2020-04-24 22:04:31 +00:00
|
|
|
|
{ stdenv, pkgs, lib, writeScript, python3, common-updater-scripts }:
|
2021-03-20 23:57:24 +00:00
|
|
|
|
{ packageName, attrPath ? packageName, versionPolicy ? "tagged", freeze ? false }:
|
2017-12-25 09:46:52 +00:00
|
|
|
|
|
|
|
|
|
let
|
2021-03-20 23:57:24 +00:00
|
|
|
|
python = python3.withPackages (p: [ p.requests p.libversion ]);
|
2020-04-24 22:04:31 +00:00
|
|
|
|
upperBoundFlag =
|
|
|
|
|
let
|
2020-04-25 13:23:35 +00:00
|
|
|
|
package = lib.attrByPath (lib.splitString "." attrPath) (throw "Cannot find attribute ‘${attrPath}’.") pkgs;
|
2020-04-24 22:04:31 +00: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 13:32:16 +00:00
|
|
|
|
in lib.optionalString (freeze && minorAvailable) ''--upper-bound="${upperBound}"'';
|
2018-12-01 23:50:37 +00:00
|
|
|
|
updateScript = writeScript "gnome-update-script" ''
|
|
|
|
|
#!${stdenv.shell}
|
|
|
|
|
set -o errexit
|
|
|
|
|
package_name="$1"
|
|
|
|
|
attr_path="$2"
|
|
|
|
|
version_policy="$3"
|
2019-06-02 07:40:55 +00:00
|
|
|
|
PATH=${lib.makeBinPath [ common-updater-scripts python ]}
|
2020-04-24 22:04:31 +00:00
|
|
|
|
latest_tag=$(python "${./find-latest-version.py}" "$package_name" "$version_policy" "stable" ${upperBoundFlag})
|
2018-12-01 23:50:37 +00:00
|
|
|
|
update-source-version "$attr_path" "$latest_tag"
|
|
|
|
|
'';
|
|
|
|
|
in [ updateScript packageName attrPath versionPolicy ]
|