diff options
author | wang biao <biao716.wang@samsung.com> | 2022-04-08 16:57:19 +0800 |
---|---|---|
committer | wang biao <biao716.wang@samsung.com> | 2022-04-20 17:35:04 +0800 |
commit | f80914042dd111f04042c5c38c1f239edabaafd7 (patch) | |
tree | 3a8f52111af2ad5977ffcc2c9afe881d36242ca7 /common_functions | |
parent | de111f2f1c4470cea8d13548fe33e02548afe323 (diff) | |
download | build-f80914042dd111f04042c5c38c1f239edabaafd7.tar.gz build-f80914042dd111f04042c5c38c1f239edabaafd7.tar.bz2 build-f80914042dd111f04042c5c38c1f239edabaafd7.zip |
Fix multiple mount issue
Change-Id: I6c5fa606cc7e706a461a7df8a9907b1a6de1c51f
Signed-off-by: wang biao <biao716.wang@samsung.com>
Diffstat (limited to 'common_functions')
-rwxr-xr-x | common_functions | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/common_functions b/common_functions index f0084f8..54a1573 100755 --- a/common_functions +++ b/common_functions @@ -88,20 +88,27 @@ check_exit() { fi } -check_use_emulator() { - INITVM_NAME= - # check if the extended host arch contains the build arch +check_native_arch() { + local arch="$1" local old_build_arch="$BUILD_ARCH" - local arch="${BUILD_ARCH%%:*}" BUILD_ARCH="$BUILD_HOST_ARCH" extend_build_arch BUILD_ARCH=":$BUILD_ARCH:" if test "$BUILD_ARCH" != "${BUILD_ARCH/:$arch:/}" ; then - # native supported arch, no emulator BUILD_ARCH="$old_build_arch" - return 1 + return 0 fi BUILD_ARCH="$old_build_arch" + return 1 +} + +check_use_emulator() { + INITVM_NAME= + # check if the extended host arch contains the build arch + if check_native_arch "${BUILD_ARCH%%:*}" ; then + # native supported arch, no emulator needed + return 1 + fi # to run the qemu initialization in the vm, we need to # register it with a static program or shell script @@ -158,4 +165,32 @@ buildroot_umount() { LOOP_CNT=$((LOOP_CNT+1)) done } +# rm that makes sure the file is gone +buildroot_rm() { + rm -rf "$BUILD_ROOT/$1" + test -e "$BUILD_ROOT/$1" && cleanup_and_exit 1 "could not remove $BUILD_ROOT/$1" +} + +assert_dirs() { + local d rl + if test -z "$1" ; then + set usr sbin usr/bin usr/sbin etc .build .build.oldpackages .init_b_cache .init_b_cache/scripts .init_b_cache/rpms .preinstall_image proc proc/sys proc/sys/fs proc/sys/fs/binfmt_misc sys dev dev/pts dev/shm mnt + fi + for d in "$@" ; do + if test -L "$BUILD_ROOT/$d" ; then + rl="$(readlink "$BUILD_ROOT/$d")" + test "$d" = sbin -a "x$rl" = "xusr/sbin" && continue + test "$d" = sbin -a "x$rl" = "xusr/bin" && continue + test "$d" = usr/sbin -a "x$rl" = "xbin" && continue + cleanup_and_exit 1 "$d: illegal symlink to $rl" + else + test -e "$BUILD_ROOT/$d" -a ! -d "$BUILD_ROOT/$d" && cleanup_and_exit 1 "$d: not a directory" + fi + done +} + +assert_dir_path() { + test "$1" != "${1%/*}" && assert_dir_path "${1%/*}" + assert_dirs "$1" +} |