pcsx2-bin: 2.1.17 -> 2.1.116, simplified updateScript (#337733)

This commit is contained in:
Sandro 2024-09-03 23:25:13 +02:00 committed by GitHub
commit 526463db24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 33 deletions

View File

@ -7,11 +7,11 @@
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "pcsx2-bin";
version = "2.1.17";
version = "2.1.116";
src = fetchurl {
url = "https://github.com/PCSX2/pcsx2/releases/download/v${finalAttrs.version}/pcsx2-v${finalAttrs.version}-macos-Qt.tar.xz";
hash = "sha256-WuxvMcGuCyTAc99JkUjG0qcV7SXWy9fmaZR0+8iGepQ=";
hash = "sha256-QKblXvqziToYOhSf7k9c/5J5NviRqo4NBLFCN1Q+0VA=";
};
nativeBuildInputs = [ makeWrapper ];

View File

@ -3,41 +3,18 @@
set -euo pipefail
ROOT="$(dirname "$(readlink -f "$0")")"
if [[ ! "$(basename "$ROOT")" == "pcsx2-bin" || ! -f "$ROOT/package.nix" ]]; then
echo "error: Not in the pcsx2-bin folder" >&2
exit 1
fi
cd "$(dirname "$0")" || exit 1
PACKAGE_NIX="$ROOT/package.nix"
# Grab latest version, ignoring "latest" and "preview" tags
LATEST_VER="$(curl --fail -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/PCSX2/pcsx2/releases" | jq -r '.[0].tag_name' | sed 's/^v//')"
CURRENT_VER="$(grep -oP 'version = "\K[^"]+' package.nix)"
# Grab latest (pre)release version
PCSX2_LATEST_VER="$(curl --fail -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/PCSX2/pcsx2/releases" | jq -r '.[0].tag_name' | sed 's/^v//')"
PCSX2_CURRENT_VER="$(grep -oP 'version = "\K[^"]+' "$PACKAGE_NIX")"
if [[ "$PCSX2_LATEST_VER" == "$PCSX2_CURRENT_VER" ]]; then
if [[ "$LATEST_VER" == "$CURRENT_VER" ]]; then
echo "pcsx2-bin is up-to-date"
exit 0
fi
get_hash() {
# $1: URL
nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "$1")"
}
HASH="$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "https://github.com/PCSX2/pcsx2/releases/download/v${LATEST_VER}/pcsx2-v${LATEST_VER}-macos-Qt.tar.xz")")"
replace_hash_in_file() {
# $1: file
# $2: new hash
sed -i "s#hash = \".*\"#hash = \"$2\"#g" "$1"
}
replace_version_in_file() {
# $1: file
# $2: new version
sed -i "s#version = \".*\";#version = \"$2\";#g" "$1"
}
PCSX2_DARWIN_HASH="$(get_hash "https://github.com/PCSX2/pcsx2/releases/download/v${PCSX2_LATEST_VER}/pcsx2-v${PCSX2_LATEST_VER}-macos-Qt.tar.xz")"
replace_hash_in_file "$PACKAGE_NIX" "$PCSX2_DARWIN_HASH"
replace_version_in_file "$PACKAGE_NIX" "$PCSX2_LATEST_VER"
sed -i "s#hash = \".*\"#hash = \"$HASH\"#g" package.nix
sed -i "s#version = \".*\";#version = \"$LATEST_VER\";#g" package.nix