From 827653aa291e37ae63c0cfa1eee4fbaa20cea122 Mon Sep 17 00:00:00 2001 From: Lena Date: Sat, 1 Aug 2026 00:00:00 +0000 Subject: build: pin and verify release inputs --- scripts/update-server | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'scripts/update-server') diff --git a/scripts/update-server b/scripts/update-server index df12e3a..337ef67 100755 --- a/scripts/update-server +++ b/scripts/update-server @@ -4,7 +4,7 @@ # # Usage: # scripts/update-server # use DEFAULT_VERSION below -# scripts/update-server 4.0 # use explicit version +# scripts/update-server 4.1 # use explicit version # # Bumping to a new release: # 1. Run with the new version. The script will print the observed SHA-256 @@ -15,16 +15,22 @@ set -eu -DEFAULT_VERSION='4.0' +DEFAULT_VERSION='4.1' VERSION="${1:-$DEFAULT_VERSION}" -ROOT="$(git rev-parse --show-toplevel)" +if ! printf '%s\n' "$VERSION" \ + | awk '/^[0-9]+([.][0-9]+)*$/ { ok = 1 } END { exit !ok }'; then + echo "update-server: invalid version: $VERSION" >&2 + exit 2 +fi + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" ASSETS="$ROOT/app/src/main/assets" URL="https://github.com/Genymobile/scrcpy/releases/download/v$VERSION/scrcpy-server-v$VERSION" # Known-good SHA-256 sums. Keep one line per blessed version. EXPECTED=$(cat <" >&2 fi +if [ -f "$ASSETS/scrcpy-server.jar" ] \ + && [ "$(cat "$ASSETS/scrcpy-server.version" 2>/dev/null || true)" = "$VERSION" ] \ + && [ "$(sha256sum "$ASSETS/scrcpy-server.jar" | awk '{print $1}')" = "$want" ]; then + printf '%s\n' "$want" >"$ASSETS/scrcpy-server.sha256" + echo "update-server: already installed $ASSETS/scrcpy-server.jar v$VERSION" + exit 0 +fi + mkdir -p "$ASSETS" tmp=$(mktemp) trap 'rm -f "$tmp"' EXIT -- cgit v1.2.3