tools: one Gradle lock helper (gradle-lock.sh) for gradle-serial.sh and clean-builds.sh
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TQd3pEP9UeN2uifbHknQ7B
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
# Prints what it removes and the space freed. Waits for the Gradle lock of tools/gradle-serial.sh, so it never deletes
|
||||
# under a running build. The orchestrator runs it after removing a worktree or when the disk is low.
|
||||
# Usage from any checkout: tools/clean-builds.sh [--dry-run]
|
||||
# shellcheck source-path=SCRIPTDIR source=gradle-lock.sh
|
||||
. "$(dirname "$0")/gradle-lock.sh"
|
||||
dry=0
|
||||
case "$1" in
|
||||
--dry-run) dry=1 ;;
|
||||
@@ -39,14 +41,8 @@ done > "$list"
|
||||
if [ ! -s "$list" ]; then echo "Nothing to remove."; exit 0; fi
|
||||
|
||||
if [ "$dry" -eq 0 ]; then
|
||||
lock=/tmp/kvitt-gradle.lock
|
||||
while ! mkdir "$lock" 2>/dev/null; do
|
||||
pid=$(cat "$lock/pid" 2>/dev/null)
|
||||
if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then rm -rf "$lock"; continue; fi
|
||||
sleep 5
|
||||
done
|
||||
echo $$ > "$lock/pid"
|
||||
trap 'rm -rf "$lock"; rm -f "$list"' EXIT INT TERM HUP
|
||||
gradle_lock_acquire
|
||||
trap 'rm -rf "$KVITT_GRADLE_LOCK"; rm -f "$list"' EXIT INT TERM HUP
|
||||
fi
|
||||
|
||||
total=0
|
||||
|
||||
Reference in New Issue
Block a user