3 ################################################################
5 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 or 3 as
9 # published by the Free Software Foundation.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program (see the file COPYING); if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 ################################################################
24 : ${BUILD_HOST_ARCH:=`uname -m`}
25 # the linux kernel only knows armv7l, armv7hl is a userland definition
26 test armv7l == "$BUILD_HOST_ARCH" && BUILD_HOST_ARCH=armv7hl
28 BUILD_INITVM_ARCH="$BUILD_HOST_ARCH"
29 # avoid multiple initvm.* helpers for i586 and i686
30 test i686 != "$BUILD_INITVM_ARCH" || BUILD_INITVM_ARCH=i586
35 aarch64) BUILD_ARCH="aarch64:aarch64_ilp32:armv8l" ;;
36 aarch64_ilp32) BUILD_ARCH="aarch64_ilp32:aarch64:armv8l" ;;
37 armv8l) BUILD_ARCH="armv8l" ;; # armv8l is aarch64 in 32bit mode. not a superset of armv7
38 armv7hl) BUILD_ARCH="armv7hl:armv7l:armv6hl:armv6l:armv5tel" ;;
39 armv7l) BUILD_ARCH="armv7l:armv6l:armv5tel" ;;
40 armv6hl) BUILD_ARCH="armv6hl:armv6l:armv5tel" ;;
41 armv6l) BUILD_ARCH="armv6l:armv5tel" ;;
42 armv5tel) BUILD_ARCH="armv5tel" ;;
43 m68k) BUILD_ARCH="m68k" ;;
44 mips64) BUILD_ARCH="mips64:mips" ;;
45 mips) BUILD_ARCH="mips" ;;
46 i686) BUILD_ARCH="i686:i586:i486:i386" ;;
47 i586) BUILD_ARCH="i586:i486:i386" ;;
48 i486) BUILD_ARCH="i486:i386" ;;
49 i386) BUILD_ARCH="i386" ;;
50 ia64) BUILD_ARCH="ia64" ;;
51 parisc64) BUILD_ARCH="hppa64:hppa" ;;
52 parisc) BUILD_ARCH="hppa" ;;
53 ppc) BUILD_ARCH="ppc" ;;
54 ppc64) BUILD_ARCH="ppc64:ppc" ;;
55 ppc64le) BUILD_ARCH="ppc64le" ;;
56 s390x) BUILD_ARCH="s390x:s390" ;;
57 s390) BUILD_ARCH="s390" ;;
58 sparc64v) BUILD_ARCH="sparc64v:sparc64:sparcv9v:sparcv9:sparcv8:sparc" ;;
59 sparc64) BUILD_ARCH="sparc64:sparcv9:sparcv8:sparc" ;;
60 sparcv9v) BUILD_ARCH="sparcv9v:sparcv9:sparcv8:sparc" ;;
61 sparcv9) BUILD_ARCH="sparcv9:sparcv8:sparc" ;;
62 sparcv8) BUILD_ARCH="sparcv8:sparc" ;;
63 sparc) BUILD_ARCH="sparc" ;;
64 x86_64) BUILD_ARCH="x86_64:i686:i586:i486:i386" ;;
70 if test -z "$BUILD_ARCH" ; then
71 BUILD_ARCH="$BUILD_HOST_ARCH"
74 if test "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then
75 cpuflags=`grep ^flags /proc/cpuinfo`
77 if test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}"; then
78 echo "Your cpu doesn't support i686 rpms. Exit."
85 if test -e $BUILD_ROOT/exit; then
91 check_use_emulator() {
93 # check if the extended host arch contains the build arch
94 local old_build_arch="$BUILD_ARCH"
95 local arch="${BUILD_ARCH%%:*}"
96 BUILD_ARCH="$BUILD_HOST_ARCH"
98 BUILD_ARCH=":$BUILD_ARCH:"
99 if test "$BUILD_ARCH" != "${BUILD_ARCH/:$arch:/}" ; then
100 # native supported arch, no emulator
101 BUILD_ARCH="$old_build_arch"
104 BUILD_ARCH="$old_build_arch"
106 # to run the qemu initialization in the vm, we need to
107 # register it with a static program or shell script
108 INITVM_NAME="initvm.$BUILD_INITVM_ARCH"
109 if test -e "$BUILD_DIR/$INITVM_NAME" -a -e "$BUILD_DIR/qemu-reg" ; then
110 chmod 0755 "$BUILD_DIR/$INITVM_NAME"
111 return 0 # chroot build, we need to run
114 echo "Warning: cross compile not possible due to missing static binaries. please install build-initvm package for that purpose."
115 echo " check that the right architecture is available for your build host, you need $INITVM_NAME for this one."
121 # progress_setup LIST
127 # $1 name of a textual list
129 eval "$1__ARRAY__=(\$$1)"
131 eval "$1__LENGTH__=\${#$1__ARRAY__[@]}"
134 # $1 name of a textual list
135 # $2 optional, printf format for 2 numeric arguments (current, total)
137 local IDX=$1__INDEX__
138 local LEN=$1__LENGTH__
139 printf "${2-[%d/%d] }" $(($IDX++)) ${!LEN}