Hermetic Build Environment Check

Assert that reproducibility-critical environment variables are pinned before a build, failing fast when they are not.

BashConfig Management

Code

snippet
#!/usr/bin/env bash
set -euo pipefail

# 可复现构建依赖这些变量被显式固定,而不是继承自当前 shell。
required=(SOURCE_DATE_EPOCH TZ LC_ALL LANG)

missing=()
for name in "${required[@]}"; do
  if [[ -z "${!name:-}" ]]; then
    missing+=("$name")
  fi
done

if (( ${#missing[@]} > 0 )); then
  echo "hermetic check failed; unset: ${missing[*]}" >&2
  exit 1
fi

# UMASK 影响嵌入产物的文件权限,必须是固定值。
if [[ "$(umask)" != "0022" ]]; then
  echo "hermetic check failed; umask is $(umask), expected 0022" >&2
  exit 1
fi

echo "environment pinned for reproducible build"