2022-03-05 16:20:37 +00:00
|
|
|
|
{ stdenv, bash, pkgs, lib, writeScript, python3, common-updater-scripts }:
|
2021-05-20 23:08:51 +00:00
|
|
|
|
{ packageName, attrPath ? packageName, versionPolicy ? "tagged", freeze ? false }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
let
|
2021-05-20 23:08:51 +00:00
|
|
|
|
python = python3.withPackages (p: [ p.requests p.libversion ]);
|
2022-03-05 16:20:37 +00:00
|
|
|
|
package = lib.attrByPath (lib.splitString "." attrPath) (throw "Cannot find attribute ‘${attrPath}’.") pkgs;
|
|
|
|
|
packageVersion = lib.getVersion package;
|
|
|
|
|
upperBound =
|
2020-04-24 23:36:52 +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-03-05 16:20:37 +00:00
|
|
|
|
in lib.optionals (freeze && minorAvailable) [ upperBound ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
updateScript = writeScript "gnome-update-script" ''
|
2022-03-05 16:20:37 +00:00
|
|
|
|
#!${bash}/bin/bash
|
2020-04-24 23:36:52 +00:00
|
|
|
|
set -o errexit
|
2022-03-05 16:20:37 +00:00
|
|
|
|
attr_path="$1"
|
|
|
|
|
package_name="$2"
|
|
|
|
|
package_version="$3"
|
|
|
|
|
version_policy="$4"
|
|
|
|
|
|
|
|
|
|
flvFlags=("$package_name" "$version_policy" "''${GNOME_UPDATE_STABILITY:-stable}")
|
|
|
|
|
|
|
|
|
|
if (( $# >= 5 )); then
|
|
|
|
|
upper_bound="$5"
|
|
|
|
|
flvFlags+=("--upper-bound=$upper_bound")
|
|
|
|
|
fi
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
PATH=${lib.makeBinPath [ common-updater-scripts python ]}
|
2022-03-05 16:20:37 +00:00
|
|
|
|
latest_tag=$(python "${./find-latest-version.py}" "''${flvFlags[@]}")
|
2020-04-24 23:36:52 +00:00
|
|
|
|
update-source-version "$attr_path" "$latest_tag"
|
2022-03-05 16:20:37 +00:00
|
|
|
|
echo '[ { "commitBody": "https://gitlab.gnome.org/GNOME/'$package_name'/-/compare/'$package_version'...'$latest_tag'" } ]'
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
2022-03-05 16:20:37 +00:00
|
|
|
|
in {
|
|
|
|
|
name = "gnome-update-script";
|
|
|
|
|
command = [ updateScript attrPath packageName packageVersion versionPolicy ] ++ upperBound;
|
|
|
|
|
supportedFeatures = [
|
|
|
|
|
"commit"
|
|
|
|
|
];
|
|
|
|
|
}
|