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
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
+}
+
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"/*