X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=common_functions;h=da0c0934de619fcda20a8b27a3395fbc62c78aba;hb=HEAD;hp=41584dbed43678741774a31bed779f3475a4175d;hpb=9fc6008076b1b5ddf8d48cbc5a820c13070c1375;p=platform%2Fupstream%2Fbuild.git diff --git a/common_functions b/common_functions old mode 100644 new mode 100755 index 41584db..da0c093 --- a/common_functions +++ b/common_functions @@ -1,5 +1,7 @@ #!/bin/bash +: ${CACHE_DIR:=/var/cache/build} + set_build_arch() { : ${BUILD_HOST_ARCH:=`uname -m`} @@ -13,16 +15,91 @@ set_build_arch() i686) BUILD_ARCH="i686:i586:i486:i386" ;; i586) BUILD_ARCH="i586:i486:i386" ;; i486) BUILD_ARCH="i486:i386" ;; + i386) BUILD_ARCH="i386" ;; x86_64) BUILD_ARCH="x86_64:i686:i586:i486:i386" ;; + sparc64v) BUILD_ARCH="sparc64v:sparc64:sparcv9v:sparcv9:sparcv8:sparc" ;; + sparc64) BUILD_ARCH="sparc64:sparcv9:sparcv8:sparc" ;; + sparcv9v) BUILD_ARCH="sparcv9v:sparcv9:sparcv8:sparc" ;; + sparcv9) BUILD_ARCH="sparcv9:sparcv8:sparc" ;; + sparcv8) BUILD_ARCH="sparcv8:sparc" ;; + sparc) BUILD_ARCH="sparc" ;; esac if test "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then cpuflags=`grep ^flags /proc/cpuinfo` cpuflags="$cpuflags " - test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}" && { + if test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}"; then echo "Your cpu doesn't support i686 rpms. Exit." - exit 1 - } + cleanup_and_exit 1 + fi + fi +} + +check_exit() +{ + if test -e $BUILD_ROOT/exit; then + echo "exit ..." + cleanup_and_exit 1 fi } -# vim:sw=4 +is_emulator_arch() +{ + local arch + local qarch=":$BUILD_ARCH:" + for arch in $EMULATOR_ARCHS; do + if test "$qarch" != "${qarch/:$arch:/}" -a "$BUILD_HOST_ARCH" != "$arch"; then + return 0 + fi + done + return 1 +} + +check_use_emulator() +{ + is_emulator_arch || return + + if [ -z "$VM_TYPE" ]; then + return 0 + fi + + # to run the qemu initialization in the XEN chroot, we need to + # register it with a static program or shell script + case "$BUILD_HOST_ARCH" in + i?86|x86_64) + if test -e $BUILD_DIR/initvm && \ + test -e $BUILD_DIR/qemu-reg; then + return 0 # prefer initvm to handle registration + elif test -e /bin/bash-static \ + -a -e /bin/mount-static \ + -a -e /usr/sbin/qemu-binfmt-conf.sh; then + return 0 # as backup use /usr/sbin/qemu-binfmt.conf.sh + else + # XXX: error? + echo "Warning: cross compile not possible due to missing static binaries" + fi + ;; + esac + return 1 +} + +# usage: +# progress_setup LIST +# for I in $LIST; do +# progress_step LIST +# action $I +# done + +# $1 name of a textual list +progress_setup() { + eval "$1__ARRAY__=(\$$1)" + eval "$1__INDEX__=1" + eval "$1__LENGTH__=\${#$1__ARRAY__[@]}" +} + +# $1 name of a textual list +# $2 optional, printf format for 2 numeric arguments (current, total) +progress_step() { + local IDX=$1__INDEX__ + local LEN=$1__LENGTH__ + printf "${2-[%d/%d] }" $(($IDX++)) ${!LEN} +}