aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-server-source
blob: 47d161a4f9686e03a127c8addcb5c0f2d280f5e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# Build and test the pinned scrcpy server, then compare its executable dex
# with the bundled upstream release.

set -eu

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
SCRCPY="$ROOT/vendor/scrcpy"
OFFICIAL="$ROOT/app/src/main/assets/scrcpy-server.jar"

"$ROOT/scripts/check-server"
built=$("$ROOT/scripts/build-server")

echo "check-server-source: unit, lint, checkstyle" >&2
"$SCRCPY/gradlew" -p "$SCRCPY" --no-daemon \
    :server:testDebugUnitTest :server:lint :server:checkstyle >&2

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT INT TERM
unzip -p "$OFFICIAL" classes.dex >"$tmp/official.dex"
unzip -p "$built" classes.dex >"$tmp/source.dex"
if ! cmp -s "$tmp/official.dex" "$tmp/source.dex"; then
    echo "check-server-source: source dex differs from upstream release" >&2
    sha256sum "$tmp/official.dex" "$tmp/source.dex" >&2
    exit 1
fi
echo "check-server-source: ok"