gitUpdater: init

- Add the 'gitUpdater' helper function to update git based packages, using the
'genericUpdater' function.
- Rework argument passing to the `list-git-tags' and 'list-archive-two-level-versions' scripts.
- Replace 'genericUpdater' plus 'list-git-tags' by 'gitUpdater'
This commit is contained in:
José Romildo 2022-02-20 22:11:49 -03:00
parent 60966b5a6e
commit ba59355e81
46 changed files with 136 additions and 111 deletions

View File

@ -1,8 +1,7 @@
{ lib
, fetchFromGitHub
, genericUpdater
, gitUpdater
, substituteAll
, common-updater-scripts
, ffmpeg
, python3Packages
, sox
@ -33,12 +32,7 @@ python3Packages.buildPythonApplication rec {
# sandbox to be disabled.
doCheck = false;
passthru = {
updateScript = genericUpdater {
inherit pname version;
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
};
};
passthru.updateScript = gitUpdater { inherit pname version; };
meta = with lib; {
description = "Fast audio loudness scanner & tagger (ReplayGain v2 / R128)";

View File

@ -26,7 +26,7 @@ getRepo() {
}
getLatestVersionTag() {
"$nixpkgs"/pkgs/common-updater/scripts/list-git-tags https://github.com/$(getRepo) 2>/dev/null \
"$nixpkgs"/pkgs/common-updater/scripts/list-git-tags --url=https://github.com/$(getRepo) 2>/dev/null \
| sort -V | tail -1 | sed 's|^v||'
}

View File

@ -1,8 +1,7 @@
{ lib
, buildGoModule
, fetchFromGitHub
, genericUpdater
, common-updater-scripts
, gitUpdater
, makeWrapper
, openssh
}:
@ -25,9 +24,8 @@ buildGoModule rec {
ldflags = [ "-s" "-w" "-X main.AgentVersion=v${version}" ];
passthru = {
updateScript = genericUpdater {
updateScript = gitUpdater {
inherit pname version;
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
rev-prefix = "v";
ignoredVersions = ".(rc|beta).*";
};

View File

@ -4,8 +4,7 @@
, pbr
, requests
, setuptools
, genericUpdater
, common-updater-scripts
, gitUpdater
}:
buildPythonApplication rec {
@ -42,10 +41,7 @@ buildPythonApplication rec {
pythonImportsCheck = [ "git_review" ];
passthru.updateScript = genericUpdater {
inherit pname version;
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
};
passthru.updateScript = gitUpdater { inherit pname version; };
meta = with lib; {
description = "Tool to submit code to Gerrit";

View File

@ -13,7 +13,7 @@ let
inherit pname version;
attrPath = lib.toLower pname;
rev-prefix = "v";
versionLister = "${common-updater-scripts}/bin/list-git-tags ${homepage}";
versionLister = "${common-updater-scripts}/bin/list-git-tags --url=${homepage}";
};
updateScript = builtins.elemAt updater 0;
updateArgs = map (lib.escapeShellArg) (builtins.tail updater);

View File

@ -17,7 +17,7 @@ let
# exclude prerelease versions
versionLister = writers.writeBash "list-mirakurun-versions" ''
${common-updater-scripts}/bin/list-git-tags ${homepage} \
${common-updater-scripts}/bin/list-git-tags --url=${homepage} \
| grep '^[0-9]\+\.[0-9]\+\.[0-9]\+$'
'';
};

View File

@ -17,8 +17,7 @@
, qtgraphicaleffects
, qmake
, qttools
, genericUpdater
, common-updater-scripts
, gitUpdater
}:
assert lib.versionAtLeast mlt.version "6.24.0";
@ -76,9 +75,8 @@ mkDerivation rec {
cp -r src/qml $out/share/shotcut/
'';
passthru.updateScript = genericUpdater {
passthru.updateScript = gitUpdater {
inherit pname version;
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
rev-prefix = "v";
};

View File

@ -55,7 +55,7 @@ let
return 1
}
tags=$($version_lister $pname ${fileForGitCommands}) || exit 1
tags=$($version_lister --pname=${pname} --file="${fileForGitCommands}") || exit 1
# print available tags
for tag in $tags; do

View File

@ -0,0 +1,17 @@
{ genericUpdater
, common-updater-scripts
}:
{ pname
, version
, attrPath ? pname
, ignoredVersions ? ""
, rev-prefix ? ""
, odd-unstable ? false
, patchlevel-unstable ? false
}:
genericUpdater {
inherit pname version attrPath ignoredVersions rev-prefix odd-unstable patchlevel-unstable;
versionLister = "${common-updater-scripts}/bin/list-git-tags";
}

View File

@ -2,25 +2,38 @@
# lists all available versions listed for a package in a site (http)
scriptName=list-archive-two-level-versions # do not use the .wrapped name
usage() {
echo "Usage: $scriptName <archive url> [<package name> [<debug file path>]]"
}
archive="$1" # archive url
pname="$2" # package name
file="$3" # file for writing debugging information
while (( $# > 0 )); do
flag="$1"
shift 1
case "$flag" in
--url=*)
archive="${flag#*=}"
;;
--pname=*)
pname="${flag#*=}"
;;
--file=*)
version="${flag#*=}"
;;
*)
echo "$0: unknown option ${flag}"
exit 1
;;
esac
done
if [ -z "$archive" ]; then
echo "$scriptName: Missing archive url"
usage
exit 1
fi
# print a debugging message
if [ -n "$file" ]; then
echo "# Listing versions for $pname at $archive" >> $file
echo "# Listing versions for '$pname' at $archive" >> $file
fi
# list all major-minor versions from archive

View File

@ -2,29 +2,50 @@
# lists all available tags from a git repository
scriptName=list-git-tags # do not use the .wrapped name
echo "# pname=$UPDATE_NIX_ATTR_PATH" > /tmp/test.txt
usage() {
echo "Usage: $scriptName <repository url> [<package name> [<debug file path>]]"
}
url="" # git repository url
pname="" # package name
file="" # file for writing debugging information
repo="$1" # git repository url
pname="$2" # package name
file="$3" # file for writing debugging information
while (( $# > 0 )); do
flag="$1"
shift 1
case "$flag" in
--url=*)
url="${flag#*=}"
;;
--pname=*)
pname="${flag#*=}"
;;
--file=*)
file="${flag#*=}"
;;
*)
echo "$0: unknown option ${flag}"
exit 1
;;
esac
done
if [ -z "$repo" ]; then
echo "$scriptName: Missing git repository url"
usage
exit 1
# By default we set url to src.url or src.meta.homepage
if [[ -z "$url" ]]; then
url="$(nix-instantiate $systemArg --eval -E \
"with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.url or $UPDATE_NIX_ATTR_PATH.src.meta.homepage" \
| tr -d '"')"
fi
if [[ -z "$pname" ]]; then
pname="$UPDATE_NIX_ATTR_PATH"
fi
# print a debugging message
if [ -n "$file" ]; then
echo "# Listing tags for $pname at $repo" >> $file
if [[ -n "$file" ]]; then
echo "# Listing tags for '$pname' at $url" >> $file
fi
# list all tags from the remote repository
tags=$(git ls-remote --tags --refs "$repo")
tags=$(git ls-remote --tags --refs "$url")
# keep only the version part of the tag
tags=$(echo "$tags" | cut --delimiter=/ --field=3)

View File

@ -8,7 +8,7 @@ repo=https://github.com/be5invis/Iosevka
# Discover the latest version.
current_version=$(nix-instantiate "$nixpkgs" --eval --strict -A iosevka.version | tr -d '"')
new_version=$(list-git-tags "$repo" | sort --reverse --version-sort | awk 'match($0, /^v([0-9.]+)$/, m) { print m[1]; exit; }')
new_version=$(list-git-tags --url="$repo" | sort --reverse --version-sort | awk 'match($0, /^v([0-9.]+)$/, m) { print m[1]; exit; }')
if [[ "$new_version" == "$current_version" ]]; then
echo "iosevka: no update found"
exit

View File

@ -5,6 +5,7 @@
, gtk-engine-murrine
, gtk_engines
, librsvg
, gitUpdater
}:
stdenv.mkDerivation rec {
@ -37,6 +38,8 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
passthru.updateScript = gitUpdater {inherit pname version; };
meta = with lib; {
description = "GTK theme supporting Budgie, Pantheon, Mate, Xfce4 and GNOME desktops";
homepage = "https://www.pling.com/p/1239855/";

View File

@ -4,10 +4,9 @@ let
# Update script tailored to LXQt packages from git repository
lxqtUpdateScript = { pname, version, src }:
pkgs.genericUpdater {
pkgs.gitUpdater {
inherit pname version;
attrPath = "lxqt.${pname}";
versionLister = "${pkgs.common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
};
# For compiling information, see:

View File

@ -10,7 +10,7 @@ let
pkgs.genericUpdater {
inherit pname version odd-unstable;
attrPath = "mate.${pname}";
versionLister = "${pkgs.common-updater-scripts}/bin/list-archive-two-level-versions ${url}";
versionLister = "${pkgs.common-updater-scripts}/bin/list-archive-two-level-versions --url=${url}";
};
atril = callPackage ./atril { };

View File

@ -9,8 +9,7 @@
, gobject-introspection
, wrapGAppsHook
, glib
, genericUpdater
, common-updater-scripts
, gitUpdater
}:
python3Packages.buildPythonApplication rec {
@ -74,10 +73,9 @@ python3Packages.buildPythonApplication rec {
done
'';
passthru.updateScript = genericUpdater {
passthru.updateScript = gitUpdater {
inherit pname version;
attrPath = "mate.${pname}";
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
};
meta = with lib; {

View File

@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
})
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister "apps" pname;

View File

@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
dontDropIconThemeCache = true;
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
sha256 = "sha256-MhTV8A6XA7XoyefDKH1gbe3scoXOtNXbMy6TraZv1XU=";
};
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -3,13 +3,10 @@
lib.makeScope pkgs.newScope (self: with self; {
#### NixOS support
updateScript = pkgs.genericUpdater;
gitLister = url:
"${pkgs.common-updater-scripts}/bin/list-git-tags ${url}";
genericUpdater = pkgs.genericUpdater;
archiveLister = category: name:
"${pkgs.common-updater-scripts}/bin/list-archive-two-level-versions https://archive.xfce.org/src/${category}/${name}";
"${pkgs.common-updater-scripts}/bin/list-archive-two-level-versions --url=https://archive.xfce.org/src/${category}/${name}";
mkXfceDerivation = callPackage ./mkXfceDerivation.nix { };

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitLab, pkg-config, xfce4-dev-tools, hicolor-icon-theme, xfce, wrapGAppsHook }:
{ lib, stdenv, fetchFromGitLab, pkg-config, xfce4-dev-tools, hicolor-icon-theme, xfce, wrapGAppsHook, gitUpdater }:
{ category
, pname
@ -41,9 +41,8 @@ let
pos = builtins.unsafeGetAttrPos "pname" args;
passthru.updateScript = xfce.updateScript {
passthru.updateScript = gitUpdater {
inherit pname version attrPath rev-prefix odd-unstable patchlevel-unstable;
versionLister = xfce.gitLister src.meta.homepage;
};
meta = with lib; {

View File

@ -45,7 +45,7 @@ in stdenv.mkDerivation rec {
hicolor-icon-theme
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -33,7 +33,7 @@ in stdenv.mkDerivation rec {
gtk2
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -35,7 +35,7 @@ in stdenv.mkDerivation rec {
gtk3
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -35,7 +35,7 @@ in stdenv.mkDerivation rec {
gtk3
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -33,7 +33,7 @@ in stdenv.mkDerivation rec {
gtk3
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
libgcrypt
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
exo
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -1,5 +1,7 @@
{ lib, stdenv, pkg-config, fetchFromGitHub, python3, vala
, gtk3, libwnck, libxfce4util, xfce4-panel, wafHook, xfce }:
, gtk3, libwnck, libxfce4util, xfce4-panel, wafHook, xfce
, gitUpdater
}:
stdenv.mkDerivation rec {
pname = "xfce4-namebar-plugin";
@ -20,10 +22,9 @@ stdenv.mkDerivation rec {
substituteInPlace src/preferences.vala --replace 'var dir_strings = Environment.get_system_data_dirs()' "string[] dir_strings = { \"$out/share\" }"
'';
passthru.updateScript = xfce.updateScript {
passthru.updateScript = gitUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.gitLister src.meta.homepage;
rev-prefix = "v";
};

View File

@ -31,7 +31,7 @@ in stdenv.mkDerivation rec {
xfconf
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -38,7 +38,7 @@ stdenv.mkDerivation rec {
"--with-pathnetcat=${netcat-gnu}/bin/netcat"
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -31,7 +31,7 @@ in stdenv.mkDerivation rec {
xfconf
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
hardeningDisable = [ "format" ];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -31,7 +31,7 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
passthru.updateScript = xfce.updateScript {
passthru.updateScript = xfce.genericUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.archiveLister category pname;

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, pkg-config, intltool, python3, imagemagick, libwnck, libxfce4ui, xfce4-panel, xfconf, xfce4-dev-tools, xfce }:
{ lib, stdenv, fetchFromGitHub, pkg-config, intltool, python3, imagemagick, libwnck, libxfce4ui, xfce4-panel, xfconf, xfce4-dev-tools, xfce, gitUpdater }:
stdenv.mkDerivation rec {
pname = "xfce4-windowck-plugin";
@ -33,10 +33,9 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
passthru.updateScript = xfce.updateScript {
passthru.updateScript = gitUpdater {
inherit pname version;
attrPath = "xfce.${pname}";
versionLister = xfce.gitLister src.meta.homepage;
rev-prefix = "v";
};

View File

@ -6,6 +6,7 @@
, cmake
, ninja
, xfce
, gitUpdater
}:
stdenv.mkDerivation rec {
@ -30,10 +31,9 @@ stdenv.mkDerivation rec {
gtk3
];
passthru.updateScript = xfce.updateScript {
passthru.updateScript = gitUpdater {
inherit pname version;
attrPath = "xfce.thunar-dropbox-plugin";
versionLister = xfce.gitLister src.meta.homepage;
};
meta = with lib; {

View File

@ -24,7 +24,7 @@ in rebar3Relx rec {
set -euo pipefail
latest=$(list-git-tags https://github.com/${owner}/${repo}.git | sort -V | tail -1)
latest=$(list-git-tags --url=https://github.com/${owner}/${repo}.git | sort -V | tail -1)
if [ "$latest" != "${version}" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
nix_path="$nixpkgs/pkgs/development/beam-modules/elvis-erlang"

View File

@ -51,7 +51,7 @@ rebar3Relx {
#! nix-shell -i bash -p common-updater-scripts coreutils git gnused gnutar gzip "rebar3WithPlugins { globalPlugins = [ beamPackages.rebar3-nix ]; }"
set -ox errexit
latest=$(list-git-tags https://github.com/${owner}/${repo}.git | sed -n '/[\d\.]\+/p' | sort -V | tail -1)
latest=$(list-git-tags --url=https://github.com/${owner}/${repo}.git | sed -n '/[\d\.]\+/p' | sort -V | tail -1)
if [[ "$latest" != "${version}" ]]; then
nixpkgs="$(git rev-parse --show-toplevel)"
nix_path="$nixpkgs/pkgs/development/beam-modules/erlang-ls"

View File

@ -154,7 +154,7 @@ stdenv.mkDerivation ({
#!${stdenv.shell}
set -ox errexit
PATH=${lib.makeBinPath [ common-updater-scripts coreutils git gnused ]}
latest=$(list-git-tags https://github.com/erlang/otp.git | sed -n 's/^OTP-${major}/${major}/p' | sort -V | tail -1)
latest=$(list-git-tags --url=https://github.com/erlang/otp.git | sed -n 's/^OTP-${major}/${major}/p' | sort -V | tail -1)
if [ "$latest" != "${version}" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
nix_file="$nixpkgs/pkgs/development/interpreters/erlang/R${major}.nix"

View File

@ -1,7 +1,7 @@
{ lib, stdenv, fetchFromGitLab, pkg-config
, qmake, qtbase, qtdeclarative, wrapQtAppsHook
, glib, gobject-introspection
, genericUpdater, common-updater-scripts
, gitUpdater
}:
stdenv.mkDerivation rec {
@ -55,10 +55,9 @@ stdenv.mkDerivation rec {
done
'';
passthru.updateScript = genericUpdater {
passthru.updateScript = gitUpdater {
inherit pname version;
rev-prefix = "v";
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
};
meta = with lib; {

View File

@ -10,8 +10,7 @@
, pcre2
# update script
, genericUpdater
, common-updater-scripts
, gitUpdater
}:
stdenv.mkDerivation rec {
@ -40,9 +39,8 @@ stdenv.mkDerivation rec {
"-DCMAKE_BUILD_TYPE:String=Release"
];
passthru.updateScript = genericUpdater {
passthru.updateScript = gitUpdater {
inherit pname version;
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
rev-prefix = "v";
};

View File

@ -1,7 +1,7 @@
{ lib, stdenv, fetchFromGitHub, makeWrapper
, SDL, ffmpeg_4, frei0r, libjack2, libdv, libsamplerate, libexif
, libvorbis, libxml2, movit, pkg-config, sox, fftw, opencv4, SDL2
, gtk2, genericUpdater, common-updater-scripts, libebur128
, gtk2, gitUpdater, libebur128
, jack2, ladspa-sdk, swig, which, ncurses
, enablePython ? false, python3
}:
@ -51,9 +51,8 @@ stdenv.mkDerivation rec {
sed -i ${outPythonPath}/mlt/__init__.py -e "s|return importlib.import_module('_mlt')|return importlib.import_module('mlt._mlt')|g"
'';
passthru.updateScript = genericUpdater {
passthru.updateScript = gitUpdater {
inherit pname version;
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
rev-prefix = "v";
};

View File

@ -18,8 +18,7 @@
, vid-stab
, opencv3
, ladspa-sdk
, genericUpdater
, common-updater-scripts
, gitUpdater
, ladspaPlugins
, mkDerivation
, which
@ -70,9 +69,8 @@ mkDerivation rec {
inherit ffmpeg;
};
passthru.updateScript = genericUpdater {
passthru.updateScript = gitUpdater {
inherit pname version;
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
rev-prefix = "v";
};

View File

@ -81,7 +81,7 @@ let
(rebar3WithPlugins { globalPlugins = [rebar3-nix]; })
]
}
latest=$(list-git-tags https://github.com/${owner}/${pname}.git | sed -n '/[\d\.]\+/p' | sort -V | tail -1)
latest=$(list-git-tags --url=https://github.com/${owner}/${pname}.git | sed -n '/[\d\.]\+/p' | sort -V | tail -1)
if [ "$latest" != "${version}" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
nix_path="$nixpkgs/pkgs/development/tools/build-managers/rebar3"

View File

@ -1,8 +1,7 @@
{ lib
, stdenv
, fetchFromGitHub
, genericUpdater
, common-updater-scripts
, gitUpdater
, autoreconfHook
}:
@ -19,10 +18,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ autoreconfHook ];
passthru.updateScript = genericUpdater {
inherit pname version;
versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
};
passthru.updateScript = gitUpdater { inherit pname version; };
meta = {
description = "SCSI Tape Encryption Manager";

View File

@ -107,6 +107,8 @@ with pkgs;
genericUpdater = callPackage ../common-updater/generic-updater.nix { };
gitUpdater = callPackage ../common-updater/git-updater.nix { };
unstableGitUpdater = callPackage ../common-updater/unstable-updater.nix { };
nix-update-script = callPackage ../common-updater/nix-update.nix { };