summary refs log tree commit diff
path: root/pkgs/applications/blockchains/nbxplorer/util/update-common.sh
diff options
context:
space:
mode:
authorCalvin Kim <calvin@kcalvinalvin.info>2020-08-11 02:49:20 +0900
committerErik Arvstedt <erik.arvstedt@gmail.com>2020-09-12 15:31:23 +0200
commit2724f7be543ebc57a01f7fc4fa42efb0a13e24cc (patch)
treeb58e8f1b15a3e23a1b6eacb023a7b09733fb5967 /pkgs/applications/blockchains/nbxplorer/util/update-common.sh
parent44cb86f0d847f0b7b06f0d0ca10563c562c6de89 (diff)
downloadnixpkgs-2724f7be543ebc57a01f7fc4fa42efb0a13e24cc.tar
nixpkgs-2724f7be543ebc57a01f7fc4fa42efb0a13e24cc.tar.gz
nixpkgs-2724f7be543ebc57a01f7fc4fa42efb0a13e24cc.tar.bz2
nixpkgs-2724f7be543ebc57a01f7fc4fa42efb0a13e24cc.tar.lz
nixpkgs-2724f7be543ebc57a01f7fc4fa42efb0a13e24cc.tar.xz
nixpkgs-2724f7be543ebc57a01f7fc4fa42efb0a13e24cc.tar.zst
nixpkgs-2724f7be543ebc57a01f7fc4fa42efb0a13e24cc.zip
nbxplorer: init at 2.1.42
Diffstat (limited to 'pkgs/applications/blockchains/nbxplorer/util/update-common.sh')
-rwxr-xr-xpkgs/applications/blockchains/nbxplorer/util/update-common.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/pkgs/applications/blockchains/nbxplorer/util/update-common.sh b/pkgs/applications/blockchains/nbxplorer/util/update-common.sh
new file mode 100755
index 00000000000..c69168ccbbb
--- /dev/null
+++ b/pkgs/applications/blockchains/nbxplorer/util/update-common.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p coreutils curl jq common-updater-scripts dotnet-sdk_3
+set -euo pipefail
+
+# This script uses the following env vars:
+# getVersionFromTags
+# onlyCreateDeps
+
+pkgName=$1
+depsFile=$2
+
+: ${getVersionFromTags:=}
+: ${onlyCreateDeps:=}
+
+scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd)
+nixpkgs=$(realpath "$scriptDir"/../../../../..)
+
+evalNixpkgs() {
+  nix eval --raw "(with import \"$nixpkgs\" {}; $1)"
+}
+
+getRepo() {
+  url=$(evalNixpkgs $pkgName.src.meta.homepage)
+  echo $(basename $(dirname $url))/$(basename $url)
+}
+
+getLatestVersionTag() {
+  "$nixpkgs"/pkgs/common-updater/scripts/list-git-tags https://github.com/$(getRepo) 2>/dev/null \
+    | sort -V | tail -1 | sed 's|^v||'
+}
+
+if [[ ! $onlyCreateDeps ]]; then
+  oldVersion=$(evalNixpkgs "$pkgName.version")
+  if [[ $getVersionFromTags ]]; then
+    newVersion=$(getLatestVersionTag)
+  else
+    newVersion=$(curl -s "https://api.github.com/repos/$(getRepo)/releases" | jq -r '.[0].name')
+  fi
+
+  if [[ $newVersion == $oldVersion ]]; then
+    echo "nixpkgs already has the latest version $newVersion"
+    echo "Run this script with env var onlyCreateDeps=1 to recreate "$(basename "$depsFile")
+    exit 0
+  else
+    echo "Updating $pkgName: $oldVersion -> $newVersion"
+    (cd "$nixpkgs" && update-source-version "$pkgName" "$newVersion")
+  fi
+fi
+
+storeSrc="$(nix-build "$nixpkgs" -A $pkgName.src --no-out-link)"
+. "$scriptDir"/create-deps.sh "$storeSrc" "$depsFile"