From edbec42e0a17489c949038843548e1d2df23fe76 Mon Sep 17 00:00:00 2001 From: emaryn Date: Mon, 21 Apr 2025 10:53:48 +0800 Subject: [PATCH] proxypin: add update script --- pkgs/by-name/pr/proxypin/package.nix | 2 ++ pkgs/by-name/pr/proxypin/update.sh | 34 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 pkgs/by-name/pr/proxypin/update.sh diff --git a/pkgs/by-name/pr/proxypin/package.nix b/pkgs/by-name/pr/proxypin/package.nix index a55ee485f38c..6ac95ab38472 100644 --- a/pkgs/by-name/pr/proxypin/package.nix +++ b/pkgs/by-name/pr/proxypin/package.nix @@ -38,6 +38,8 @@ flutter327.buildFlutterApplication rec { install -Dm0644 assets/icon.png $out/share/pixmaps/proxypin.png ''; + passthru.updateScript = ./update.sh; + meta = { description = "Capture HTTP(S) traffic software"; homepage = "https://github.com/wanghongenpin/proxypin"; diff --git a/pkgs/by-name/pr/proxypin/update.sh b/pkgs/by-name/pr/proxypin/update.sh new file mode 100755 index 000000000000..a9c584fe312d --- /dev/null +++ b/pkgs/by-name/pr/proxypin/update.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p yq nix bash coreutils nix-update common-updater-scripts ripgrep flutter + +set -eou pipefail + +PACKAGE_DIR="$(realpath "$(dirname "$0")")" +cd "$PACKAGE_DIR"/.. +while ! test -f flake.nix; do cd ..; done +NIXPKGS_DIR="$PWD" + +latestVersion=$( + list-git-tags --url=https://github.com/wanghongenpin/proxypin | + rg '^v(.*)' -r '$1' | + sort --version-sort | + tail -n1 +) + +currentVersion=$(nix-instantiate --eval -E "with import ./. {}; proxypin.version or (lib.getVersion proxypin)" | tr -d '"') + +if [[ "$currentVersion" == "$latestVersion" ]]; then + echo "package is up-to-date: $currentVersion" + exit 0 +fi + +nix-update --version=$latestVersion proxypin + +export HOME="$(mktemp -d)" +src="$(nix-build --no-link "$NIXPKGS_DIR" -A proxypin.src)" +TMPDIR="$(mktemp -d)" +cp --recursive --no-preserve=mode "$src"/* $TMPDIR +cd $TMPDIR +flutter pub get +yq . pubspec.lock >"$PACKAGE_DIR"/pubspec.lock.json +rm -rf $TMPDIR