summaryrefslogtreecommitdiffstats
path: root/tools/build_snapshots.sh
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-09-22 07:44:57 -0300
committerRenato Botelho <renato@netgate.com>2015-09-22 07:44:57 -0300
commit3e05b544c797db1cdb2fa8db3806d89c5661ca2b (patch)
treebb367b52a4f8e2c38fd5e14062b2a993899ea9a0 /tools/build_snapshots.sh
parent3adf4a15e63244216e5a0945cd6daba39a4ac26a (diff)
downloadpfsense-3e05b544c797db1cdb2fa8db3806d89c5661ca2b.zip
pfsense-3e05b544c797db1cdb2fa8db3806d89c5661ca2b.tar.gz
Start to build a new round of snapshots when get SIGINFO (ctrl+t)
Diffstat (limited to 'tools/build_snapshots.sh')
-rwxr-xr-xtools/build_snapshots.sh47
1 files changed, 37 insertions, 10 deletions
diff --git a/tools/build_snapshots.sh b/tools/build_snapshots.sh
index ca7f635..5b74de8 100755
--- a/tools/build_snapshots.sh
+++ b/tools/build_snapshots.sh
@@ -57,19 +57,33 @@ done
# Keeps track of how many time builder has looped
BUILDCOUNTER=0
+export COUNTER=0
+
+# Global variable to keep sleep pid
+export _sleep_pid=0
git_last_commit() {
export CURRENT_COMMIT=$(git -C ${BUILDER_ROOT} log -1 --format='%H')
export CURRENT_AUTHOR=$(git -C ${BUILDER_ROOT} log -1 --format='%an')
}
+restart_build() {
+ if [ "${_sleep_pid}" != "0" ]; then
+ ${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> SIGNINFO received, restarting build"
+ COUNTER=$((maxsleepvalue + 60))
+ kill ${_sleep_pid}
+ fi
+}
+
# This routine is called in between runs. We
# will sleep for a bit and check for new commits
# in between sleeping for short durations.
snapshots_sleep_between_runs() {
- COUNTER=0
while [ $COUNTER -lt $maxsleepvalue ]; do
- sleep 60
+ sleep 60 &
+ _sleep_pid=$!
+ wait ${_sleep_pid}
+ _sleep_pid=0
# Update this repo
git -C "${BUILDER_ROOT}" pull -q
git_last_commit
@@ -88,6 +102,9 @@ snapshots_sleep_between_runs() {
git_last_commit
+# Handle SIGINFO (ctrl+T) and restart build
+trap restart_build SIGINFO
+
# Main builder loop
while [ /bin/true ]; do
BUILDCOUNTER=$((${BUILDCOUNTER}+1))
@@ -111,12 +128,22 @@ while [ /bin/true ]; do
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Sleeping for at least $minsleepvalue, at most $maxsleepvalue in between snapshot builder runs."
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Last known commit: ${LAST_COMMIT}"
- ${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Freezing build process at $(date)."
- sleep $minsleepvalue
- ${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Thawing build process and resuming checks for pending commits at $(date)."
-
- # Count some sheep or wait until a new commit turns up
- # for one days time. We will wake up if a new commit
- # is detected during sleepy time.
- snapshots_sleep_between_runs $maxsleepvalue
+ ${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Freezing build process at $(date)"
+ echo ">>> Press ctrl+T to start a new build"
+ COUNTER=0
+ sleep $minsleepvalue &
+ _sleep_pid=$!
+ wait ${_sleep_pid}
+ _sleep_pid=0
+
+ # If COUNTER > 0, ctrl+T was pressed, then skip this block
+ if [ ${COUNTER} -eq 0 ]; then
+ ${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Thawing build process and resuming checks for pending commits at $(date)."
+ echo ">>> Press ctrl+T to start a new build"
+
+ # Count some sheep or wait until a new commit turns up
+ # for one days time. We will wake up if a new commit
+ # is detected during sleepy time.
+ snapshots_sleep_between_runs $maxsleepvalue
+ fi
done
OpenPOWER on IntegriCloud