From 9fc6008076b1b5ddf8d48cbc5a820c13070c1375 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Fri, 24 Apr 2009 11:18:19 +0000 Subject: [PATCH] introduce common_functions file to be shared between programs move set_build_arch to common_functions introduce $BUILD_HOST_ARCH (not used yet) --- build | 28 ++++------------------------ common_functions | 28 ++++++++++++++++++++++++++++ init_buildsystem | 4 ++++ 3 files changed, 36 insertions(+), 24 deletions(-) create mode 100644 common_functions diff --git a/build b/build index 1b6cf7b..bb2320d 100755 --- 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 index 0000000..41584db --- /dev/null +++ b/common_functions @@ -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 diff --git a/init_buildsystem b/init_buildsystem index fb9ecbb..a074b55 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -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 -- 2.7.4