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