opentabletdriver: simpler update script

This commit is contained in:
Gutyina Gergő
2024-12-20 14:02:09 +01:00
parent a7de226c52
commit a040d1d122
+6 -21
View File
@@ -1,23 +1,8 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=./. -i bash -p curl gnused jq common-updater-scripts nixfmt-rfc-style
set -eo pipefail
#!nix-shell --pure -i bash -p bash nix nix-update git cacert
set -euo pipefail
verlte() {
printf '%s\n' "$1" "$2" | sort -C -V
}
new_version="$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} -s "https://api.github.com/repos/OpenTabletDriver/OpenTabletDriver/releases" |
jq -r 'map(select(.prerelease == false)) | .[0].tag_name' |
cut -c2-)"
old_version="$(nix --extra-experimental-features 'nix-command' eval --file default.nix opentabletdriver.version --raw)"
if verlte "$new_version" "$old_version"; then
echo "Already up to date!"
[[ "${1}" != "--force" ]] && exit 0
fi
update-source-version opentabletdriver "$new_version"
eval "$(nix-build -A opentabletdriver.fetch-deps --no-out-link)"
cd "$(dirname "${BASH_SOURCE[0]}")"
nixfmt deps.nix
prev_version=$(nix eval --raw -f. opentabletdriver.version)
nix-update opentabletdriver
[[ $(nix eval --raw -f. opentabletdriver.version) == "$prev_version" ]] ||
"$(nix-build . -A opentabletdriver.fetch-deps --no-out-link)"