Skip to content

Commit 6dff1ab

Browse files
committed
Smarter auto unlock build supporting CTRL-C
Catch all exists equally, success or any error case including CTRL-C to unlock the build. This way we do not have to manually catch all exits. The lock should never get stuck because we do never build twice in a row from one script. Even ./loop_gdb.sh launches ./update.sh and as soon as it is finished the build lock is freed. If for whatever reason we need to build multiple times in a row the manual `unlock_build` calls have to be reintroduced.
1 parent dabfa31 commit 6dff1ab

3 files changed

Lines changed: 1 addition & 5 deletions

File tree

lib/include/build_lock.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function lock_build() {
130130
# lock the build
131131
printf '%s %s %s %s\n' "$CFG_GIT_PATH_MOD" "$SERVER_UUID" "$$" "$(date '+%s')" >> "$BUILD_LOCKFILE"
132132
_meta_unlock || return 1
133+
trap unlock_build EXIT
133134
}
134135

135136
function unlock_build() {

lib/include/update/cmake.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ function cmake_update() {
161161
err " cd $arg_git_path"
162162
err " git status"
163163
err " $(tput bold)./update.sh --force$(tput sgr0) to ignore"
164-
unlock_build
165164
exit 1
166165
fi
167166
current_branch="$(git rev-parse --abbrev-ref HEAD)"
@@ -230,7 +229,6 @@ function cmake_update() {
230229
if [ "$build_fail" == "1" ]
231230
then
232231
err --log "build failed."
233-
unlock_build
234232
exit 1
235233
fi
236234
if [ ! -f "$arg_compiled_bin" ]

update.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,12 @@ then
225225
then
226226
custom_update_teeworlds "$@"
227227
else
228-
unlock_build
229228
err "Unsupported build system: $CFG_BUILD_SYSTEM"
230229
exit 1
231230
fi
232231
map_themes_post
233232
git_save_pull
234233
update_lua
235-
236-
unlock_build
237234
elif [ "$CFG_SERVER_TYPE" == "tem" ] || [ "$arg_type" == "tem" ]
238235
then
239236
if [ "$arg_refresh" == "1" ]

0 commit comments

Comments
 (0)