Whamcloud - gitweb
b=14949
[fs/lustre-release.git] / build / lbuild
index 33e9e20..372096c 100755 (executable)
@@ -174,7 +174,7 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
     pulling from CVS.
 
   --nodownload
-    Do not try to download a kernel from ftp.lustre.org
+    Do not try to download a kernel from downloads.lustre.org
 
   --nosrc
     Do not build a .src.rpm, a full kernel patch, or a patched kernel
@@ -377,11 +377,15 @@ download_and_build_tarball() {
 
     local srpm=kernel-${lnxmaj}-${lnxrel}.src.rpm
 
-    echo "Downloading http://ftp.lustre.org/pub/kernels/$target/old/$srpm..."
-    if ! wget -nv "http://ftp.lustre.org/pub/kernels/$target/old/$srpm" \
+    echo "Downloading http://downloads.lustre.org/public/kernels/$target/old/$srpm..."
+    if ! wget -nv "http://downloads.lustre.org/public/kernels/$target/old/$srpm" \
         -O "$KERNELDIR/$srpm" ; then
-        fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from ftp.lustre.org."
+        fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org."
     fi
+    [ -s "$KERNELDIR/$srpm" ] || {
+        rm -rf $KERNELDIR/$srpm
+        fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org."
+    }
 
     build_tarball $target $srpm
 }
@@ -420,16 +424,34 @@ load_target()
                 build_tarball $CANONICAL_TARGET $KERNEL_SRPM
             else
                 if (( $DOWNLOAD )) ; then
-                    echo "Downloading http://ftp.lustre.org/pub/kernels/$CANONICAL_TARGET/old/$KERNEL..."
-                    if ! wget -nv "http://ftp.lustre.org/pub/kernels/$CANONICAL_TARGET/old/$KERNEL" -O "$KERNELDIR/$KERNEL" ; then
+                    echo "Downloading http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL..."
+                    if ! wget -nv "http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL" -O "$KERNELDIR/$KERNEL" ; then
                         # see if we can do it with an SRPM from the download site
                         download_and_build_tarball $CANONICAL_TARGET $KERNEL_FILE
+                    else
+                        [ -s "$KERNELDIR/$KERNEL" ] || {
+                            rm -rf "$KERNELDIR/$KERNEL"
+                            fatal 1 "Target $TARGET's kernel $KERNEL not found in directory $KERNELDIR."
+                        }
                     fi
                 else
                     fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
                 fi
             fi
         fi
+        if [ -n "$OFED_VERSION" ] && \
+           [ ! -r "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ] ; then
+            if (( $DOWNLOAD )) ; then
+                local location="http://downloads.lustre.org/public/OFED/"
+                echo "Downloading $location/OFED-${OFED_VERSION}.tgz..."
+                if ! wget -nv "$location/OFED-${OFED_VERSION}.tgz" \
+                    -O "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ; then
+                    fatal 1 "Could not download OFED-${OFED_VERSION}.tgz from downloads.lustre.org."
+                fi
+            else
+                fatal 1 "OFED-${OFED_VERSION}.tgz not found in kernel directory $KERNELDIR."
+            fi
+        fi
     fi
 
     if [ "$SERIES" ] ; then
@@ -521,6 +543,15 @@ untar()
     tar $(tarflags "$1") "$1"
 }
 
+unpack_ofed()
+{
+    untar "$KERNELTREE/../OFED-${OFED_VERSION}.tgz"
+    [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED
+    pwd
+    ls -ld OFED OFED-[0-9].[0-9]*
+    ls -l OFED OFED-[0-9].[0-9]*
+}
+
 unpack_lustre()
 {
     DIRNAME="lustre-$TAG-$TIMESTAMP"
@@ -629,6 +660,7 @@ prep_kernel_build()
         -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
         -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
         -e "s^@KERNEL_EXTRA_VERSION_DELIMITER@^$EXTRA_VERSION_DELIMITER^g" \
+        -e "s^@KERNEL_TARGET_DELIMITER@^$TARGET_DELIMITER^g" \
         -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
         -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
         -e "s^@KERNEL_VERSION@^$VERSION^g" \
@@ -961,13 +993,14 @@ store_for_reuse()
 
 set_rpm_smp_type()
 {
+    local infact_arch=${TARGET_ARCH}
     RPMSMPTYPE=default
+    [ "$infact_arch" == "i586" ] && infact_arch="i686"
     for smp_type in $SMP_ARCHS; do
-        [ $TARGET_ARCH == $smp_type ] && RPMSMPTYPE=smp && break
+        [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break
     done
-
     for smp_type in $BIGSMP_ARCHS; do
-        [ $TARGET_ARCH == $smp_type ] && RPMSMPTYPE=bigsmp && break
+        [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break
     done
 }
 
@@ -1024,7 +1057,20 @@ unpack_linux_rpm()
                 LINUXOBJ="$(pwd)/$src/$objects"
             fi
         done
-        [ -z "$LINUX" ] && RC=255
+        if [ -z "$LINUX" ]; then
+            RC=255
+        else
+            # dig out the release version
+            local LINUXRELEASEHEADER=version.h
+            if test -s ${LINUXOBJ:-$LINUX}/include/linux/utsrelease.h ; then
+                LINUXRELEASEHEADER=utsrelease.h
+            fi
+            LINUXRELEASE=$(sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' ${LINUXOBJ:-$LINUX}/include/linux/$LINUXRELEASEHEADER)
+            if [ -z "$LINUXRELEASE" ]; then
+                echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}/include/linux/$LINUXRELEASEHEADER"
+                RC=255
+            fi
+        fi
     else
         RC=255
     fi
@@ -1190,6 +1236,41 @@ build_linux()
     return
 }
 
+build_kernel_ib()
+{
+    # build kernel-ib{,-devel}
+    # some I/B drivers are architecture dependent and kernel-ib's configure
+    # does not figure it out for us ~sigh~
+    local configure_options=""
+    case "$TARGET_ARCH" in
+       x86_64 | ia64)
+           configure_options="--with-ipath_inf-mod"
+           ;;
+       ppc64)
+           configure_options="--with-ipath_inf-mod --with-ehca-mod"
+           ;;
+    esac
+    $RPMBUILD --rebuild --define 'build_kernel_ib 1' --define 'build_kernel_ib_devel 1' \
+             --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
+             --define "KVERSION ${LINUXRELEASE}" \
+             --define "KSRC ${LINUXOBJ:-${LINUX}}" \
+             --define "LIB_MOD_DIR /lib/modules/${LINUXRELEASE}/updates" \
+             --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" ${TOPDIR}/OFED/SRPMS/ofa_kernel-${OFED_VERSION}-ofed${OFED_VERSION}.src.rpm
+
+    if [ ${PIPESTATUS[0]} != 0 ]; then
+        fatal 1 "Error building kernel-ib"
+    fi
+
+    pushd "$TOPDIR" >/dev/null
+    rm -rf kernel-ib-devel
+    mkdir kernel-ib-devel
+    cd kernel-ib-devel
+    local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${OFED_VERSION}-${LINUXRELEASE//-/_}.*.rpm)
+    rpm2cpio -itv < $rpm | cpio -id
+    CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
+    popd >/dev/null
+}
+
 #build patchless lustre
 patchless_build_sequence()
 {
@@ -1204,28 +1285,26 @@ patchless_build_sequence()
     fi
     [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
 
-    local type=
-    local delimiter=
+    local delimiter=${EXTRA_VERSION_DELIMITER:-"-"}
+    # default to source type -source and special case below
+    local type=-source
     case "$DISTRO" in
         rhel*)
             type=-devel
-            delimiter=-
-            ;;
-        sles10)
-            type=-source
-            delimiter=.
-            ;;
-        sles9)
-            type=-source
-            delimiter=-
-            ;;
-        *)
-            echo "Don't know what to do with $DISTRO"
-            return 255
             ;;
     esac
 
     unpack_linux_rpm $type $delimiter && rpmfound=true
+
+    [ -d SRPMS ] || mkdir SRPMS
+    [ -d RPMS ] || mkdir RPMS
+    [ -d BUILD ] || mkdir BUILD
+    [ -d SOURCES ] || mkdir SOURCES
+
+    # first build kernel-ib
+    if [ -n "$OFED_VERSION" ]; then
+        $rpmfound && build_kernel_ib
+    fi
     ( $rpmfound ) && build_lustre && buildsuccess=true && find_linux_source_rpm
 
     if $buildsuccess; then
@@ -1542,6 +1621,10 @@ unpack_lustre
 load_target
 EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"}
 
+if [ -n "$OFED_VERSION" ]; then
+    unpack_ofed
+fi
+
 build_success=false
 if $PATCHLESS; then
     patchless_build_sequence && build_success=true