From 873099a6a1af7b57d825f019d0e0d79f825ace00 Mon Sep 17 00:00:00 2001 From: aucub <78630225+aucub@users.noreply.github.com> Date: Sat, 28 Dec 2024 10:02:44 +0800 Subject: [PATCH] pilipalax: add update script --- pkgs/by-name/pi/pilipalax/package.nix | 6 ++++-- pkgs/by-name/pi/pilipalax/update.sh | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100755 pkgs/by-name/pi/pilipalax/update.sh diff --git a/pkgs/by-name/pi/pilipalax/package.nix b/pkgs/by-name/pi/pilipalax/package.nix index 3b0b43d2ee758..1dbf8ccd79f8c 100644 --- a/pkgs/by-name/pi/pilipalax/package.nix +++ b/pkgs/by-name/pi/pilipalax/package.nix @@ -39,12 +39,12 @@ }: flutter324.buildFlutterApplication rec { pname = "pilipalax"; - version = "1.0.22-beta.12+174"; + version = "1.0.22-beta.12"; src = fetchFromGitHub { owner = "orz12"; repo = "PiliPalaX"; - tag = version; + tag = "${version}+174"; hash = "sha256-Qjqyg9y5R70hODGfVClS505dJwexL0BbUm6lXSHzhJs="; }; @@ -113,6 +113,8 @@ flutter324.buildFlutterApplication rec { --prefix LD_LIBRARY_PATH : "$out/app/${pname}/lib" ''; + passthru.updateScript = ./update.sh; + meta = { description = "Third-party BiliBili client developed with Flutter"; homepage = "https://github.com/orz12/PiliPalaX"; diff --git a/pkgs/by-name/pi/pilipalax/update.sh b/pkgs/by-name/pi/pilipalax/update.sh new file mode 100755 index 0000000000000..8cd134d203d0f --- /dev/null +++ b/pkgs/by-name/pi/pilipalax/update.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env nix-shell +#!nix-shell -I nixpkgs=./. -i bash -p curl jq yq nixVersions.latest bash coreutils common-updater-scripts + +set -eou pipefail + +ROOT="$(dirname "$(readlink -f "$0")")" + +latestTag=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/orz12/PiliPalaX/releases/latest | jq --raw-output .tag_name) +latestVersion=$(echo "$latestTag" | awk -F'+' '{print $1}') +RunNumber=$(echo "$latestTag" | grep -o '[^+]*$') + +currentVersion=$(nix-instantiate --eval -E "with import ./. {}; pilipalax.version or (lib.getVersion pilipalax)" | tr -d '"') + +if [[ "$currentVersion" == "$latestVersion" ]]; then + echo "package is up-to-date: $currentVersion" + exit 0 +fi + +sed -i "s/\(tag = \"\${version}+\)[0-9]\+/\1${RunNumber}/" "$ROOT/package.nix" + +hash=$(nix hash convert --hash-algo sha256 --to sri $(nix-prefetch-url --unpack "https://github.com/orz12/PiliPalaX/archive/refs/tags/${latestTag}.tar.gz")) +update-source-version pilipalax $latestVersion $hash + +curl https://raw.githubusercontent.com/orz12/PiliPalaX/${latestTag}/pubspec.lock | yq . >$ROOT/pubspec.lock.json