about summary refs log tree commit diff
path: root/nixpkgs/pkgs/common-updater
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-03-15 10:36:38 +0000
committerAlyssa Ross <hi@alyssa.is>2022-03-16 11:37:19 +0000
commitd435710923ac6e6f9fc155534800745004f2ce93 (patch)
tree386f9401476f96bdc6ec25173a090198942b5d5b /nixpkgs/pkgs/common-updater
parentc725f0011e91ae49d351b981690eb66b862b6104 (diff)
parent3239fd2b8f728106491154b44625662e10259af2 (diff)
downloadnixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.gz
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.bz2
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.lz
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.xz
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.tar.zst
nixlib-d435710923ac6e6f9fc155534800745004f2ce93.zip
Merge commit '3239fd2b8f728106491154b44625662e10259af2'
Conflicts:
	nixpkgs/pkgs/applications/window-managers/sway/default.nix
Diffstat (limited to 'nixpkgs/pkgs/common-updater')
-rw-r--r--nixpkgs/pkgs/common-updater/generic-updater.nix2
-rw-r--r--nixpkgs/pkgs/common-updater/git-updater.nix17
-rw-r--r--nixpkgs/pkgs/common-updater/http-two-levels-updater.nix19
-rwxr-xr-xnixpkgs/pkgs/common-updater/scripts/list-archive-two-level-versions35
-rwxr-xr-xnixpkgs/pkgs/common-updater/scripts/list-archive-two-levels-versions54
-rwxr-xr-xnixpkgs/pkgs/common-updater/scripts/list-git-tags53
6 files changed, 128 insertions, 52 deletions
diff --git a/nixpkgs/pkgs/common-updater/generic-updater.nix b/nixpkgs/pkgs/common-updater/generic-updater.nix
index 8483f9bbd1de..df47df14b85b 100644
--- a/nixpkgs/pkgs/common-updater/generic-updater.nix
+++ b/nixpkgs/pkgs/common-updater/generic-updater.nix
@@ -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
diff --git a/nixpkgs/pkgs/common-updater/git-updater.nix b/nixpkgs/pkgs/common-updater/git-updater.nix
new file mode 100644
index 000000000000..304bad9af60c
--- /dev/null
+++ b/nixpkgs/pkgs/common-updater/git-updater.nix
@@ -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";
+}
diff --git a/nixpkgs/pkgs/common-updater/http-two-levels-updater.nix b/nixpkgs/pkgs/common-updater/http-two-levels-updater.nix
new file mode 100644
index 000000000000..f9e1e1b7204a
--- /dev/null
+++ b/nixpkgs/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/nixpkgs/pkgs/common-updater/scripts/list-archive-two-level-versions b/nixpkgs/pkgs/common-updater/scripts/list-archive-two-level-versions
deleted file mode 100755
index 36a051e97c91..000000000000
--- a/nixpkgs/pkgs/common-updater/scripts/list-archive-two-level-versions
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-
-# 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
-
-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
-fi
-
-# list all major-minor versions from archive
-tags1=$(curl -sS "$archive/")
-tags1=$(echo "$tags1" | sed -rne 's,^<a href="([0-9]+\.[0-9]+)/">.*,\1,p')
-
-# print available versions
-for tag in $tags1; do
-    tags2=$(curl -sS "$archive/$tag/")
-    tags2=$(echo "$tags2" | sed -rne "s,^<a href=\"$pname-([0-9.]+)\\.[^0-9].*\">.*,\\1,p")
-    echo "$tags2"
-done
diff --git a/nixpkgs/pkgs/common-updater/scripts/list-archive-two-levels-versions b/nixpkgs/pkgs/common-updater/scripts/list-archive-two-levels-versions
new file mode 100755
index 000000000000..4263a9de3ca3
--- /dev/null
+++ b/nixpkgs/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,^<a href="([0-9]+\.[0-9]+)/">.*,\1,p')
+
+# print available versions
+for tag in $tags1; do
+    tags2=$(curl -sS "$archive/$tag/")
+    tags2=$(echo "$tags2" | sed -rne "s,^<a href=\"$pname-([0-9.]+)\\.[^0-9].*\">.*,\\1,p")
+    echo "$tags2"
+done
diff --git a/nixpkgs/pkgs/common-updater/scripts/list-git-tags b/nixpkgs/pkgs/common-updater/scripts/list-git-tags
index d137552cdd66..176e647eb2ea 100755
--- a/nixpkgs/pkgs/common-updater/scripts/list-git-tags
+++ b/nixpkgs/pkgs/common-updater/scripts/list-git-tags
@@ -2,29 +2,50 @@
 
 # lists all available tags from a git repository
 
-scriptName=list-git-tags # do not use the .wrapped name
-
-usage() {
-    echo "Usage: $scriptName <repository url> [<package name> [<debug file path>]]"
-}
-
-repo="$1" # git repository url
-pname="$2" # package name
-file="$3" # file for writing debugging information
+echo "# pname=$UPDATE_NIX_ATTR_PATH" > /tmp/test.txt
+
+url="" # git repository url
+pname="" # package name
+file="" # 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
+
+# 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 "$repo" ]; then
-    echo "$scriptName: Missing git repository url"
-    usage
-    exit 1
+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)