#!/bin/sh set -eu ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd) artifact_dir=${1:-} build_command=${2:-the matching Android build script} if [ -z "$artifact_dir" ]; then echo "usage: $0 ARTIFACT_DIR [BUILD_COMMAND]" >&2 exit 2 fi case "$artifact_dir" in /*) ;; *) artifact_dir="$ROOT/$artifact_dir" ;; esac fingerprint_file="$artifact_dir/source-fingerprint.sha256" if [ ! -s "$fingerprint_file" ]; then echo "Android artifacts do not record their source fingerprint: $fingerprint_file" >&2 echo "Run $build_command before using these artifacts." >&2 exit 1 fi expected=$(tr -d '\r\n' <"$fingerprint_file") actual=$("$ROOT/scripts/android-source-fingerprint.sh") if ! printf '%s\n' "$expected" | grep -Eq '^[0-9a-f]{64}$'; then echo "Android artifact source fingerprint is malformed." >&2 exit 1 fi if [ "$expected" != "$actual" ]; then echo "Android artifacts are stale relative to the current Android source." >&2 echo "Run $build_command before smoke or cross-client testing." >&2 exit 1 fi printf 'Verified Android artifact source fingerprint: %s\n' "$actual"