Merge remote-tracking branch 'origin/devel' accepted/tizen/devbase/tools/20210513.020813 submit/trunk/20210508.154130
authorbiao716.wang <biao716.wang@samsung.com>
Sat, 8 May 2021 07:41:22 +0000 (16:41 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Sat, 8 May 2021 07:41:22 +0000 (16:41 +0900)
Change-Id: If69a74e840cc9ac3cc17cc30792b209fc06201ee

build
common_functions
init_buildsystem

diff --git a/build b/build
index fb572fe..f98e1b7 100755 (executable)
--- 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
index 512d826..8512eae 100755 (executable)
@@ -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
+}
+
index 187f944..de92390 100755 (executable)
@@ -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"/*