add new option --configdir
authorAnas Nashif <anas.nashif@intel.com>
Wed, 16 May 2012 10:57:39 +0000 (11:57 +0100)
committerAdrian Schröter <adrian@suse.de>
Mon, 21 May 2012 12:47:36 +0000 (14:47 +0200)
To add support for distribtuons not packages with the build script, we
need an option to specify a custom location where configs can reside
instead of the hardcoded location under BUILD_DIR

build
init_buildsystem

diff --git a/build b/build
index 600a0d2..c323122 100755 (executable)
--- a/build
+++ b/build
@@ -9,6 +9,7 @@
 
 test -z "$BUILD_DIR" && BUILD_DIR=/usr/lib/build
 test -z "$BUILD_ROOT" && BUILD_ROOT=/var/tmp/build-root
+test -z "$CONFIG_DIR" && CONFIG_DIR="$BUILD_DIR/configs"
 
 export BUILD_ARCH BUILD_HOST_ARCH BUILD_ROOT BUILD_RPMS BUILD_DIR BUILD_DEBUG
 export BUILD_DIST
@@ -1005,6 +1006,9 @@ while test -n "$1"; do
       *-useusedforbuild)
        USEUSEDFORBUILD="--useusedforbuild"
       ;;
+      *-configdir)
+       CONFIG_DIR="$ARG"
+      ;;
       *-list*state)
        LIST_STATE=true
       ;;
@@ -1272,7 +1276,7 @@ if test -n "$LIST_STATE" ; then
        }
        for SPECFILE in $BUILD_ROOT/usr/src/packages/SPECS/*.spec ; do : ; done
     fi
-    init_buildsystem --cachedir "$CACHE_DIR" --list-state "${definesnstuff[@]}" "${repos[@]}" $USEUSEDFORBUILD $SPECFILE $BUILD_EXTRA_PACKS
+    init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" --list-state "${definesnstuff[@]}" "${repos[@]}" $USEUSEDFORBUILD $SPECFILE $BUILD_EXTRA_PACKS
     ERR=$?
     rm -rf $BUILD_ROOT
     cleanup_and_exit $ERR
@@ -1485,7 +1489,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do
        if test "$DO_INIT" = true ; then
            # do fist stage of init_buildsystem
            rm -f $BUILD_ROOT/.build.success
-           set -- init_buildsystem --cachedir "$CACHE_DIR" --prepare "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USE_SYSTEM_QEMU $USEUSEDFORBUILD $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS
+           set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" --prepare "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USE_SYSTEM_QEMU $USEUSEDFORBUILD $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS
            echo "$* ..."
            "$@" || cleanup_and_exit 1
            check_exit
@@ -1762,7 +1766,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do
        echo "BUILD_INCARNATION=$INCARNATION" > $BUILD_ROOT/.buildenv
        CREATE_BUILD_BINARIES=
        egrep '^#[       ]*needsbinariesforbuild[       ]*$' >/dev/null <$MYSRCDIR/$SPECFILE && CREATE_BUILD_BINARIES=--create-build-binaries
-       set -- init_buildsystem --cachedir "$CACHE_DIR" "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USE_SYSTEM_QEMU $USEUSEDFORBUILD $CREATE_BUILD_BINARIES $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS
+       set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USE_SYSTEM_QEMU $USEUSEDFORBUILD $CREATE_BUILD_BINARIES $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS
        echo "$* ..."
        "$@" || cleanup_and_exit 1
        check_exit
@@ -1937,9 +1941,9 @@ for SPECFILE in "${SPECFILES[@]}" ; do
        if test -n "$RELEASE"; then
                args=(--release "$RELEASE")
        fi
-       substitutedeps "${args[@]}" --root "$BUILD_ROOT" --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" $CHANGELOGARGS "$BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE" "$BUILD_ROOT/.spec.new" || cleanup_and_exit 1
+       substitutedeps "${args[@]}" --root "$BUILD_ROOT" --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" $CHANGELOGARGS "$BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE" "$BUILD_ROOT/.spec.new" || cleanup_and_exit 1
        # extract macros from configuration
-       getmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" > $BUILD_ROOT/root/.rpmmacros
+       getmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" > $BUILD_ROOT/root/.rpmmacros
        if test -n "$BUILD_DEBUG" ; then
            echo '
 %prep %{?!_suse_insert_debug_package_seen:%?_suse_insert_debug_package}%%prep
@@ -1960,10 +1964,10 @@ for SPECFILE in "${SPECFILES[@]}" ; do
        fi
        test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmmacros $BUILD_ROOT/home/abuild/.rpmmacros
        # extract optflags from configuration
-       getoptflags --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH" ${BUILD_DEBUG:+--debug} > $BUILD_ROOT/root/.rpmrc
+       getoptflags --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" ${BUILD_DEBUG:+--debug} > $BUILD_ROOT/root/.rpmrc
        test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmrc $BUILD_ROOT/home/abuild/.rpmrc
        if test -z "$ABUILD_TARGET"; then
-           ABUILD_TARGET=$(getchangetarget --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH" )
+           ABUILD_TARGET=$(getchangetarget --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" )
            test -z "$ABUILD_TARGET" || echo "build target is $ABUILD_TARGET"
        fi
     fi
index 1834b0c..defc0e9 100755 (executable)
@@ -85,6 +85,10 @@ while test -n "$1" ; do
            CACHE_DIR="$2"
            shift 2
            ;;
+       --configdir)
+           CONFIG_DIR=$2
+           shift 2
+           ;;
        *)
            break
            ;;
@@ -259,7 +263,7 @@ reorder()
     for PKG in "$@" ; do
        echo "$PKG" >> $BUILD_ROOT/.init_b_cache/order.manifest
     done
-    $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $BUILD_DIR/configs --manifest $BUILD_ROOT/.init_b_cache/order.manifest $BUILD_ROOT/.init_b_cache/rpms
+    $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR --manifest $BUILD_ROOT/.init_b_cache/order.manifest $BUILD_ROOT/.init_b_cache/rpms
     rm -f $BUILD_ROOT/.init_b_cache/order.manifest
 }
 
@@ -607,7 +611,7 @@ else
        #
        RPMLIST=$BUILD_ROOT/.init_b_cache/rpmlist
        test -z "$LIST_STATE" && echo "expanding package dependencies..."
-       if ! $BUILD_DIR/expanddeps $USEUSEDFORBUILD "${definesnstuff[@]}" --dist "$BUILD_DIST" --depfile "$CACHE_FILE" --archpath "$BUILD_ARCH" --configdir $BUILD_DIR/configs "${PKGS[@]}" > $RPMLIST ; then
+       if ! $BUILD_DIR/expanddeps $USEUSEDFORBUILD "${definesnstuff[@]}" --dist "$BUILD_DIST" --depfile "$CACHE_FILE" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR "${PKGS[@]}" > $RPMLIST ; then
            rm -f $BUILD_IS_RUNNING
            cleanup_and_exit 1
        fi
@@ -728,7 +732,7 @@ else
 
     echo "$GUESSED_DIST" > $BUILD_ROOT/.guessed_dist
     test -n "$BUILD_DIST" || BUILD_DIST="$GUESSED_DIST"
-    DIST_TYPE=`gettype --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH"`
+    DIST_TYPE=`gettype --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH"`
     case "$DIST_TYPE" in
        spec)  PSUF=rpm ;;
        dsc)   PSUF=deb ;;