summary refs log tree commit diff
path: root/pkgs/common-updater/scripts
diff options
context:
space:
mode:
authorJosé Romildo <malaquias@gmail.com>2022-02-20 22:11:49 -0300
committerJosé Romildo <malaquias@gmail.com>2022-02-21 13:01:49 -0300
commitba59355e8105035382b2f4056a97b1ffcd1bb70a (patch)
treeec5ac6cc16144a581e5913ce032320c2d3d2a4bf /pkgs/common-updater/scripts
parent60966b5a6ebfb22b16c1400b28eb0f668a0412d3 (diff)
downloadnixpkgs-ba59355e8105035382b2f4056a97b1ffcd1bb70a.tar
nixpkgs-ba59355e8105035382b2f4056a97b1ffcd1bb70a.tar.gz
nixpkgs-ba59355e8105035382b2f4056a97b1ffcd1bb70a.tar.bz2
nixpkgs-ba59355e8105035382b2f4056a97b1ffcd1bb70a.tar.lz
nixpkgs-ba59355e8105035382b2f4056a97b1ffcd1bb70a.tar.xz
nixpkgs-ba59355e8105035382b2f4056a97b1ffcd1bb70a.tar.zst
nixpkgs-ba59355e8105035382b2f4056a97b1ffcd1bb70a.zip
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'
Diffstat (limited to 'pkgs/common-updater/scripts')
-rwxr-xr-xpkgs/common-updater/scripts/list-archive-two-level-versions29
-rwxr-xr-xpkgs/common-updater/scripts/list-git-tags53
2 files changed, 58 insertions, 24 deletions
diff --git a/pkgs/common-updater/scripts/list-archive-two-level-versions b/pkgs/common-updater/scripts/list-archive-two-level-versions
index 36a051e97c9..ae29d533fc3 100755
--- a/pkgs/common-updater/scripts/list-archive-two-level-versions
+++ b/pkgs/common-updater/scripts/list-archive-two-level-versions
@@ -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
diff --git a/pkgs/common-updater/scripts/list-git-tags b/pkgs/common-updater/scripts/list-git-tags
index d137552cdd6..176e647eb2e 100755
--- a/pkgs/common-updater/scripts/list-git-tags
+++ b/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)