From a93e299f91a2692292a83bf3ac6215368b5253c7 Mon Sep 17 00:00:00 2001 From: Howard Wu <40033067+Howard20181@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:53:36 +0800 Subject: [PATCH] Selectable temporary directory locations Uncomment `export TMPDIR=$PARENT_DIR/WORK_DIR_` to use the source directory as the working directory This allows the script to work on devices with low `/tmp` storage space close #31 --- scripts/build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/build.sh b/scripts/build.sh index 58dbf4d..d428c45 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -29,6 +29,11 @@ if [ "$HOST_ARCH" != "x86_64" ] && [ "$HOST_ARCH" != "aarch64" ]; then fi cd "$(dirname "$0")" || exit 1 trap umount_clean EXIT +PARENT_DIR="$(dirname "$PWD")" +# export TMPDIR=$PARENT_DIR/WORK_DIR_ +if [ "$TMPDIR" ] && [ ! -d "$TMPDIR" ]; then + mkdir -p "$TMPDIR" +fi WORK_DIR=$(mktemp -d -t wsa-build-XXXXXXXXXX_) || exit 1 DOWNLOAD_DIR=../download DOWNLOAD_CONF_NAME=download.list @@ -51,6 +56,10 @@ umount_clean() { else rm -rf "${WORK_DIR:?}" fi + if [ "$TMPDIR" ] && [ -d "$TMPDIR" ]; then + rm -rf "${TMPDIR:?}" + unset TMPDIR + fi } clean_download() { if [ -d "$DOWNLOAD_DIR" ]; then