need to recursively chown TOPDIR
[opensuse:build.git] / common_functions
1 #!/bin/bash
2
3 set_build_arch()
4 {
5     : ${BUILD_HOST_ARCH:=`uname -m`}
6
7     if [ -z "$BUILD_ARCH" ]; then
8         BUILD_ARCH="$BUILD_HOST_ARCH"
9         test i686 != "$BUILD_ARCH" || BUILD_ARCH=i586 # XXX: why?
10     fi
11
12     case $BUILD_ARCH in
13       i686) BUILD_ARCH="i686:i586:i486:i386" ;;
14       i586) BUILD_ARCH="i586:i486:i386" ;;
15       i486) BUILD_ARCH="i486:i386" ;;
16       i386) BUILD_ARCH="i386" ;;
17       x86_64) BUILD_ARCH="x86_64:i686:i586:i486:i386" ;;
18       sparc64v) BUILD_ARCH="sparc64v:sparc64:sparcv9v:sparcv9:sparcv8:sparc" ;;
19       sparc64) BUILD_ARCH="sparc64:sparcv9:sparcv8:sparc" ;;
20       sparcv9v) BUILD_ARCH="sparcv9v:sparcv9:sparcv8:sparc" ;;
21       sparcv9) BUILD_ARCH="sparcv9:sparcv8:sparc" ;;
22       sparcv8) BUILD_ARCH="sparcv8:sparc" ;;
23       sparc) BUILD_ARCH="sparc" ;;
24     esac
25     if test "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then
26         cpuflags=`grep ^flags /proc/cpuinfo`
27         cpuflags="$cpuflags "
28         if test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}"; then
29             echo "Your cpu doesn't support i686 rpms. Exit."
30             cleanup_and_exit 1
31         fi
32     fi
33 }
34
35 check_exit()
36 {
37     if test -e $BUILD_ROOT/exit; then
38         echo "exit ..."
39         cleanup_and_exit 1
40     fi
41 }
42
43 is_emulator_arch()
44 {
45     local arch
46     for arch in $EMULATOR_ARCHS; do
47         if test "$BUILD_ARCH" = "$arch" -a "$BUILD_HOST_ARCH" != "$arch"; then
48             return 0
49         fi
50     done
51     return 1
52 }
53
54 check_use_emulator()
55 {
56     is_emulator_arch || return
57
58     if [ -z "$VM_TYPE" ]; then
59         return 0
60     fi
61
62     # to run the qemu initialization in the XEN chroot, we need to register it with a statically build shell
63     case "$BUILD_HOST_ARCH" in
64         i?86|x86_64)
65             if test -e /bin/bash-static \
66                 -a -e /bin/mount-static \
67                 -a -e /usr/sbin/qemu-binfmt-conf.sh; then
68                 return 0
69             else
70                 # XXX: error?
71                 echo "Warning: cross compile not possible due to missing static binaries"
72             fi
73         ;;
74     esac
75     return 1
76 }