introduce common_functions file to be shared between programs
authorLudwig Nussel <ludwig.nussel@suse.de>
Fri, 24 Apr 2009 11:18:19 +0000 (11:18 +0000)
committerLudwig Nussel <ludwig.nussel@suse.de>
Fri, 24 Apr 2009 11:18:19 +0000 (11:18 +0000)
move set_build_arch to common_functions
introduce $BUILD_HOST_ARCH (not used yet)

build
common_functions [new file with mode: 0644]
init_buildsystem

diff --git a/build b/build
index 1b6cf7b..bb2320d 100755 (executable)
--- a/build
+++ b/build
@@ -10,7 +10,7 @@
 test -z "$BUILD_DIR" && BUILD_DIR=/usr/lib/build
 test -z "$BUILD_ROOT" && BUILD_ROOT=/var/tmp/build-root
 
-export BUILD_ARCH BUILD_ROOT BUILD_RPMS BUILD_DIR
+export BUILD_ARCH BUILD_HOST_ARCH BUILD_ROOT BUILD_RPMS BUILD_DIR
 
 ccache=0
 icecream=0
@@ -405,29 +405,6 @@ detect_vm_2nd_stage()
     return 0
 }
 
-set_build_arch()
-{
-    if [ -z "$BUILD_ARCH" ]; then
-       BUILD_ARCH=`uname -m`
-       test i686 = "$BUILD_ARCH" && BUILD_ARCH=i586 # XXX: why?
-    fi
-
-    case $BUILD_ARCH in
-      i686) BUILD_ARCH="i686:i586:i486:i386" ;;
-      i586) BUILD_ARCH="i586:i486:i386" ;;
-      i486) BUILD_ARCH="i486:i386" ;;
-      x86_64) BUILD_ARCH="x86_64:i686:i586:i486:i386" ;;
-    esac
-    if test "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then
-       cpuflags=`grep ^flags /proc/cpuinfo`
-       cpuflags="$cpuflags "
-       test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}" && {
-           echo "Your cpu doesn't support i686 rpms. Exit."
-           exit 1
-       }
-    fi
-}
-
 find_spec_files()
 {
     local spec files
@@ -510,6 +487,9 @@ shopt -s nullglob
 if detect_vm_2nd_stage ; then
     set "/.build-srcdir/$SPECFILE"
 fi
+
+. $BUILD_DIR/common_functions || exit 1
+
 export HOST
 
 while test -n "$1"; do
diff --git a/common_functions b/common_functions
new file mode 100644 (file)
index 0000000..41584db
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+set_build_arch()
+{
+    : ${BUILD_HOST_ARCH:=`uname -m`}
+
+    if [ -z "$BUILD_ARCH" ]; then
+       BUILD_ARCH="$BUILD_HOST_ARCH"
+       test i686 != "$BUILD_ARCH" || BUILD_ARCH=i586 # XXX: why?
+    fi
+
+    case $BUILD_ARCH in
+      i686) BUILD_ARCH="i686:i586:i486:i386" ;;
+      i586) BUILD_ARCH="i586:i486:i386" ;;
+      i486) BUILD_ARCH="i486:i386" ;;
+      x86_64) BUILD_ARCH="x86_64:i686:i586:i486:i386" ;;
+    esac
+    if test "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then
+       cpuflags=`grep ^flags /proc/cpuinfo`
+       cpuflags="$cpuflags "
+       test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}" && {
+           echo "Your cpu doesn't support i686 rpms. Exit."
+           exit 1
+       }
+    fi
+}
+
+# vim:sw=4
index fb9ecbb..a074b55 100755 (executable)
@@ -22,6 +22,8 @@ browner=0
 definesnstuff=()
 repos=()
 
+. $BUILD_DIR/common_functions || exit 1
+
 # should RPMs be installed with --force ?
 USE_FORCE=false
 
@@ -303,6 +305,8 @@ fail_exit()
   cleanup_and_exit 1
 }
 
+set_build_arch
+
 trap fail_exit EXIT
 
 if [ "$BUILD_ROOT" = / ]; then