Whamcloud - gitweb
LU-13178 build: Update ZFS version to 0.8.3
[fs/lustre-release.git] / contrib / lbuild / lbuild
index 6a1ab0a..5e19901 100755 (executable)
@@ -414,6 +414,14 @@ compare_version () {
     return 1
 }
 
+# Return a numeric version code based on a version string.  The version
+# code is useful for comparison two version strings to see which is newer.
+version_code() {
+    # split arguments like "0.8.0" into "0", "8", "0"
+    eval set -- $(tr "[:punct:]" " " <<< $*)
+    echo -n "$((($1 << 16) | ($2 << 8) | $3))"
+}
+
 uniqify() {
 
     echo $(echo "$*" | xargs -n 1 | sort -u)
@@ -613,7 +621,7 @@ download_ofed() {
                        # this is a work around for suse distro (sles11.3). what we need is
                        # sles11sp3. We really need to redesign how we use target and distro
                        [[ $distro_name =~ sles ]] && distro_name=${DISTRO/./sp}
-                       if [[ $arch = "aarch64" ]]; then
+                       if [[ $arch = "aarch64" ]] && [[ $DISTROMAJ < "rhel8" ]]; then
                                file="MLNX_OFED_LINUX-${ofed_version}-${distro_name}alternate-${arch}.tgz"
                        else
                                file="MLNX_OFED_LINUX-${ofed_version}-${distro_name}-${arch}.tgz"
@@ -788,7 +796,7 @@ unpack_ofed() {
                        # this is a work around for suse distro (sles11.3). what we need is
                        # sles11sp3. We really need to redesign how we use target and distro
                        [[ $distro_name =~ sles ]] && distro_name=${DISTRO/./sp}
-                       if [[ $arch = "aarch64" ]]; then
+                       if [[ $arch = "aarch64" ]] && [[ $DISTROMAJ < "rhel8" ]]; then
                                file="MLNX_OFED_LINUX-${ofed_version}-${distro_name}alternate-${arch}"
                        else
                                file="MLNX_OFED_LINUX-${ofed_version}-${distro_name}-${arch}"
@@ -808,7 +816,11 @@ unpack_ofed() {
                                return 1
                        fi
                        [ -d OFED ] || ln -sf MLNX_OFED_SRC-[0-9].[0-9]* OFED
-                       [ -d OFED_RPMS ] || ln -sf ${file}/RPMS OFED_RPMS
+                       if compare_version $ofed_version 4.7; then
+                               [ -d OFED_RPMS ] || ln -sf ${file}/RPMS OFED_RPMS
+                       else
+                               [ -d OFED_RPMS ] || ln -sf ${file}/RPMS/MLNX_LIBS OFED_RPMS
+                       fi
                        ;;
                ifs)
                        file="IntelIB-Basic.$(echo ${distro_name%%.*} | tr '[:lower:]' '[:upper:]')-${arch}.${ofed_version}"
@@ -1006,11 +1018,12 @@ build_spl_zfs() {
     # The spl/zfs spec files expect RPM_BUILD_ROOT to point to the root of the
     # destination for the rpms
     export RPM_BUILD_ROOT=$TOPDIR
-    SPLZFSVER=${SPLZFSVER:-0.7.13}
+    SPLZFSVER=${SPLZFSVER:-0.8.3}
     SPLZFSTAG=${SPLZFSTAG:-}
     # "spl zfs" prior to 0.8.0
     # "zfs" for 0.8.0 and later
-    SPLZFSPKGS="spl zfs"
+    (( $(version_code $SPLZFSVER) < $(version_code 0.8.0) )) &&
+        SPLZFSPKGS="spl zfs" || SPLZFSPKGS="zfs"
 
     # The files expect a kver to be set to the kernel version .
     local kver=$(find_linux_release)
@@ -1259,7 +1272,7 @@ build_kernel_ib() {
         rpm --define "_topdir ${TOPDIR}" -ivh $SOURCE
         SOURCE="${TOPDIR}/SPECS/${kib_prefix}.spec"
         local file ed_fragment1 ed_fragment2 n=1
-        for file in $(ls ${TOPDIR}/lustre/contrib/patches/ofed/*.patch); do
+        for file in $(ls ${TOPDIR}/lustre/contrib/patches/ofed/*.patch 2>/dev/null); do
             ed_fragment1="$ed_fragment1
 Patch$n: ${file%%*/}"
             ed_fragment2="$ed_fragment2
@@ -1267,7 +1280,7 @@ Patch$n: ${file%%*/}"
             cp $file ${TOPDIR}/SOURCES
             let n=$n+1
         done
-        for file in $(ls ${TOPDIR}/lustre/contrib/patches/ofed/*.ed); do
+        for file in $(ls ${TOPDIR}/lustre/contrib/patches/ofed/*.ed 2>/dev/null); do
             # Only apply the ed-scripts that should be used for the canonical target
             # ed-files in ${TOPDIR}/lustre/contrib/patches/ofed/ have to follow the naming
             # convention
@@ -1327,7 +1340,7 @@ EOF
                fi
                # now that we have the kernel rpms, we need to lib rpms too
                # we don't have to rebuild since MOFED include the binaries
-               cp -f OFED_RPMS/{libibmad-*,libibverbs-*,libibumad-*,librdmacm*,ibutils-*,opensm-*}.${TARGET_ARCH}.rpm \
+               cp -f OFED_RPMS/{libibmad-*,libibverbs-*,libibumad-*,librdmacm*,ibutils*,opensm-*}.${TARGET_ARCH}.rpm \
                        ${TOPDIR}/RPMS/${TARGET_ARCH} || \
                        fatal 1 "Failed to copy MOFED rpms"
                ;;
@@ -1480,6 +1493,8 @@ build_kernel_with_srpm() {
                                   sed -e '/_VERSION=/s/_[0-9]*_g.*$//g';
                                   cat "$FULL_PATCH";
                                   cat "$LBUILD_DIR/lbuild";
+                                 test -f lbuild-${DISTROMAJ%%[0-9]*} &&
+                                 cat lbuild-${DISTROMAJ%%[0-9]*};
                                   cat "$LBUILD_DIR/lbuild-$DISTROMAJ"; } |
                                 md5sum | cut -d" " -f1)
         # see if we can link to the reuse pool
@@ -1605,6 +1620,8 @@ build_ofed() {
                                   echo "$BUILD_GEN")";
                                   cat "${linux}/include/linux/autoconf.h";
                                   cat "$LBUILD_DIR/lbuild";
+                                 test -f lbuild-${DISTROMAJ%%[0-9]*} &&
+                                 cat lbuild-${DISTROMAJ%%[0-9]*};
                                   cat "$LBUILD_DIR/lbuild-$DISTROMAJ"; } |
                                 md5sum | cut -d" " -f1)
         # see if we can link to the reuse pool
@@ -1741,38 +1758,17 @@ build_with_srpm() {
                fi
        fi
 
-    # ~sigh~  have to make copies of and modify some of the rpm
-    # infrastructure files so that find-requires can find our unpacked
-    # kernel-devel artifacts
-    cp $RPM_HELPERS_DIR/{symset-table,find-requires{,.ksyms}} .
-    export FIND_REQUIRES="$(pwd)/find-requires"
-    chmod 755 {symset-table,find-requires{,.ksyms}}
-    local tmp="$(pwd)"
-    tmp="${tmp//\//\\/}"
-    ed find-requires <<EOF
-1a
-set -x
-.
-/|.*find-requires.ksyms/s/|/| bash -x/
-g/ [^ ]*\/\(find-requires\.ksyms\)/s// $tmp\/\1/g
-wq
-EOF
-    ed find-requires.ksyms <<EOF
-1a
-set -x
-.
-g/\/.*\/\(symset-table\)/s//$tmp\/\1/g
-g/\(\/usr\/src\/kernels\/\)/s//$tmp\/reused\1/g
-wq
-EOF
-    ed symset-table <<EOF
-1a
-set -x
-.
-g/\(\/boot\/\)/s//$tmp\/reused\1/g
-g/\(\/usr\/src\/kernels\/\)/s//$tmp\/reused\1/g
-wq
-EOF
+       # ~sigh~  have to make copies of and modify some of the rpm
+       # infrastructure files so that find-requires can find our unpacked
+       # kernel-devel artifacts
+       cp $RPM_HELPERS_DIR/{symset-table,find-requires{,.ksyms}} .
+       export FIND_REQUIRES="$(pwd)/find-requires"
+       chmod 755 {symset-table,find-requires{,.ksyms}}
+       local tmp="$(pwd)"
+       tmp="${tmp//\//\\/}"
+       sed -i "s/\/.*find-requires.ksyms/$tmp\/find-requires.ksyms/g" find-requires
+       sed -i "s/\/usr\/src\/kernels/$tmp\/reused\/usr\/src\/kernels/" find-requires.ksyms
+       sed -i "s/\/boot/$tmp\/reused\/boot/; s/\/usr\/src\/kernels/$tmp\/reused\/usr\/src\/kernels/" symset-table
 
        build_ofed "${LINUXOBJ:-$LINUX}" "$ofed_type" "$ofed_version" ||
         fatal 1 "error building OFED"