summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunggi Lee <hyunggi.lee@samsung.com>2021-05-03 20:28:27 +0900
committerHyunggi Lee <hyunggi.lee@samsung.com>2021-05-04 12:43:05 +0900
commit4f2c6883d8a923e9aadc7bdc835b7aa083782209 (patch)
tree115598f82c0f799f1b9235c408ec04ede078da96
parent9682daf8a594ef3897aaa8846be4718ae6082f6a (diff)
downloadbuild-4f2c6883d8a923e9aadc7bdc835b7aa083782209.tar.gz
build-4f2c6883d8a923e9aadc7bdc835b7aa083782209.tar.bz2
build-4f2c6883d8a923e9aadc7bdc835b7aa083782209.zip
fix umount error when build is done
error: there're mounted directories to build root. Please unmount them manually to avoid being deleted unexpectly: / ==> ~/GBS-ROOT-TIZEN/t65std/local/BUILD-ROOTS/scratch.armv7l.0/proc / ==> ~/GBS-ROOT-TIZEN/t65std/local/BUILD-ROOTS/scratch.armv7l.0/proc/sys/fs/binfmt_misc / ==> ~/GBS-ROOT-TIZEN/t65std/local/BUILD-ROOTS/scratch.armv7l.0/proc In certain build environments, proc/fs/sys/fs/binfmt_misc and proc are mounted multiple times (unknown reason) However, when the build is complete, umount is executed only once. So, I added the repeating code to umount them all. Change-Id: Ia8cdfc62d0481043aae2b951a6daa202ba4b4a08 Signed-off-by: Hyunggi Lee <hyunggi.lee@samsung.com>
-rwxr-xr-xbuild16
-rwxr-xr-xcommon_functions21
-rwxr-xr-xinit_buildsystem21
3 files changed, 38 insertions, 20 deletions
diff --git a/build b/build
index fb572fe..f98e1b7 100755
--- a/build
+++ b/build
@@ -389,17 +389,11 @@ cleanup_and_exit () {
test -n "$browner" && chown "$browner" "$BUILD_ROOT"
vm_shutdown "$1"
else
- umount -n "$BUILD_ROOT"/proc/sys/fs/binfmt_misc 2> /dev/null || true
- umount -n "$BUILD_ROOT"/proc 2>/dev/null || true
- while true
- do
- umount -n "$BUILD_ROOT"/dev/pts 2>/dev/null
- if test $? -ne 0; then
- break
- fi
- done
- umount -n "$BUILD_ROOT"/dev/shm 2>/dev/null || true
- umount -n "$BUILD_ROOT"/sys 2>/dev/null || true
+ buildroot_umount /proc/sys/fs/binfmt_misc
+ buildroot_umount /proc
+ buildroot_umount /sys
+ buildroot_umount /dev/pts
+ buildroot_umount /dev/shm
test -n "$VM_IMAGE" -a "$VM_IMAGE" != 1 && umount "$BUILD_ROOT" 2>/dev/null || true
test -n "$VM_TYPE" && vm_cleanup
fi
diff --git a/common_functions b/common_functions
index 512d826..8512eae 100755
--- a/common_functions
+++ b/common_functions
@@ -138,3 +138,24 @@ progress_step() {
local LEN=$1__LENGTH__
printf "${2-[%d/%d] }" $(($IDX++)) ${!LEN}
}
+
+# umount that does not follow symlinks
+buildroot_umount() {
+ local d="$1"
+ local d2="/$d"
+ while test -n "$d2" ; do
+ test -L "$BUILD_ROOT$d2" && return
+ test -d "$BUILD_ROOT$d2" || return
+ d2="${d2%/*}"
+ done
+ # XXX: use stat -f /dev/pts/ -c %T to check whether it's mounted and not suppress errors?
+ local LOOP_CNT=1
+ while [ $LOOP_CNT -le 20 ] ; do
+ umount -n "$BUILD_ROOT/$d" 2>/dev/null
+ if test $? -ne 0; then
+ break
+ fi
+ LOOP_CNT=$((LOOP_CNT+1))
+ done
+}
+
diff --git a/init_buildsystem b/init_buildsystem
index 187f944..de92390 100755
--- a/init_buildsystem
+++ b/init_buildsystem
@@ -158,20 +158,23 @@ cleanup_and_exit() {
test "$BUILD_ROOT" = / -a -n "$browner" && chown "$browner" "$BUILD_ROOT"
# umount so init_buildsystem can be used standalone
# XXX: use stat -f /dev/pts/ -c %T to check whether it's mounted and not suppress errors then?
- umount -n "$BUILD_ROOT/proc/sys/fs/binfmt_misc" 2> /dev/null || true
- umount -n "$BUILD_ROOT/proc" 2> /dev/null || true
- umount -n "$BUILD_ROOT/dev/pts" 2> /dev/null || true
- umount -n "$BUILD_ROOT/mnt" 2> /dev/null || true
+ buildroot_umount "/proc/sys/fs/binfmt_misc"
+ buildroot_umount "/proc"
+ buildroot_umount "/sys"
+ buildroot_umount "/dev/pts"
+ buildroot_umount "/dev/shm"
+ buildroot_umount "/mnt"
exit ${1:-0}
}
clean_build_root() {
if test -n "$BUILD_ROOT" ; then
- umount -n "$BUILD_ROOT/proc/sys/fs/binfmt_misc" 2> /dev/null || true
- umount -n "$BUILD_ROOT/proc" 2> /dev/null || true
- umount -n "$BUILD_ROOT/dev/pts" 2> /dev/null || true
- umount -n "$BUILD_ROOT/dev/shm" 2> /dev/null || true
- umount -n "$BUILD_ROOT/mnt" 2> /dev/null || true
+ buildroot_umount "/proc/sys/fs/binfmt_misc"
+ buildroot_umount "/proc"
+ buildroot_umount "/sys"
+ buildroot_umount "/dev/pts"
+ buildroot_umount "/dev/shm"
+ buildroot_umount "/mnt"
rm -rf -- "$BUILD_ROOT"/* 2> /dev/null || true
chattr -a -A -i -R -- "$BUILD_ROOT" 2> /dev/null || true
rm -rf -- "$BUILD_ROOT"/*