montana/_internal-private/MontanaOS-archived-20260521/scripts/sync-grapheneos.sh
2026-05-26 21:14:51 +03:00

39 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
LOCK_FILE="${MONTANAOS_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}/MONTANAOS_VERSIONS.lock"
TEMPLATE_FILE="${MONTANAOS_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}/MONTANAOS_VERSIONS.template"
if [[ ! -f "$LOCK_FILE" ]]; then
echo "ERROR: $LOCK_FILE not found."
echo "Phase 0 has $TEMPLATE_FILE only. Phase 1 closes by writing the lock file"
echo "with concrete commit SHAs. Cannot sync deterministically before Phase 1."
exit 1
fi
GRAPHENE_BRANCH="$(awk -F'"' '/^grapheneos_branch/ {print $2}' "$LOCK_FILE")"
GRAPHENE_COMMIT="$(awk -F'"' '/^grapheneos_commit/ {print $2}' "$LOCK_FILE")"
WORK_DIR="${MONTANAOS_WORK:-$HOME/montanaos-build}"
MANIFEST_URL="${MANIFEST_URL:-https://github.com/GrapheneOS/platform_manifest.git}"
if [[ -z "$GRAPHENE_BRANCH" || -z "$GRAPHENE_COMMIT" ]]; then
echo "ERROR: lock file missing grapheneos_branch or grapheneos_commit"
exit 1
fi
mkdir -p "$WORK_DIR/grapheneos"
cd "$WORK_DIR/grapheneos"
if [[ ! -d .repo ]]; then
repo init -u "$MANIFEST_URL" -b "$GRAPHENE_BRANCH"
fi
repo sync -j8 --no-clone-bundle --no-tags --current-branch
echo
echo "GrapheneOS source synced to $WORK_DIR/grapheneos"
echo "Branch: $GRAPHENE_BRANCH"
echo "Pinned commit: $GRAPHENE_COMMIT"
echo
echo "Next step: ./scripts/apply-patches.sh"