about summary refs log tree commit diff
path: root/pkgs/common-updater/generic-updater.nix
diff options
context:
space:
mode:
authorJosé Romildo Malaquias <malaquias@gmail.com>2022-09-30 09:19:21 -0300
committerGitHub <noreply@github.com>2022-09-30 09:19:21 -0300
commite78c23cf5b4e3b5534b480ff1d6a534620d6e395 (patch)
tree1172549cbf3dc68c419f2d8dedad6ce078094f14 /pkgs/common-updater/generic-updater.nix
parentfee5e0d5ef59e801f2441374ab5ea4d1cfc0c005 (diff)
parent3a36ccc07549f55bec1f679a4e3b98235005e456 (diff)
downloadnixlib-e78c23cf5b4e3b5534b480ff1d6a534620d6e395.tar
nixlib-e78c23cf5b4e3b5534b480ff1d6a534620d6e395.tar.gz
nixlib-e78c23cf5b4e3b5534b480ff1d6a534620d6e395.tar.bz2
nixlib-e78c23cf5b4e3b5534b480ff1d6a534620d6e395.tar.lz
nixlib-e78c23cf5b4e3b5534b480ff1d6a534620d6e395.tar.xz
nixlib-e78c23cf5b4e3b5534b480ff1d6a534620d6e395.tar.zst
nixlib-e78c23cf5b4e3b5534b480ff1d6a534620d6e395.zip
Merge pull request #193248 from romildo/upd.generic-updater
generic-updater: more flexible with name, pname, version and attr path, and cleanups
Diffstat (limited to 'pkgs/common-updater/generic-updater.nix')
-rw-r--r--pkgs/common-updater/generic-updater.nix41
1 files changed, 25 insertions, 16 deletions
diff --git a/pkgs/common-updater/generic-updater.nix b/pkgs/common-updater/generic-updater.nix
index 7a919ff5845e..04adcf563814 100644
--- a/pkgs/common-updater/generic-updater.nix
+++ b/pkgs/common-updater/generic-updater.nix
@@ -1,8 +1,9 @@
 { stdenv, writeScript, coreutils, gnugrep, gnused, common-updater-scripts, nix }:
 
-{ pname
-, version
-, attrPath ? pname
+{ name ? null
+, pname ? null
+, version ? null
+, attrPath ? null
 , versionLister
 , ignoredVersions ? ""
 , rev-prefix ? ""
@@ -15,22 +16,28 @@ let
   fileForGitCommands = "update-git-commits.txt";
 
   # shell script to update package
-  updateScript = writeScript "update-script.sh" ''
+  updateScript = writeScript "generic-update-script.sh" ''
     #! ${stdenv.shell}
     set -o errexit
     set -x
 
-    pname="$1"
-    version="$2"
-    attr_path="$3"
-    version_lister="$4"
-    ignored_versions="$5"
-    rev_prefix="$6"
-    odd_unstable="$7"
-    patchlevel_unstable="$8"
+    name="$1"
+    pname="$2"
+    version="$3"
+    attr_path="$4"
+    version_lister="$5"
+    ignored_versions="$6"
+    rev_prefix="$7"
+    odd_unstable="$8"
+    patchlevel_unstable="$9"
+
+    [[ -n "$name" ]] || name="$UPDATE_NIX_NAME"
+    [[ -n "$pname" ]] || pname="$UPDATE_NIX_PNAME"
+    [[ -n "$version" ]] || version="$UPDATE_NIX_OLD_VERSION"
+    [[ -n "$attr_path" ]] || attr_path="$UPDATE_NIX_ATTR_PATH"
 
     # print header
-    echo "# $pname-$version" >> ${fileForGitCommands}
+    echo "# $name" >> ${fileForGitCommands}
 
     function version_is_ignored() {
       local tag="$1"
@@ -55,7 +62,7 @@ let
       return 1
     }
 
-    tags=$($version_lister --pname=${pname} --file="${fileForGitCommands}") || exit 1
+    tags=$($version_lister --pname=$pname --attr-path=$attr_path --file="${fileForGitCommands}") || exit 1
 
     # print available tags
     for tag in $tags; do
@@ -104,5 +111,7 @@ let
     echo "" >> ${fileForGitCommands}
   '';
 
-in
-[ updateScript pname version attrPath versionLister ignoredVersions rev-prefix odd-unstable patchlevel-unstable ]
+in {
+  name = "generic-update-script";
+  command = [ updateScript name pname version attrPath versionLister ignoredVersions rev-prefix odd-unstable patchlevel-unstable ];
+}