[build] reworked qemu init code. never mix up local and OBS backend server installed...
authorMartin Mohring <martin.mohring@5edatasoft.com>
Thu, 11 Aug 2011 16:49:14 +0000 (18:49 +0200)
committerMartin Mohring <martin.mohring@5edatasoft.com>
Thu, 11 Aug 2011 16:49:14 +0000 (18:49 +0200)
build
init_buildsystem

diff --git a/build b/build
index 25053dd..29fdced 100755 (executable)
--- a/build
+++ b/build
@@ -86,11 +86,11 @@ RSYNCDONE=
 SIGNDUMMY=
 
 # list of archs which need emulator initialization
-: ${EMULATOR_ARCHS:="armv4l armv5el armv6el armv7el armv7hl armv8el mips mipsel mips64 mips64el ppc ppc64 sh4"}
+: ${EMULATOR_ARCHS:="armv4l armv5el armv6el armv7el armv7hl armv8el mips mipsel mips64 mips64el ppc ppc64 sh4 sparc sparc64 s390 s390x"}
 export EMULATOR_ARCHS
 
 # list of devices registered by binfmt handlers in /proc/sys/fs/binfmt_misc
-: ${EMULATOR_DEVS:="arm mips mipsel mips64 mips64el ppc sh4 sparc"}
+: ${EMULATOR_DEVS:="arm armeb mips mipsel mips64 mips64el ppc sh4 sh4eb sparc s390x"}
 export EMULATOR_DEVS
 
 # This is for insserv
@@ -1435,7 +1435,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do
        fi
 
        if check_use_emulator; then
-           if [ -e $BUILD_DIR/initvm ]; then
+           if [ -x "$BUILD_DIR/initvm" -a -e "$BUILD_DIR/qemu-reg" ]; then
                vm_init_script="/.build/initvm"
            elif [ -e $BUILD_DIR/initscript_qemu_vm ]; then
                vm_init_script="/.build/initscript_qemu_vm"
index 35f9501..09760a1 100755 (executable)
@@ -357,33 +357,49 @@ validate_cache_file()
 #
 copy_qemu()
 {
-    local dev dir path dest
+    local path dest
 
     echo "copying qemu"
 
     mkdir -p $BUILD_ROOT/usr/bin
-    for dev in $EMULATOR_DEVS; do
-       for dir in $BUILD_DIR /usr/bin; do
-           for path in $dir/qemu-${dev}*; do
-               if file $path | grep -q static; then
-                   dest="$BUILD_ROOT/usr/bin/${path##*/}"
-                   if [ -f "$path" -a ! -x "$dest" ]; then
-                       echo -n " $path"                # report copy
-                       install -m755 "$path" "$dest"
-                   fi
+
+    if [ -e $BUILD_DIR/qemu-reg ]; then
+
+       for path in $BUILD_DIR/qemu-*; do
+           if file $path | grep -q static; then
+               dest="$BUILD_ROOT/usr/bin/${path##*/}"
+               if [ -f "$path" -a ! -x "$dest" ]; then
+                   echo -n " $path"            # report copy
+                   #echo install -m755 "$path" "$dest"
+                   install -m755 "$path" "$dest"
                fi
-           done
+           fi
        done
-    done
+
+    else
+
+       for path in /usr/bin/qemu-*; do
+           if file $path | grep -q static; then
+               dest="$BUILD_ROOT/usr/bin/${path##*/}"
+               if [ -f "$path" -a ! -x "$dest" ]; then
+                   echo -n " $path"            # report copy
+                   #echo install -m755 "$path" "$dest"
+                   install -m755 "$path" "$dest"
+               fi
+           fi
+       done
+
+       if [ -e /usr/sbin/qemu-binfmt-conf.sh \
+           -a ! -e $BUILD_ROOT/usr/sbin/qemu-binfmt-conf.sh ]; then
+           echo " /usr/sbin/qemu-binfmt-conf.sh"               # report copy
+           mkdir -p $BUILD_ROOT/usr/sbin
+           install -m755 /usr/sbin/qemu-binfmt-conf.sh $BUILD_ROOT/usr/sbin
+       fi
+
+    fi
     echo ""
 
     # Below for backward compatibility when /.build/initvm is not present
-    if [ -e /usr/sbin/qemu-binfmt-conf.sh \
-       -a ! -e $BUILD_ROOT/usr/sbin/qemu-binfmt-conf.sh ]; then
-       echo " /usr/sbin/qemu-binfmt-conf.sh"           # report copy
-       mkdir -p $BUILD_ROOT/usr/sbin
-       install -m755 /usr/sbin/qemu-binfmt-conf.sh $BUILD_ROOT/usr/sbin
-    fi
 
     if [ -n "$PREPARE_VM" ]; then
        if [ -x /bin/bash-static -a -x /bin/mount-static ]; then
@@ -576,16 +592,11 @@ else
        if [ -z "$PREPARE_VM" ]; then
            if ! check_binfmt_registered; then
                echo "registering binfmt handlers"
-               # prefer initvm over qemu-binfmt-conf.sh
-               success=false
-               for cmd in $BUILD_DIR/initvm /usr/sbin/qemu-binfmt-conf.sh
-               do
-                   if [ -x $cmd ] && $cmd; then
-                       success=true
-                       break
-                   fi
-               done
-               if [ success = false ]; then
+               if [ -x "$BUILD_DIR/initvm" -a -e "$BUILD_DIR/qemu-reg" ]; then
+                   $BUILD_DIR/initvm
+               elif [ -x /usr/sbin/qemu-binfmt-conf.sh ]; then
+                  /usr/sbin/qemu-binfmt-conf.sh
+               else
                    echo "Warning: could not register binfmt handlers"
                fi
            fi