c_josie_overlay

#!/usr/bin/env bash
# Deterministic pre-merge gate for josie-overlay packages.
#
#   scripts/overlay-gate.sh <category/pkg> [<category/pkg> ...]
#
# Runs, against the *local* tree:  pkgcheck static -> pkgcheck --net ->
# `emerge -pv` dependency resolution. Prints PASS/FAIL per step and exits
# non-zero if any failed, so a green run means the bump is safe to merge
# without review and only a red one needs attention.
#
# Requires network (--net checks distfile checksums/availability). `emerge`
# uses your real /etc/portage config, so a stale version-pinned
# accept_keywords entry for a fresh bump will (correctly) show as a failure.
set -uo pipefail

root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
[ $# -gt 0 ] || { echo "usage: $0 <category/pkg> [...]" >&2; exit 2; }
cd "$root"

rc=0
step() { # step <label> <cmd...>
	local label=$1; shift
	printf '\n== %s ==\n' "$label"
	if "$@"; then printf 'PASS: %s\n' "$label"; else printf 'FAIL: %s\n' "$label"; rc=1; fi
}

step "pkgcheck (static)" pkgcheck scan "$@"
step "pkgcheck (--net)" pkgcheck scan --net "$@"

export PORTDIR_OVERLAY="$root"
for pkg in "$@"; do
	step "emerge -pv $pkg" emerge -pv "$pkg"
done

printf '\n== gate %s ==\n' "$([ $rc -eq 0 ] && echo PASS || echo FAIL)"
exit $rc