diff options
| author | Lena <lena@omega> | 2026-01-01 00:00:00 +0000 |
|---|---|---|
| committer | Lena <lena@omega> | 2026-06-24 22:14:50 +0300 |
| commit | eb0c8951196c637e44daf3c0617b131b997d5d2c (patch) | |
| tree | 2f83b6a41cee745467e53fc401942b82cea286ea /scripts/update-server | |
| download | scrcpy-android-eb0c8951196c637e44daf3c0617b131b997d5d2c.tar.gz | |
scrcpy-android: mirror an Android device over wireless ADB0.1
Native Java app for Android 12+ that mirrors another Android
device over wireless ADB, forwarding video, audio, touch input,
and clipboard. Bundles a pinned scrcpy-server.jar and the
vendored libadb-android stack. Supports h264/h265/av1 video and
raw/opus audio with in-app codec selection. No NDK, no Kotlin.
Includes JVM unit tests and a Docker-based emulator e2e rig.
Diffstat (limited to 'scripts/update-server')
| -rwxr-xr-x | scripts/update-server | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/scripts/update-server b/scripts/update-server new file mode 100755 index 0000000..df12e3a --- /dev/null +++ b/scripts/update-server @@ -0,0 +1,64 @@ +#!/bin/sh +# Download a pinned scrcpy-server.jar release, verify SHA-256 against an +# in-script allow-list, and install it into app assets. Idempotent. +# +# Usage: +# scripts/update-server # use DEFAULT_VERSION below +# scripts/update-server 4.0 # use explicit version +# +# Bumping to a new release: +# 1. Run with the new version. The script will print the observed SHA-256 +# and exit non-zero if it is not in the allow-list. +# 2. Paste the printed line into the `case` below. +# 3. Update DEFAULT_VERSION. +# 4. Re-run. Commit the assets. + +set -eu + +DEFAULT_VERSION='4.0' +VERSION="${1:-$DEFAULT_VERSION}" + +ROOT="$(git rev-parse --show-toplevel)" +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 <<EOF +4.0 84924bd564a1eb6089c872c7521f968058977f91f5ff02514a8c74aff3210f3a +EOF +) + +want=$(printf '%s\n' "$EXPECTED" | awk -v v="$VERSION" '$1==v {print $2}') +if [ -z "$want" ]; then + echo "update-server: version $VERSION is not in the allow-list" >&2 + echo " to bless it, add this line to the EXPECTED block in this script:" >&2 + echo " $VERSION <sha256-of-the-downloaded-binary>" >&2 +fi + +mkdir -p "$ASSETS" +tmp=$(mktemp) +trap 'rm -f "$tmp"' EXIT + +echo "update-server: GET $URL" +curl -fsSL -o "$tmp" "$URL" + +got=$(sha256sum "$tmp" | awk '{print $1}') +echo "update-server: sha256 $got" + +if [ -z "$want" ]; then + echo "update-server: refusing to install unverified jar" >&2 + exit 1 +fi + +if [ "$got" != "$want" ]; then + echo "update-server: sha256 mismatch" >&2 + echo " want: $want" >&2 + echo " got: $got" >&2 + exit 1 +fi + +install -m 0644 "$tmp" "$ASSETS/scrcpy-server.jar" +printf '%s\n' "$VERSION" >"$ASSETS/scrcpy-server.version" +printf '%s\n' "$got" >"$ASSETS/scrcpy-server.sha256" + +echo "update-server: installed $ASSETS/scrcpy-server.jar v$VERSION" |