clean.sh: avoid cleaning build directories while build is running

This commit is contained in:
Leonid Pliushch 2019-07-08 17:51:38 +03:00
parent 291c7bbe1a
commit 6bf521b42b
1 changed files with 18 additions and 2 deletions

View File

@ -6,5 +6,21 @@ set -e -u
test -f $HOME/.termuxrc && . $HOME/.termuxrc
: ${TERMUX_TOPDIR:="$HOME/.termux-build"}
[ -d "$TERMUX_TOPDIR" ] && chmod +w -R $TERMUX_TOPDIR
rm -Rf /data/* $TERMUX_TOPDIR
# Lock file. Same as used in build-package.sh.
TERMUX_BUILD_LOCK_FILE="/tmp/.termux-build.lck"
if [ ! -e "$TERMUX_BUILD_LOCK_FILE" ]; then
touch "$TERMUX_BUILD_LOCK_FILE"
fi
{
if ! flock -n 5; then
echo "Not cleaning build directory since you have unfinished build running."
exit 1
fi
if [ -d "$TERMUX_TOPDIR" ]; then
chmod +w -R $TERMUX_TOPDIR
fi
rm -Rf /data/* $TERMUX_TOPDIR
} 5< "$TERMUX_BUILD_LOCK_FILE"