pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / by-name / ge / geoserver / update.sh
blobe3b2f25fbaa47ad38ec5b5d5e367b930e7992efa
1 #!/usr/bin/env nix-shell
2 #!nix-shell -I ./. -i bash -p common-updater-scripts jq
4 set -eEuo pipefail
5 test ${DEBUG:-0} -eq 1 && set -x
7 # Current version.
8 LATEST_NIXPKGS_VERSION=$(nix eval --raw .#geoserver.version 2>/dev/null)
9 UPDATE_NIX_OLD_VERSION=${UPDATE_NIX_OLD_VERSION:-$LATEST_NIXPKGS_VERSION}
11 # Maybe future version.
12 LATEST_GITHUB_VERSION=$(curl -s "https://api.github.com/repos/geoserver/geoserver/releases/latest" | jq -r '.tag_name')
13 UPDATE_NIX_NEW_VERSION=${UPDATE_NIX_NEW_VERSION:-$LATEST_GITHUB_VERSION}
15 SMALLEST_VERSION=$(printf "$UPDATE_NIX_OLD_VERSION\n$UPDATE_NIX_NEW_VERSION" | sort --version-sort | head -n 1)
17 if [[ "$SMALLEST_VERSION" == "$UPDATE_NIX_NEW_VERSION" ]]; then
18 echo "geoserver is up-to-date: $SMALLEST_VERSION"
19 exit 0
22 echo "Updating geoserver..."
23 update-source-version geoserver "$UPDATE_NIX_NEW_VERSION"
25 cd "$(dirname "$(readlink -f "$0")")"
27 EXT_NAMES=($(grep -o -E "hash = .*?; # .*$" ./extensions.nix | sed 's/.* # //' | sort))
29 if [[ $# -gt 0 ]] ; then
30 EXT_NAMES=(${@:1})
33 for EXT_NAME in "${EXT_NAMES[@]}" ; do
34 echo "Updating extension $EXT_NAME..."
35 URL="mirror://sourceforge/geoserver/GeoServer/${UPDATE_NIX_NEW_VERSION}/extensions/geoserver-${UPDATE_NIX_NEW_VERSION}-${EXT_NAME}-plugin.zip"
36 HASH=$(nix-hash --to-sri --type sha256 $(nix-prefetch-url --unpack "$URL"))
37 sed -i "s@version = \".*\"; # $EXT_NAME@version = \"$UPDATE_NIX_NEW_VERSION\"; # $EXT_NAME@" ./extensions.nix
38 sed -i "s@hash = \".*\"; # $EXT_NAME@hash = \"$HASH\"; # $EXT_NAME@" ./extensions.nix
39 done
41 cd -