#!/usr/bin/env bash # Writes THIRD-PARTY-NOTICES.txt from the crate graph `didbot-pds` links. # # `--check` regenerates into a temporary file and diffs, which is what the # prek hook runs: a dependency change that moves the graph fails here until # the notices are regenerated and staged, the same shape as the plan register. set -euo pipefail root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" out="$root/THIRD-PARTY-NOTICES.txt" if ! cargo about --version >/dev/null 2>&1; then echo "gen-notices: cargo-about is the tool this reads the graph with." >&2 echo " cargo install --locked --features cli cargo-about" >&2 exit 1 fi generate() { cargo about generate \ --locked \ --manifest-path "$root/crates/didbot-serve/Cargo.toml" \ --features route53 \ --config "$root/about.toml" \ "$root/about.hbs" \ --output-file "$1" } if [ "${1-}" = "--check" ]; then tmp="$(mktemp)" trap 'rm -f "$tmp"' EXIT generate "$tmp" if ! diff -u "$out" "$tmp"; then echo "gen-notices: THIRD-PARTY-NOTICES.txt is behind the graph." >&2 echo " run scripts/gen-notices.sh and stage the result" >&2 exit 1 fi exit 0 fi generate "$out" echo "gen-notices: wrote $out"