about summary refs log tree commit diff
path: root/pkgs/applications/emulators/yuzu/early-access/update.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/emulators/yuzu/early-access/update.sh')
-rwxr-xr-xpkgs/applications/emulators/yuzu/early-access/update.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/pkgs/applications/emulators/yuzu/early-access/update.sh b/pkgs/applications/emulators/yuzu/early-access/update.sh
new file mode 100755
index 0000000000000..0e98185bbf9a2
--- /dev/null
+++ b/pkgs/applications/emulators/yuzu/early-access/update.sh
@@ -0,0 +1,48 @@
+#! /usr/bin/env nix-shell
+#! nix-shell -i bash -p nix nix-prefetch-git gnutar curl jq unzip
+
+set -euo pipefail
+
+cd "$(dirname "$(readlink -f "$0")")"
+
+log() {
+    tput bold
+    echo "#" "$@"
+    tput sgr0
+}
+
+oldVersion="$(nix --experimental-features nix-command eval -f sources.nix --raw version)"
+newVersion="$(curl "https://api.github.com/repos/pineappleEA/pineapple-src/releases?per_page=1" | jq -r '.[0].tag_name' | cut -d"-" -f2)"
+
+if [ "$oldVersion" == "$newVersion" ]; then
+    log "Already up to date"
+    exit 0
+fi
+
+fetched="$(nix-prefetch-url --unpack --print-path "https://github.com/pineappleEA/pineapple-src/releases/download/EA-${newVersion}/Windows-Yuzu-EA-${newVersion}.zip")"
+
+eaDistHash="$(echo "${fetched}" | head -n1)"
+eaDist="$(echo "${fetched}" | tail -n1)"
+
+eaDistUnpacked="$(mktemp -d)"
+trap 'rm -rf "$eaDistUnpacked"' EXIT
+
+log "Unpacking dist..."
+tar xf "$eaDist"/*.tar.xz --directory="$eaDistUnpacked" --strip-components=1
+
+log "Rehydrating..."
+eaFullHash="$(nix-prefetch-git --fetch-submodules "$eaDistUnpacked" | jq -r '.sha256')"
+
+cat >sources.nix <<EOF
+# Generated by ./update.sh - do not update manually!
+# Last updated: $(date +%F)
+{
+  version = "$newVersion";
+  distHash = "sha256:$eaDistHash";
+  fullHash = "sha256:$eaFullHash";
+}
+EOF
+
+if [ "${COMMIT:-0}" == "1" ]; then
+    git commit -m "yuzu-ea: ${oldVersion} -> ${newVersion}" ./sources.nix
+fi