From 005ac63a1910945086e40d197164a5aae4c38090 Mon Sep 17 00:00:00 2001 From: José Romildo Date: Mon, 21 Feb 2022 12:10:33 -0300 Subject: httpTwoLevelsUpdater: init --- pkgs/common-updater/http-two-levels-updater.nix | 19 ++++++++ .../scripts/list-archive-two-level-versions | 48 ------------------- .../scripts/list-archive-two-levels-versions | 54 ++++++++++++++++++++++ pkgs/desktops/mate/default.nix | 5 +- pkgs/desktops/xfce/applications/orage/default.nix | 5 +- .../desktops/xfce/art/xfce4-icon-theme/default.nix | 6 +-- pkgs/desktops/xfce/art/xfwm4-themes/default.nix | 6 +-- pkgs/desktops/xfce/default.nix | 8 +++- .../xfce4-cpugraph-plugin/default.nix | 6 +-- .../panel-plugins/xfce4-embed-plugin/default.nix | 6 +-- .../panel-plugins/xfce4-eyes-plugin/default.nix | 6 +-- .../panel-plugins/xfce4-fsguard-plugin/default.nix | 6 +-- .../panel-plugins/xfce4-genmon-plugin/default.nix | 6 +-- .../xfce4-mailwatch-plugin/default.nix | 6 +-- .../panel-plugins/xfce4-mpc-plugin/default.nix | 6 +-- .../panel-plugins/xfce4-notes-plugin/default.nix | 6 +-- .../panel-plugins/xfce4-sensors-plugin/default.nix | 6 +-- .../xfce4-systemload-plugin/default.nix | 6 +-- .../panel-plugins/xfce4-timer-plugin/default.nix | 6 +-- .../panel-plugins/xfce4-weather-plugin/default.nix | 6 +-- pkgs/top-level/all-packages.nix | 2 + 21 files changed, 99 insertions(+), 126 deletions(-) create mode 100644 pkgs/common-updater/http-two-levels-updater.nix delete mode 100755 pkgs/common-updater/scripts/list-archive-two-level-versions create mode 100755 pkgs/common-updater/scripts/list-archive-two-levels-versions 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 0000000000000..f9e1e1b7204ad --- /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-level-versions deleted file mode 100755 index ae29d533fc3be..0000000000000 --- a/pkgs/common-updater/scripts/list-archive-two-level-versions +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -# 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 - -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" - exit 1 -fi - -# print a debugging message -if [ -n "$file" ]; then - echo "# Listing versions for '$pname' at $archive" >> $file -fi - -# list all major-minor versions from archive -tags1=$(curl -sS "$archive/") -tags1=$(echo "$tags1" | sed -rne 's,^.*,\1,p') - -# print available versions -for tag in $tags1; do - tags2=$(curl -sS "$archive/$tag/") - tags2=$(echo "$tags2" | sed -rne "s,^.*,\\1,p") - echo "$tags2" -done diff --git a/pkgs/common-updater/scripts/list-archive-two-levels-versions b/pkgs/common-updater/scripts/list-archive-two-levels-versions new file mode 100755 index 0000000000000..4263a9de3ca3e --- /dev/null +++ b/pkgs/common-updater/scripts/list-archive-two-levels-versions @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# lists all available versions listed for a package in a site (http) + +archive="" # archive url +pname="" # package name +file="" # file for writing debugging information + +while (( $# > 0 )); do + flag="$1" + shift 1 + case "$flag" in + --url=*) + archive="${flag#*=}" + ;; + --pname=*) + pname="${flag#*=}" + ;; + --file=*) + file="${flag#*=}" + ;; + *) + echo "$0: unknown option ‘${flag}’" + exit 1 + ;; + esac +done + +# 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 + echo "# Listing versions for '$pname' at $archive" >> $file +fi + +# list all major-minor versions from archive +tags1=$(curl -sS "$archive/") +tags1=$(echo "$tags1" | sed -rne 's,^.*,\1,p') + +# print available versions +for tag in $tags1; do + tags2=$(curl -sS "$archive/$tag/") + tags2=$(echo "$tags2" | sed -rne "s,^.*,\\1,p") + echo "$tags2" +done diff --git a/pkgs/desktops/mate/default.nix b/pkgs/desktops/mate/default.nix index 17107ea8947f7..2c5b45a653e54 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 7def10fb59737..4e5028a6a599b 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 209547ea67c42..8c37dde65ccb2 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 10270c7fde992..3665263ede05c 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 de418dd432cd4..1ec4cec5b31d5 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 68e44437629c5..33bdb052b6a9e 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 c79e30a658029..cc4ce861e7246 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 17fa349a1d985..08434ad25227f 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 1ba214611a65d..81498aea96f4b 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 1f7225fe958b0..1b794ff2b8364 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 2e6d0e297bb0e..fdd3af5fe402f 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 da2c4298ec4a2..566475869345f 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 124bbfe8a633f..6cb2fcc66c020 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 8edface25a861..22b4d8c4f40f9 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 ccdc051982fd7..d264181bd48fc 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 ad4add40c5bd1..c3cb16dfa830e 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 f6a9bef823f35..5ceda9cb8bd38 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 cf0796ffe21e4..6726ff8e0041d 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 { }; -- cgit 1.4.1