summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2021-05-08 16:41:22 +0900
committerbiao716.wang <biao716.wang@samsung.com>2021-05-08 16:41:22 +0900
commit1aa7e7476181593b380670a2c05f9a51e9faaec1 (patch)
tree115598f82c0f799f1b9235c408ec04ede078da96
parent07884282576d8e059ad2392085881eb67f1d9afc (diff)
parent4f2c6883d8a923e9aadc7bdc835b7aa083782209 (diff)
downloadbuild-1aa7e7476181593b380670a2c05f9a51e9faaec1.tar.gz
build-1aa7e7476181593b380670a2c05f9a51e9faaec1.tar.bz2
build-1aa7e7476181593b380670a2c05f9a51e9faaec1.zip
Change-Id: If69a74e840cc9ac3cc17cc30792b209fc06201ee
-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"/*