create a lock file during builds
prevent duplicate main instances of the build system from running the lock file is deleted when the parent process exits, alongside the tmpdir deletion the build system must only ever be run ot one instance at a time, per work directory Signed-off-by: Leah Rowe <leah@libreboot.org>audit2-merge1
parent
b6dc23bc67
commit
f1caf89a28
|
@ -24,3 +24,4 @@
|
||||||
/src/
|
/src/
|
||||||
/CHANGELOG
|
/CHANGELOG
|
||||||
/todo.txt
|
/todo.txt
|
||||||
|
/lock
|
||||||
|
|
4
build
4
build
|
@ -119,7 +119,8 @@ fetch_trees()
|
||||||
|
|
||||||
fail()
|
fail()
|
||||||
{
|
{
|
||||||
tmp_cleanup || printf "WARNING: can't rm tmpdir: %s\n" "$tmpdir" 1>&2
|
tmp_cleanup || printf "WARNING: can't rm tmp files: %s\n" "$tmpdir" \
|
||||||
|
1>&2
|
||||||
err_ "${1}"
|
err_ "${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +128,7 @@ tmp_cleanup()
|
||||||
{
|
{
|
||||||
[ "$tmpdir_was_set" = "n" ] || return 0
|
[ "$tmpdir_was_set" = "n" ] || return 0
|
||||||
rm -Rf "$tmpdir" || return 1
|
rm -Rf "$tmpdir" || return 1
|
||||||
|
rm -f lock || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
main $@
|
main $@
|
||||||
|
|
|
@ -65,27 +65,28 @@ install_packages()
|
||||||
id -u 1>/dev/null 2>/dev/null || $err "suid check failed (id -u)"
|
id -u 1>/dev/null 2>/dev/null || $err "suid check failed (id -u)"
|
||||||
[ "$(id -u)" != "0" ] || $err "this command as root is not permitted"
|
[ "$(id -u)" != "0" ] || $err "this command as root is not permitted"
|
||||||
|
|
||||||
# if "y": a coreboot target won't be built if target.cfg says release="n"
|
|
||||||
# (this is used to exclude certain build targets from releases)
|
|
||||||
|
|
||||||
[ -z "${XBMK_RELEASE+x}" ] && xbmk_release="n"
|
|
||||||
[ -z "$xbmk_release" ] && xbmk_release="$XBMK_RELEASE"
|
|
||||||
[ "$xbmk_release" = "n" ] || [ "$xbmk_release" = "y" ] || xbmk_release="n"
|
|
||||||
export XBMK_RELEASE="$xbmk_release"
|
|
||||||
|
|
||||||
[ -z "${TMPDIR+x}" ] && tmpdir_was_set="n"
|
[ -z "${TMPDIR+x}" ] && tmpdir_was_set="n"
|
||||||
if [ "$tmpdir_was_set" = "y" ]; then
|
if [ "$tmpdir_was_set" = "y" ]; then
|
||||||
[ "${TMPDIR%_*}" = "/tmp/xbmk" ] || tmpdir_was_set="n"
|
[ "${TMPDIR%_*}" = "/tmp/xbmk" ] || tmpdir_was_set="n"
|
||||||
fi
|
fi
|
||||||
if [ "$tmpdir_was_set" = "n" ]; then
|
if [ "$tmpdir_was_set" = "n" ]; then
|
||||||
|
[ -f "lock" ] && $err "The 'lock' file exists. Is a build running?"
|
||||||
export TMPDIR="/tmp"
|
export TMPDIR="/tmp"
|
||||||
tmpdir="$(mktemp -d -t xbmk_XXXXXXXX)"
|
tmpdir="$(mktemp -d -t xbmk_XXXXXXXX)"
|
||||||
export TMPDIR="$tmpdir"
|
export TMPDIR="$tmpdir"
|
||||||
|
touch lock || $err "cannot create 'lock' file"
|
||||||
else
|
else
|
||||||
export TMPDIR="$TMPDIR"
|
export TMPDIR="$TMPDIR"
|
||||||
tmpdir="$TMPDIR"
|
tmpdir="$TMPDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# if "y": a coreboot target won't be built if target.cfg says release="n"
|
||||||
|
# (this is used to exclude certain build targets from releases)
|
||||||
|
[ -z "${XBMK_RELEASE+x}" ] && xbmk_release="n"
|
||||||
|
[ -z "$xbmk_release" ] && xbmk_release="$XBMK_RELEASE"
|
||||||
|
[ "$xbmk_release" = "n" ] || [ "$xbmk_release" = "y" ] || xbmk_release="n"
|
||||||
|
export XBMK_RELEASE="$xbmk_release"
|
||||||
|
|
||||||
[ -z "${XBMK_THREADS+x}" ] || threads="$XBMK_THREADS"
|
[ -z "${XBMK_THREADS+x}" ] || threads="$XBMK_THREADS"
|
||||||
[ -z "$threads" ] && threads=1
|
[ -z "$threads" ] && threads=1
|
||||||
expr "X$threads" : "X-\{0,1\}[0123456789][0123456789]*$" \
|
expr "X$threads" : "X-\{0,1\}[0123456789][0123456789]*$" \
|
||||||
|
|
Loading…
Reference in New Issue