From 005ac63a1910945086e40d197164a5aae4c38090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Romildo?= Date: Mon, 21 Feb 2022 12:10:33 -0300 Subject: [PATCH] httpTwoLevelsUpdater: init --- .../http-two-levels-updater.nix | 19 ++++++++++++++++ ...sions => list-archive-two-levels-versions} | 22 ++++++++++++------- pkgs/desktops/mate/default.nix | 5 ++--- .../xfce/applications/orage/default.nix | 5 ++--- .../xfce/art/xfce4-icon-theme/default.nix | 6 +---- .../xfce/art/xfwm4-themes/default.nix | 6 +---- pkgs/desktops/xfce/default.nix | 8 +++++-- .../xfce4-cpugraph-plugin/default.nix | 6 +---- .../xfce4-embed-plugin/default.nix | 6 +---- .../xfce4-eyes-plugin/default.nix | 6 +---- .../xfce4-fsguard-plugin/default.nix | 6 +---- .../xfce4-genmon-plugin/default.nix | 6 +---- .../xfce4-mailwatch-plugin/default.nix | 6 +---- .../xfce4-mpc-plugin/default.nix | 6 +---- .../xfce4-notes-plugin/default.nix | 6 +---- .../xfce4-sensors-plugin/default.nix | 6 +---- .../xfce4-systemload-plugin/default.nix | 6 +---- .../xfce4-timer-plugin/default.nix | 6 +---- .../xfce4-weather-plugin/default.nix | 6 +---- pkgs/top-level/all-packages.nix | 2 ++ 20 files changed, 59 insertions(+), 86 deletions(-) create mode 100644 pkgs/common-updater/http-two-levels-updater.nix rename pkgs/common-updater/scripts/{list-archive-two-level-versions => list-archive-two-levels-versions} (64%) diff --git a/pkgs/common-updater/http-two-levels-updater.nix b/pkgs/common-updater/http-two-levels-updater.nix new file mode 100644 index 000000000000..f9e1e1b7204a --- /dev/null +++ b/pkgs/common-updater/http-two-levels-updater.nix @@ -0,0 +1,19 @@ +{ lib +, genericUpdater +, common-updater-scripts +}: + +{ pname +, version +, attrPath ? pname +, ignoredVersions ? "" +, rev-prefix ? "" +, odd-unstable ? false +, patchlevel-unstable ? false +, url ? null +}: + +genericUpdater { + inherit pname version attrPath ignoredVersions rev-prefix odd-unstable patchlevel-unstable; + versionLister = "${common-updater-scripts}/bin/list-archive-two-levels-versions ${lib.optionalString (url != null) "--url=${url}"}"; +} diff --git a/pkgs/common-updater/scripts/list-archive-two-level-versions b/pkgs/common-updater/scripts/list-archive-two-levels-versions similarity index 64% rename from pkgs/common-updater/scripts/list-archive-two-level-versions rename to pkgs/common-updater/scripts/list-archive-two-levels-versions index ae29d533fc3b..4263a9de3ca3 100755 --- a/pkgs/common-updater/scripts/list-archive-two-level-versions +++ b/pkgs/common-updater/scripts/list-archive-two-levels-versions @@ -2,9 +2,9 @@ # lists all available versions listed for a package in a site (http) -archive="$1" # archive url -pname="$2" # package name -file="$3" # file for writing debugging information +archive="" # archive url +pname="" # package name +file="" # file for writing debugging information while (( $# > 0 )); do flag="$1" @@ -17,7 +17,7 @@ while (( $# > 0 )); do pname="${flag#*=}" ;; --file=*) - version="${flag#*=}" + file="${flag#*=}" ;; *) echo "$0: unknown option ‘${flag}’" @@ -26,13 +26,19 @@ while (( $# > 0 )); do esac done -if [ -z "$archive" ]; then - echo "$scriptName: Missing archive url" - exit 1 +# by default set url to the base dir of the first url in src.urls +if [[ -z "$archive" ]]; then + archive="$(nix-instantiate $systemArg --eval -E \ + "with import ./. {}; dirOf (dirOf (lib.head $UPDATE_NIX_ATTR_PATH.src.urls))" \ + | tr -d '"')" +fi + +if [[ -z "$pname" ]]; then + pname="$UPDATE_NIX_ATTR_PATH" fi # print a debugging message -if [ -n "$file" ]; then +if [[ -n "$file" ]]; then echo "# Listing versions for '$pname' at $archive" >> $file fi diff --git a/pkgs/desktops/mate/default.nix b/pkgs/desktops/mate/default.nix index 17107ea8947f..2c5b45a653e5 100644 --- a/pkgs/desktops/mate/default.nix +++ b/pkgs/desktops/mate/default.nix @@ -7,10 +7,9 @@ let # Update script tailored to mate packages from git repository mateUpdateScript = { pname, version, odd-unstable ? true, url ? "https://pub.mate-desktop.org/releases" }: - pkgs.genericUpdater { - inherit pname version odd-unstable; + pkgs.httpTwoLevelsUpdater { + inherit pname version odd-unstable url; attrPath = "mate.${pname}"; - versionLister = "${pkgs.common-updater-scripts}/bin/list-archive-two-level-versions --url=${url}"; }; atril = callPackage ./atril { }; diff --git a/pkgs/desktops/xfce/applications/orage/default.nix b/pkgs/desktops/xfce/applications/orage/default.nix index 7def10fb5973..4e5028a6a599 100644 --- a/pkgs/desktops/xfce/applications/orage/default.nix +++ b/pkgs/desktops/xfce/applications/orage/default.nix @@ -38,10 +38,9 @@ stdenv.mkDerivation rec { }) ]; - passthru.updateScript = xfce.genericUpdater { + passthru.updateScript = xfce.archiveUpdater { + category = "apps"; inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister "apps" pname; }; meta = with lib; { diff --git a/pkgs/desktops/xfce/art/xfce4-icon-theme/default.nix b/pkgs/desktops/xfce/art/xfce4-icon-theme/default.nix index 209547ea67c4..8c37dde65ccb 100644 --- a/pkgs/desktops/xfce/art/xfce4-icon-theme/default.nix +++ b/pkgs/desktops/xfce/art/xfce4-icon-theme/default.nix @@ -28,11 +28,7 @@ stdenv.mkDerivation rec { dontDropIconThemeCache = true; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://www.xfce.org/"; diff --git a/pkgs/desktops/xfce/art/xfwm4-themes/default.nix b/pkgs/desktops/xfce/art/xfwm4-themes/default.nix index 10270c7fde99..3665263ede05 100644 --- a/pkgs/desktops/xfce/art/xfwm4-themes/default.nix +++ b/pkgs/desktops/xfce/art/xfwm4-themes/default.nix @@ -13,11 +13,7 @@ stdenv.mkDerivation rec { sha256 = "sha256-MhTV8A6XA7XoyefDKH1gbe3scoXOtNXbMy6TraZv1XU="; }; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://www.xfce.org/"; diff --git a/pkgs/desktops/xfce/default.nix b/pkgs/desktops/xfce/default.nix index de418dd432cd..1ec4cec5b31d 100644 --- a/pkgs/desktops/xfce/default.nix +++ b/pkgs/desktops/xfce/default.nix @@ -5,8 +5,12 @@ lib.makeScope pkgs.newScope (self: with self; { genericUpdater = pkgs.genericUpdater; - archiveLister = category: name: - "${pkgs.common-updater-scripts}/bin/list-archive-two-level-versions --url=https://archive.xfce.org/src/${category}/${name}"; + archiveUpdater = { category, pname, version }: + pkgs.httpTwoLevelsUpdater { + inherit pname version; + attrPath = "xfce.${pname}"; + url = "https://archive.xfce.org/src/${category}/${pname}"; + }; mkXfceDerivation = callPackage ./mkXfceDerivation.nix { }; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-cpugraph-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-cpugraph-plugin/default.nix index 68e44437629c..33bdb052b6a9 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-cpugraph-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-cpugraph-plugin/default.nix @@ -45,11 +45,7 @@ in stdenv.mkDerivation rec { hicolor-icon-theme ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-cpugraph-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-embed-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-embed-plugin/default.nix index c79e30a65802..cc4ce861e724 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-embed-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-embed-plugin/default.nix @@ -33,11 +33,7 @@ in stdenv.mkDerivation rec { gtk2 ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib;{ homepage = "https://docs.xfce.org/panel-plugins/xfce4-embed-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-eyes-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-eyes-plugin/default.nix index 17fa349a1d98..08434ad25227 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-eyes-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-eyes-plugin/default.nix @@ -35,11 +35,7 @@ in stdenv.mkDerivation rec { gtk3 ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-eyes-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-fsguard-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-fsguard-plugin/default.nix index 1ba214611a65..81498aea96f4 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-fsguard-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-fsguard-plugin/default.nix @@ -35,11 +35,7 @@ in stdenv.mkDerivation rec { gtk3 ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-fsguard-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-genmon-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-genmon-plugin/default.nix index 1f7225fe958b..1b794ff2b836 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-genmon-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-genmon-plugin/default.nix @@ -33,11 +33,7 @@ in stdenv.mkDerivation rec { gtk3 ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-genmon-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-mailwatch-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-mailwatch-plugin/default.nix index 2e6d0e297bb0..fdd3af5fe402 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-mailwatch-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-mailwatch-plugin/default.nix @@ -27,11 +27,7 @@ stdenv.mkDerivation rec { libgcrypt ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-mailwatch-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-mpc-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-mpc-plugin/default.nix index da2c4298ec4a..566475869345 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-mpc-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-mpc-plugin/default.nix @@ -27,11 +27,7 @@ stdenv.mkDerivation rec { exo ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-mpc-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-notes-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-notes-plugin/default.nix index 124bbfe8a633..6cb2fcc66c02 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-notes-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-notes-plugin/default.nix @@ -31,11 +31,7 @@ in stdenv.mkDerivation rec { xfconf ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-notes-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-sensors-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-sensors-plugin/default.nix index 8edface25a86..22b4d8c4f40f 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-sensors-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-sensors-plugin/default.nix @@ -38,11 +38,7 @@ stdenv.mkDerivation rec { "--with-pathnetcat=${netcat-gnu}/bin/netcat" ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-sensors-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-systemload-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-systemload-plugin/default.nix index ccdc051982fd..d264181bd48f 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-systemload-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-systemload-plugin/default.nix @@ -31,11 +31,7 @@ in stdenv.mkDerivation rec { xfconf ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-systemload-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-timer-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-timer-plugin/default.nix index ad4add40c5bd..c3cb16dfa830 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-timer-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-timer-plugin/default.nix @@ -28,11 +28,7 @@ stdenv.mkDerivation rec { hardeningDisable = [ "format" ]; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-timer-plugin"; diff --git a/pkgs/desktops/xfce/panel-plugins/xfce4-weather-plugin/default.nix b/pkgs/desktops/xfce/panel-plugins/xfce4-weather-plugin/default.nix index f6a9bef823f3..5ceda9cb8bd3 100644 --- a/pkgs/desktops/xfce/panel-plugins/xfce4-weather-plugin/default.nix +++ b/pkgs/desktops/xfce/panel-plugins/xfce4-weather-plugin/default.nix @@ -31,11 +31,7 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - passthru.updateScript = xfce.genericUpdater { - inherit pname version; - attrPath = "xfce.${pname}"; - versionLister = xfce.archiveLister category pname; - }; + passthru.updateScript = xfce.archiveUpdater { inherit category pname version; }; meta = with lib; { homepage = "https://docs.xfce.org/panel-plugins/xfce4-weather-plugin"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cf0796ffe21e..6726ff8e0041 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -109,6 +109,8 @@ with pkgs; gitUpdater = callPackage ../common-updater/git-updater.nix { }; + httpTwoLevelsUpdater = callPackage ../common-updater/http-two-levels-updater.nix { }; + unstableGitUpdater = callPackage ../common-updater/unstable-updater.nix { }; nix-update-script = callPackage ../common-updater/nix-update.nix { };