infra(docker-env2)+infra(docker): init:true + secrets posture parity for env2; regen-proto EXIT trap (arch-review 2026-08-19 P8-2 + P8-3 + P8-4)
This commit is contained in:
+20
-8
@@ -50,12 +50,25 @@ if [[ ! -f "$CSPROJ" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Backup so we can always restore the comment state on failure. Leaving the
|
||||
# csproj with an active Protobuf item is the one outcome that breaks Docker, so
|
||||
# every exit path restores this copy.
|
||||
# Backup so we can always restore the comment state, however this script ends.
|
||||
# Leaving the csproj with an active Protobuf item is the one outcome that breaks
|
||||
# Docker, so every exit path restores this copy — success, a failed `dotnet
|
||||
# build` (ERR), or Ctrl-C (INT/TERM) mid-build. An EXIT trap covers all of
|
||||
# those (bash runs it on any shell termination, signals included), and the
|
||||
# guard on $BACKUP's existence makes it idempotent: the normal success path
|
||||
# below restores explicitly for prompt feedback, so by the time the trap fires
|
||||
# on a clean exit $BACKUP is already gone and it's a no-op instead of a second
|
||||
# restore/rm.
|
||||
BACKUP="$(mktemp)"
|
||||
cp "$CSPROJ" "$BACKUP"
|
||||
trap 'cp "$BACKUP" "$CSPROJ"; rm -f "$BACKUP"; echo "Restored csproj from backup."' ERR
|
||||
restore_csproj() {
|
||||
if [[ -f "$BACKUP" ]]; then
|
||||
cp "$BACKUP" "$CSPROJ"
|
||||
rm -f "$BACKUP"
|
||||
echo "Restored csproj from backup."
|
||||
fi
|
||||
}
|
||||
trap restore_csproj EXIT
|
||||
|
||||
# 1. Inject an ItemGroup holding just the selected protos, immediately before
|
||||
# the closing </Project>. The documented commented-out block is left alone.
|
||||
@@ -117,10 +130,9 @@ if [[ "$TARGET" == "sitecommand" || "$TARGET" == "all" ]]; then
|
||||
fi
|
||||
|
||||
# 5. Restore the backed-up csproj — i.e. drop the injected ItemGroup — so Docker
|
||||
# builds keep working.
|
||||
cp "$BACKUP" "$CSPROJ"
|
||||
rm -f "$BACKUP"
|
||||
trap - ERR
|
||||
# builds keep working. (Also covered by the EXIT trap above; calling it here
|
||||
# too just gives the success path its "Restored..." feedback before "Done".)
|
||||
restore_csproj
|
||||
|
||||
echo ""
|
||||
echo "Done. Review and commit:"
|
||||
|
||||
Reference in New Issue
Block a user