|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 5 | +TMP_DIR="$(mktemp -d)" |
| 6 | +cleanup() { |
| 7 | + rm -rf "${TMP_DIR}" |
| 8 | +} |
| 9 | +trap cleanup EXIT |
| 10 | + |
| 11 | +usage() { |
| 12 | + echo "Usage: $0 [path-to-tarball]" >&2 |
| 13 | +} |
| 14 | + |
| 15 | +if [[ $# -gt 1 ]]; then |
| 16 | + usage |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
| 20 | +if [[ $# -eq 1 ]]; then |
| 21 | + TARBALL="$1" |
| 22 | +else |
| 23 | + TARBALL_NAME="$(cd "${ROOT_DIR}" && npm pack --silent --ignore-scripts --pack-destination "${TMP_DIR}" | tail -n1)" |
| 24 | + TARBALL="${TMP_DIR}/${TARBALL_NAME}" |
| 25 | +fi |
| 26 | + |
| 27 | +if [[ ! -f "${TARBALL}" ]]; then |
| 28 | + echo "Tarball not found: ${TARBALL}" >&2 |
| 29 | + exit 1 |
| 30 | +fi |
| 31 | + |
| 32 | +REQUIRED_PATHS=$(cat <<'EOF' |
| 33 | +package/app.plugin.js |
| 34 | +package/FileHash.podspec |
| 35 | +package/third_party/xxhash/xxhash.c |
| 36 | +package/third_party/xxhash/xxhash.h |
| 37 | +package/third_party/blake3/c/blake3.c |
| 38 | +package/third_party/blake3/c/blake3.h |
| 39 | +package/third_party/blake3/c/blake3_dispatch.c |
| 40 | +package/third_party/blake3/c/blake3_impl.h |
| 41 | +package/third_party/blake3/c/blake3_portable.c |
| 42 | +package/third_party/blake3/c/blake3_neon.c |
| 43 | +package/third_party/zig-files-hash/build.zig.zon |
| 44 | +package/third_party/zig-files-hash/src/zig_files_hash_c_api.h |
| 45 | +package/third_party/zig-files-hash-prebuilt/android/arm64-v8a/libzig_files_hash.a |
| 46 | +package/third_party/zig-files-hash-prebuilt/android/armeabi-v7a/libzig_files_hash.a |
| 47 | +package/third_party/zig-files-hash-prebuilt/android/x86/libzig_files_hash.a |
| 48 | +package/third_party/zig-files-hash-prebuilt/android/x86_64/libzig_files_hash.a |
| 49 | +package/third_party/zig-files-hash-prebuilt/ios/ZigFilesHash.xcframework/Info.plist |
| 50 | +package/third_party/zig-files-hash-prebuilt/ios/ZigFilesHash.xcframework/ios-arm64/libzig_files_hash.a |
| 51 | +package/third_party/zig-files-hash-prebuilt/ios/ZigFilesHash.xcframework/ios-arm64_x86_64-simulator/libzig_files_hash.a |
| 52 | +EOF |
| 53 | +) |
| 54 | + |
| 55 | +CONTENTS_FILE="${TMP_DIR}/tar-contents.txt" |
| 56 | +tar -tf "${TARBALL}" > "${CONTENTS_FILE}" |
| 57 | + |
| 58 | +missing=() |
| 59 | +while IFS= read -r path; do |
| 60 | + [[ -n "${path}" ]] || continue |
| 61 | + if ! grep -Fxq "${path}" "${CONTENTS_FILE}"; then |
| 62 | + missing+=("${path}") |
| 63 | + fi |
| 64 | +done <<EOF |
| 65 | +${REQUIRED_PATHS} |
| 66 | +EOF |
| 67 | + |
| 68 | +if (( ${#missing[@]} > 0 )); then |
| 69 | + echo "Packaged tarball is missing required artifacts:" >&2 |
| 70 | + printf ' - %s |
| 71 | +' "${missing[@]}" >&2 |
| 72 | + exit 1 |
| 73 | +fi |
| 74 | + |
| 75 | +echo "Verified packaged artifacts in: ${TARBALL}" |
0 commit comments