2020-04-24 23:04:31 +01:00
|
|
|
|
{ stdenv, pkgs, lib, writeScript, python3, common-updater-scripts }:
|
|
|
|
|
{ packageName, attrPath ? packageName, versionPolicy ? "odd-unstable", freeze ? false }:
|
2017-12-25 09:46:52 +00:00
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
python = python3.withPackages (p: [ p.requests ]);
|
2020-04-24 23:04:31 +01:00
|
|
|
|
upperBoundFlag =
|
|
|
|
|
let
|
2020-04-25 14:23:35 +01:00
|
|
|
|
package = lib.attrByPath (lib.splitString "." attrPath) (throw "Cannot find attribute ‘${attrPath}’.") pkgs;
|
2020-04-24 23:04:31 +01: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 14:32:16 +01: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 08:40:55 +01:00
|
|
|
|
PATH=${lib.makeBinPath [ common-updater-scripts python ]}
|
2020-04-24 23:04:31 +01: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 ]
|