Whamcloud - gitweb
b=22847 separate format and content in ext[34]_warning()
[fs/lustre-release.git] / build / lmake
index a018011..9a2288e 100755 (executable)
@@ -49,6 +49,9 @@ CONFIG_FILE=
 RPMBUILD=
 XEN=false
 
+# build the lustre-tests rpm?
+LUSTRE_TESTS=true
+
 canon()
 {
     pushd $1 >/dev/null
@@ -242,7 +245,7 @@ load_target()
 #    [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a patch series."
 #    [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
     [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify the kernel version."
-    
+
     if [ "$KERNELDIR" ] ; then
        KERNEL_FILE="$KERNELDIR/$KERNEL"
        [ -r "$KERNELDIR/$KERNEL" ] || \
@@ -284,10 +287,10 @@ setup_ccache_distcc()
             unset DISTCC
         fi
     fi
-    
+
     CC=${CC:-gcc}
     if [ "$CCACHE" ]; then
-        CC="$CCACHE $CC"
+        [[ $CC != ccache\ * ]] && CC="$CCACHE $CC"
         [ "$DISTCC" ] && export CCACHE_PREFIX="$DISTCC"
     else
         [ "$DISTCC" ] && CC="$DISTCC $CC"
@@ -330,7 +333,7 @@ extract_kernel()
        [ -L linux ] && rm -rf $(readlink linux)
        rm -rf linux
     fi
-    untar "$KERNEL_FILE"
+    untar "$KERNEL_FILE" || fatal 1 "Error unpacking Linux tarball"
     [ -d linux ] || ln -sf linux* linux
     popd >/dev/null
 }
@@ -388,7 +391,7 @@ timed_run() {
     #bash -c "$@" &
     ("$@") &
     child_pid=$!
-    
+
     (sleep $SLEEP_TIME
     kill -TERM -$child_pid 2>/dev/null
     sleep 5
@@ -415,7 +418,7 @@ depend_kernel()
     if [ -n "${TARGET_CONFIG}" ]; then
        extra_version="${extra_version}${TARGET_DELIMITER}${TARGET_CONFIG}"
     fi
-    perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${extra_version}/" Makefile
+    sed -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${extra_version}/" Makefile
     echo "Making depend in $PWD..."
     $MAKE "$MAKE_CC" mrproper || fatal 1 "Error running make mrproper"
     rm -f rpm-release
@@ -538,14 +541,12 @@ build_kernel_ib()
     if [ "$OFED_VERSION" = "1.3" ]; then
         K_SRC="KSRC"
     fi
-    $RPMBUILD --rebuild --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
-             --define "_topdir $(lbuild_topdir)" --target ${TARGET_ARCH} \
-             --define "KVERSION ${FULL_VERSION}" \
-             --define "$K_SRC ${PWD}/linux" \
-             --define "LIB_MOD_DIR /lib/modules/${FULL_VERSION}" \
-             --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --without-srp-target-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" $(lbuild_topdir)/OFED/SRPMS/ofa_kernel-${OFED_VERSION}-ofed${OFED_VERSION}.src.rpm
-
-    if [ ${PIPESTATUS[0]} != 0 ]; then
+    if ! $RPMBUILD --rebuild --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
+                   --define "_topdir $(lbuild_topdir)" --target ${TARGET_ARCH} \
+                   --define "KVERSION ${FULL_VERSION}" \
+                   --define "$K_SRC ${PWD}/linux" \
+                   --define "LIB_MOD_DIR /lib/modules/${FULL_VERSION}" \
+                   --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" $(lbuild_topdir)/OFED/SRPMS/ofa_kernel-*.src.rpm 2>&1; then
         fatal 1 "Error building kernel-ib"
     fi
 
@@ -553,7 +554,7 @@ build_kernel_ib()
     rm -rf kernel-ib-devel
     mkdir kernel-ib-devel
     cd kernel-ib-devel
-    local rpm=$(ls $(lbuild_topdir)/RPMS/*/kernel-ib-devel-${OFED_VERSION}-${FULL_VERSION//-/_}.*.rpm)
+    local rpm=$(ls $(lbuild_topdir)/RPMS/*/kernel-ib-devel-*-${FULL_VERSION//-/_}.*.rpm)
     rpm2cpio -itv < $rpm | cpio -id
     CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
     popd >/dev/null
@@ -581,12 +582,22 @@ build_lustre()
        -e s^@VERSION@^${LUSTRE_VERSION}^g \
        -e s^@LINUXRELEASE@^${FULL_VERSION}^g \
        -e s^@RELEASE@^${FULL_VERSION//-/_}^g \
-       -e s^@ac_configure_args@^"--with-linux=${PWD}/linux ${CONFIGURE_FLAGS}"^g \
        < lustre.spec.in \
        > lustre.spec
+    # convert the $LUSTRE_TESTS boolean to an empty/not-empty boolean
+    # as silly as this seems, it makes the syntax of the rpmbuild command
+    # simpler and not need an eval to deal with the quotes in the quotes
+    # ditto for the lustre-tests boolean
+    local lustre_tests=""
+    if ! $LUSTRE_TESTS; then
+        lustre_tests="no"
+    fi
+
     $RPMBUILD --target ${TARGET_ARCH} -bb lustre.spec \
+        --define "configure_args --with-linux=${PWD}/linux ${CONFIGURE_FLAGS}" \
+        ${lustre_tests:+--define "build_lustre_tests 0"} \
         --define "_tmppath $TMPDIR" \
-       --define "_topdir $(lbuild_topdir)" || \
+       --define "_topdir $(lbuild_topdir)" 2>&1 || \
        fatal 1 "Error building Lustre rpms."
     # $MAKE_J "$MAKE_CC" || fatal 1 "Error building Lustre."
     popd >/dev/null
@@ -743,7 +754,7 @@ save_headers()
 
     KVERREL="${VERSION}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}"
     # deal with the kernel headers that are version specific
-    
+
     saveddir="$RPM_BUILD_ROOT/usr/src/linux-${KVERREL}/savedheaders/${TARGET_ARCH}/${TARGET_CONFIG:-up}"
     mkdir -p "$saveddir"
     install -m 644 include/linux/autoconf.h "$saveddir/autoconf.h"
@@ -792,7 +803,7 @@ longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kern
 options=$(getopt -o hj: -l "$longopts" -- "$@")
 
 eval set -- "$options"
-    
+
 while [ "$1" ] ; do
     case "$1" in
        '')
@@ -876,6 +887,11 @@ while [ "$1" ] ; do
             ;;
        --)
            shift
+            # there are actually some lustre configure flags that we need to
+            # handle ourselves (but we still give them to configure)
+            if [[ \ $@\  == *\ --disable-tests\ * ]]; then
+                LUSTRE_TESTS=false
+            fi
            CONFIGURE_FLAGS=$@
            break
            ;; 
@@ -904,7 +920,7 @@ if [ -n "$OFED_VERSION" ]; then
     if [ "$OFED_VERSION" = "inkernel" ]; then
        CONFIGURE_FLAGS="--with-o2ib=yes ${CONFIGURE_FLAGS}"
     else
-    build_kernel_ib
+        build_kernel_ib
     fi
 fi