Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / emulators / yuzu / update.sh
blobad34bfee3d6b333fbec176dcb2767a88e1abfa4b
1 #! /usr/bin/env nix-shell
2 #! nix-shell -i bash -p nix nix-prefetch-git gnutar curl jq unzip
4 set -euo pipefail
6 cd "$(dirname "$(readlink -f "$0")")"
8 log() {
9 tput bold
10 echo "#" "$@"
11 tput sgr0
14 alias curl='curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"}'
16 log "Updating compatibility list..."
17 compatListRev="$(curl "https://api.github.com/repos/flathub/org.yuzu_emu.yuzu/commits/master" | jq -r '.sha')"
19 log "Downloading rev: ${compatListRev}"
20 compatListHash="$(nix-prefetch-url "https://raw.githubusercontent.com/flathub/org.yuzu_emu.yuzu/${compatListRev}/compatibility_list.json")"
22 log "Updating mainline..."
23 mainlineVersion="$(curl "https://api.github.com/repos/yuzu-emu/yuzu-mainline/releases?per_page=1" | jq -r '.[0].name' | cut -d" " -f2)"
25 log "Downloading version: ${mainlineVersion}"
26 mainlineHash="$(nix-prefetch-git --fetch-submodules --rev "mainline-0-${mainlineVersion}" "https://github.com/yuzu-emu/yuzu-mainline" | jq -r '.sha256')"
28 log "Updating early access..."
29 eaVersion="$(curl "https://api.github.com/repos/pineappleEA/pineapple-src/releases?per_page=1" | jq -r '.[0].tag_name' | cut -d"-" -f2)"
31 log "Downloading dist version: ${eaVersion}"
32 fetched="$(nix-prefetch-url --unpack --print-path "https://github.com/pineappleEA/pineapple-src/releases/download/EA-${eaVersion}/Windows-Yuzu-EA-${eaVersion}.zip")"
34 eaDistHash="$(echo "${fetched}" | head -n1)"
35 eaDist="$(echo "${fetched}" | tail -n1)"
37 eaDistUnpacked="$(mktemp -d)"
38 trap 'rm -rf "$eaDistUnpacked"' EXIT
40 log "Unpacking dist..."
41 tar xf "$eaDist"/*.tar.xz --directory="$eaDistUnpacked" --strip-components=1
43 log "Rehydrating..."
44 eaFullHash="$(nix-prefetch-git --fetch-submodules "$eaDistUnpacked" | jq -r '.sha256')"
46 cat >sources.nix <<EOF
47 # Generated by ./update.sh - do not update manually!
48 # Last updated: $(date +%F)
50 compatList = {
51 rev = "$compatListRev";
52 hash = "sha256:$compatListHash";
55 mainline = {
56 version = "$mainlineVersion";
57 hash = "sha256:$mainlineHash";
60 ea = {
61 version = "$eaVersion";
62 distHash = "sha256:$eaDistHash";
63 fullHash = "sha256:$eaFullHash";
66 EOF