2022-02-16 18:13:24 +00:00
|
|
|
|
{ stdenv, bash, 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 ]);
|
2022-02-16 17:52:36 +00:00
|
|
|
|
package = lib.attrByPath (lib.splitString "." attrPath) (throw "Cannot find attribute ‘${attrPath}’.") pkgs;
|
|
|
|
|
packageVersion = lib.getVersion package;
|
2022-02-16 18:13:24 +00:00
|
|
|
|
upperBound =
|
2020-04-24 22:04:31 +00:00
|
|
|
|
let
|
|
|
|
|
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}";
|
2022-09-24 12:58:58 +00:00
|
|
|
|
in
|
|
|
|
|
if builtins.isBool freeze then
|
|
|
|
|
lib.optionals (freeze && minorAvailable) [ upperBound ]
|
|
|
|
|
else if builtins.isString freeze then
|
|
|
|
|
[ freeze ]
|
|
|
|
|
else
|
|
|
|
|
throw "“freeze” argument needs to be either a boolean, or a version string.";
|
2018-12-01 23:50:37 +00:00
|
|
|
|
updateScript = writeScript "gnome-update-script" ''
|
2022-02-16 18:13:24 +00:00
|
|
|
|
#!${bash}/bin/bash
|
2018-12-01 23:50:37 +00:00
|
|
|
|
set -o errexit
|
2022-02-16 17:52:36 +00:00
|
|
|
|
attr_path="$1"
|
|
|
|
|
package_name="$2"
|
|
|
|
|
package_version="$3"
|
|
|
|
|
version_policy="$4"
|
2022-02-16 18:13:24 +00:00
|
|
|
|
|
2022-02-16 18:27:41 +00:00
|
|
|
|
flvFlags=("$package_name" "$version_policy" "''${GNOME_UPDATE_STABILITY:-stable}")
|
2022-02-16 18:13:24 +00:00
|
|
|
|
|
|
|
|
|
if (( $# >= 5 )); then
|
|
|
|
|
upper_bound="$5"
|
|
|
|
|
flvFlags+=("--upper-bound=$upper_bound")
|
|
|
|
|
fi
|
|
|
|
|
|
2019-06-02 07:40:55 +00:00
|
|
|
|
PATH=${lib.makeBinPath [ common-updater-scripts python ]}
|
2022-02-16 18:13:24 +00:00
|
|
|
|
latest_tag=$(python "${./find-latest-version.py}" "''${flvFlags[@]}")
|
2018-12-01 23:50:37 +00:00
|
|
|
|
update-source-version "$attr_path" "$latest_tag"
|
2022-02-16 17:52:36 +00:00
|
|
|
|
echo '[ { "commitBody": "https://gitlab.gnome.org/GNOME/'$package_name'/-/compare/'$package_version'...'$latest_tag'" } ]'
|
2018-12-01 23:50:37 +00:00
|
|
|
|
'';
|
2022-02-16 17:52:36 +00:00
|
|
|
|
in {
|
|
|
|
|
name = "gnome-update-script";
|
2022-02-16 18:13:24 +00:00
|
|
|
|
command = [ updateScript attrPath packageName packageVersion versionPolicy ] ++ upperBound;
|
2022-02-16 17:52:36 +00:00
|
|
|
|
supportedFeatures = [
|
|
|
|
|
"commit"
|
|
|
|
|
];
|
|
|
|
|
}
|