2020-04-25 00:04:31 +02:00
|
|
|
|
{ stdenv, pkgs, lib, writeScript, python3, common-updater-scripts }:
|
2021-03-21 00:57:24 +01:00
|
|
|
|
{ packageName, attrPath ? packageName, versionPolicy ? "tagged", freeze ? false }:
|
2017-12-25 10:46:52 +01:00
|
|
|
|
|
|
|
|
|
let
|
2021-03-21 00:57:24 +01:00
|
|
|
|
python = python3.withPackages (p: [ p.requests p.libversion ]);
|
2020-04-25 00:04:31 +02:00
|
|
|
|
upperBoundFlag =
|
|
|
|
|
let
|
2020-04-25 15:23:35 +02:00
|
|
|
|
package = lib.attrByPath (lib.splitString "." attrPath) (throw "Cannot find attribute ‘${attrPath}’.") pkgs;
|
2020-04-25 00:04:31 +02:00
|
|
|
|
packageVersion = lib.getVersion package;
|
|
|
|
|
versionComponents = lib.versions.splitVersion packageVersion;
|
|
|
|
|
minorVersion = lib.versions.minor packageVersion;
|
|
|
|
|
minorAvailable = builtins.length versionComponents > 1 && builtins.match "[0-9]+" minorVersion != null;
|
|
|
|
|
nextMinor = builtins.fromJSON minorVersion + 1;
|
|
|
|
|
upperBound = "${lib.versions.major packageVersion}.${builtins.toString nextMinor}";
|
2020-04-25 15:32:16 +02:00
|
|
|
|
in lib.optionalString (freeze && minorAvailable) ''--upper-bound="${upperBound}"'';
|
2018-12-02 00:50:37 +01:00
|
|
|
|
updateScript = writeScript "gnome-update-script" ''
|
|
|
|
|
#!${stdenv.shell}
|
|
|
|
|
set -o errexit
|
|
|
|
|
package_name="$1"
|
|
|
|
|
attr_path="$2"
|
|
|
|
|
version_policy="$3"
|
2019-06-02 09:40:55 +02:00
|
|
|
|
PATH=${lib.makeBinPath [ common-updater-scripts python ]}
|
2020-04-25 00:04:31 +02:00
|
|
|
|
latest_tag=$(python "${./find-latest-version.py}" "$package_name" "$version_policy" "stable" ${upperBoundFlag})
|
2018-12-02 00:50:37 +01:00
|
|
|
|
update-source-version "$attr_path" "$latest_tag"
|
|
|
|
|
'';
|
|
|
|
|
in [ updateScript packageName attrPath versionPolicy ]
|