boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

input-manifest.sh (1310B)


      1 #!/bin/sh
      2 ## input-manifest.sh — hash a sealed boot2 src/ + boot/ input pair.
      3 ##
      4 ## Usage: tools/release/input-manifest.sh <src-dir> <boot-dir> <output>
      5 ##
      6 ## Paths in the output are rooted at src/ and boot/ regardless of where
      7 ## the two input directories live. This lets release.sh compare a freshly
      8 ## regenerated checkout tree with the manifest bundled in a release.
      9 
     10 set -eu
     11 
     12 SRC_DIR=${1:-}
     13 BOOT_DIR=${2:-}
     14 OUTPUT=${3:-}
     15 [ -d "$SRC_DIR" ] || { echo "input-manifest: missing src dir: $SRC_DIR" >&2; exit 2; }
     16 [ -d "$BOOT_DIR" ] || { echo "input-manifest: missing boot dir: $BOOT_DIR" >&2; exit 2; }
     17 [ -n "$OUTPUT" ] || { echo "usage: $0 <src-dir> <boot-dir> <output>" >&2; exit 2; }
     18 
     19 if command -v sha256sum >/dev/null 2>&1; then
     20     sha256() { sha256sum "$1" | awk '{print $1}'; }
     21 else
     22     sha256() { shasum -a 256 "$1" | awk '{print $1}'; }
     23 fi
     24 
     25 emit_tree() {
     26     _prefix=$1
     27     _dir=$2
     28     (
     29         cd "$_dir"
     30         find . -type f | LC_ALL=C sort | while read -r _path; do
     31             _rel=${_path#./}
     32             _hash=$(sha256 "$_path")
     33             printf '%s  %s/%s\n' "$_hash" "$_prefix" "$_rel"
     34         done
     35     )
     36 }
     37 
     38 # LC_ALL=C lexical order puts boot/ before src/, matching the bundled
     39 # INPUT_MANIFEST.txt contract.
     40 {
     41     emit_tree boot "$BOOT_DIR"
     42     emit_tree src "$SRC_DIR"
     43 } > "$OUTPUT"