Whamcloud - gitweb
b=20617
authorbrian <brian>
Wed, 18 Nov 2009 13:36:13 +0000 (13:36 +0000)
committerbrian <brian>
Wed, 18 Nov 2009 13:36:13 +0000 (13:36 +0000)
i=wangyb
i=yangsheng

Build the RDAC and mptlinux drivers with the Lustre kernel in lbuild.

build/autoMakefile.am.toplevel
build/lbuild
build/mptlinux.spec.patch [new file with mode: 0644]
build/rdac_spec [new file with mode: 0644]

index f2064fa..0549cb7 100644 (file)
@@ -104,7 +104,8 @@ EXTRA_DIST = @PACKAGE_TARNAME@.spec                                 \
        build/sles8-update_INITRD_MODULES.sh                            \
        build/sles8-update_rcfile_setting.sh build/update_oldconfig     \
        build/autoconf/lustre-build-linux.m4                            \
-       build/autoconf/lustre-build.m4
+       build/autoconf/lustre-build.m4 build/rdac_spec                  \
+       build/mptlinux.spec.patch
 
 rpms-real: @PACKAGE_TARNAME@.spec dist Makefile
        rpmbuild -ta $(distdir).tar.gz
index 4286fd4..8930c91 100755 (executable)
@@ -64,6 +64,11 @@ BIGSMP_ARCHS=
 PSERIES64_ARCHS=
 UP_ARCHS=
 
+# these should likely come from the target files too
+RDAC_VERSION="09.03.0C02.0013"
+MPTLINUX_VERSION="4.16.00.00-2"
+
+
 # not in the target file any more
 CONFIG=
 
@@ -433,6 +438,56 @@ download_ofed() {
 
 }
 
+download_rdac() {
+    local force="${1:-false}"
+
+    if [ -n "$RDAC_VERSION" -a "$RDAC_VERSION" != "inkernel" ] &&
+       ( $force || [ ! -r "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz" ] ||
+           [ ! -s "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz" ] ); then
+        if $DOWNLOAD; then
+            local location="http://downloads.lustre.org/public/RDAC/"
+            echo "Downloading $location/rdac-LINUX-${RDAC_VERSION}-source.tar.gz..."
+            if ! wget -nv "$location/rdac-LINUX-${RDAC_VERSION}-source.tar.gz" \
+                -O "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz" ||
+               [ ! -s "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz" ]; then
+                rm -f $KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz
+                fatal 1 "Could not download rdac-LINUX-${RDAC_VERSION}-source.tar.gz" \
+                        "from downloads.lustre.org."
+            fi
+        else
+            fatal 1 "rdac-LINUX-${RDAC_VERSION}-source.tar.gz not found in kernel" \
+                    "directory $KERNELTREE."
+        fi
+    fi
+
+    return 0
+}
+
+download_mptlinux() {
+    local force="${1:-false}"
+
+    if [ -n "$MPTLINUX_VERSION" -a "$MPTLINUX_VERSION" != "inkernel" ] &&
+       ( $force || [ ! -r "$KERNELTREE/MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip" ] ||
+           [ ! -s "$KERNELTREE/MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip" ] ); then
+        if $DOWNLOAD; then
+            local location="http://downloads.lustre.org/public/MPTLINUX/"
+            echo "Downloading $location/MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip..."
+            if ! wget -nv "$location/MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip" \
+                -O "$KERNELTREE/MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip" ||
+               [ ! -s "$KERNELTREE/MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip" ]; then
+                rm -f $KERNELTREE/MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip
+                fatal 1 "Could not download MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip" \
+                        "from downloads.lustre.org."
+            fi
+        else
+            fatal 1 "MPTLINUX_RHEL5_SLES10_PH15-${MPTLINUX_VERSION}.zip not found in kernel" \
+                    "directory $KERNELTREE."
+        fi
+    fi
+
+    return 0
+}
+
 load_target() {
 
     EXTRA_VERSION_save="$EXTRA_VERSION"
@@ -576,6 +631,24 @@ unpack_ofed() {
 
 }
 
+unpack_rdac() {
+
+    if ! untar "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz"; then
+        return 1
+    fi
+    [ -d rdac-LINUX ] || ln -sf rdac-LINUX-[0-9][0-9].* rdac-LINUX
+
+}
+
+unpack_mptlinux() {
+
+    if ! unzip -p $KERNELTREE/MPTLINUX_RHEL5_SLES10_PH15-4.16.00.00-2.zip | tar xzvf - srpms-2/mptlinux-4.16.00.00-2.src.rpm; then
+        return 1
+    fi
+    mv srpms-2/mptlinux-4.16.00.00-2.src.rpm .
+
+}
+
 unpack_lustre() {
 
     if [ -z "$LUSTRE" ]; then
@@ -644,23 +717,25 @@ do_patch_linux() {
 }
 
 build_lustre() {
+    local linux="$1"
+    local linuxobj="$2"
 
     cp "$LUSTRE" SOURCES
 
     pushd lustre >/dev/null
 
     echo "Building Lustre RPMs for: $BUILD_ARCHS..."
-    targets=
+    local targets arch
     for arch in $BUILD_ARCHS; do
         targets="--target $arch $targets"
     done
 
-    local confoptions="--with-linux=${LINUX}"
+    local confoptions="--with-linux=${linux}"
     if $PATCHLESS; then
-        confoptions="--with-linux=${LINUX} --disable-server"
+        confoptions="--with-linux=${linux} --disable-server"
     fi
-    if [ ! "$LINUXOBJ" = "" ]; then
-        confoptions="$confoptions --with-linux-obj=${LINUXOBJ}"
+    if [ "$linuxobj" != "" ]; then
+        confoptions="$confoptions --with-linux-obj=${linuxobj}"
     fi
 
     ./configure $confoptions ${CONFIGURE_FLAGS}
@@ -1044,7 +1119,7 @@ reuse() {
     if [ -n "$REUSEBUILD" ] && [ -d "$REUSEBUILD/$signature/$module" ]; then
         if [ ! -f "$REUSEBUILD/$signature/$module/.lastused" ]; then
             # the .lastused flag is populated at the end of the caching to
-            # signal that the caching was completeld.  if that flag is not
+            # signal that the caching was completed.  if that flag is not
             # there, then the cache is invalid (and should be removed in fact) 
             mv "$REUSEBUILD/$signature/$module"{,-bad-$(date +%s)} || 
                 fatal 1 "failed to clean up a bad cache in location" \
@@ -1214,54 +1289,146 @@ build_kernel_with_srpm() {
 
 }
 
-build_with_srpm() {
+build_mptlinux() {
+    local LINUX="$1"
 
-    if ! $PATCHLESS; then
-        local kernel_extra_version
-        if ! kernel_extra_version=$(build_kernel_with_srpm); then
-            fatal 1 "Failed to build the kernel from it's SRPM"
+    local targets arch
+    for arch in $BUILD_ARCHS; do
+        targets="--target $arch $targets"
+    done
+
+    local rpmbuildopt='-bb'
+    if $NORPM; then
+        rpmbuildopt='-bc'
+        echo NORPM mode. Only compiling.
         fi
 
+    # if only we could just rebuild the src.rpm.  but the included spec
+    # is a real pig's breakfast.  just check out the patch we need to
+    # apply to it to make it useful.
+    #$RPMBUILD --rebuild \
+    #          --define "_topdir ${TOPDIR}" --target ${TARGET_ARCH} \
+    #          ${TOPDIR}/mptlinux-*.src.rpm
+    rpm -ivh --define "_topdir ${TOPDIR}" ${TOPDIR}/mptlinux-*.src.rpm
+
+    # now the big honkin' patch to the spec file
+    pushd ${TOPDIR}/SPECS
+    # to regen this patch use:
+    # !!cd ~/rpm/SPECS/ && diff -u mptlinux.spec{.dist,}
+    patch -p0 < ${TOPDIR}/lustre/build/mptlinux.spec.patch || fatal 1 "failed to patch mptlinux.spec"
+    popd
+
+    local targets arch
         for arch in $BUILD_ARCHS; do
+        targets="--target $arch $targets"
+    done
 
-            local kernel_devel_rpm
-            if ! kernel_devel_rpm=$(find_rpm "$TOPDIR/RPMS/$arch/" provides "^$(devel_kernel_name $KERNEL_LUSTRE_NAMING) ="); then
-                fatal 1 "Failed to find a kernel development RPM in $TOPDIR/RPMS/$arch/"
+    local rpmbuildopt='-bb'
+    if $NORPM; then
+        rpmbuildopt='-bc'
+        echo NORPM mode. Only compiling.
             fi
 
-            # install the -devel RPM in preparation for the lustre build
-            # note that the EXTRA_VERSION_DELIMITER is *NOT* used in the
-            # version of the directory name under /usr/src
-            if ! lnxrel="$kernel_extra_version" unpack_linux_devel_rpm \
-                           "$TOPDIR/RPMS/$arch/$kernel_devel_rpm" "-"; then
-                fatal 1 "Could not find the Linux tree in $TOPDIR/RPMS/$arch/$kernel_devel_rpm"
+    if ! $RPMBUILD $targets $rpmbuildopt \
+                  --define "_tmppath /var/tmp" \
+                  --define "_topdir ${TOPDIR}" \
+                  --define "kernel_obj $LINUX" \
+                  ${TOPDIR}/SPECS/mptlinux.spec; then
+        return 1
+    fi
+    if $DO_SRC; then
+        if ! $RPMBUILD -bs \
+                      --define "_tmppath /var/tmp" \
+                      --define "_topdir ${TOPDIR}" \
+                      --define "kernel_obj $LINUX" \
+                      ${TOPDIR}/SPECS/mptlinux.spec; then
+            return 1
+        fi
             fi
+
+    return 0
+
+}
+
+# build RDAC
+build_rdac() {
+    local LINUX="$1"
+
+    # note that we use an _, not a . before the spec on purpose.  we are not
+    # allowed to have more than one file with a .spec trailer in a tarball
+    # that is supposed to be usable with rpmbuild
+    cp lustre/build/rdac_spec ${TOPDIR}/SPECS/rdac.spec || fatal 1 "Could not find rdac.spec in lustre/build" 
+
+    local targets arch
+    for arch in $BUILD_ARCHS; do
+        targets="--target $arch $targets"
         done
-    else
-        # need to find and unpack the vendor's own kernel-devel for patchless
-        # client build
-        local kernelrpm
-        if ! kernelrpm=$(find_linux_rpm "-$DEVEL_KERNEL_TYPE" ${EXTRA_VERSION_DELIMITER:-"-"}); then
-            fatal 1 "Could not find the kernel-$DEVEL_KERNEL_TYPE RPM in ${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
+
+    local rpmbuildopt='-bb'
+    if $NORPM; then
+        rpmbuildopt='-bc'
+        echo NORPM mode. Only compiling.
         fi
-        if ! lnxrel="$lnxrel" unpack_linux_devel_rpm "$kernelrpm" "-"; then
-            fatal 1 "Could not find the Linux tree in $kernelrpm"
+
+    local distro
+    case $DISTRO in
+     rhel5)     distro="REDHAT"
+                ;;
+    sles1*)     distro="SUSE"
+                ;;
+         *)     echo "$DISTRO not supported by RDAC, skipping"
+                return 0
+                ;;
+    esac
+    if ! $RPMBUILD $targets $rpmbuildopt --define "dist $distro" \
+                  --define "_tmppath /var/tmp" \
+                  --define "_topdir ${TOPDIR}" \
+                  --define "kernel_obj $LINUX" \
+                  ${TOPDIR}/SPECS/rdac.spec; then
+        return 1
         fi
+    if $DO_SRC; then
+        if ! $RPMBUILD -bs --define "dist $distro" \
+                      --define "_tmppath /var/tmp" \
+                      --define "_topdir ${TOPDIR}" \
+                      --define "kernel_obj $LINUX" \
+                      ${TOPDIR}/SPECS/rdac.spec; then
+            return 1
+    fi
     fi
 
+    return 0
+}
+
+# build OFED
+# globals used:
+#    TOPDIR
+#    REUSEBUILD, REUSERPM
+#    CONFIGURE_FLAGS
+
+build_ofed() {
+    local linux="$1"
+    local ofed_version="$2"
+
     # before lustre, build kernel-ib
-    if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
+    if [ -n "$ofed_version" -a "$ofed_version" != "inkernel" ]; then
+        if [ -n "$REUSEBUILD" ]; then
         # see if we can link to the reuse pool
-        # XXX - hrm.  i'm not convinced this doesn't belong in the reuse "library"
+            # XXX - hrm.  i'm not convinced this doesn't belong in the reuse
+            #       "library"
         local CAN_LINK_FOR_REUSE=false
         touch $REUSEBUILD/$$
         if cp -al $REUSEBUILD/$$ $TOPDIR/; then
             CAN_LINK_FOR_REUSE=true
         fi
         rm $REUSEBUILD/$$
+        fi
 
-        local REUSE_SIGNATURE=$({ echo "$OFED_VERSION"; echo "$(find_linux_release ${LINUXOBJ:-$LINUX})"; cat "${LINUXOBJ:-${LINUX}}/include/linux/autoconf.h"; } | md5sum | cut -d" " -f1)
-        if ! reuse ofed "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
+        local REUSE_SIGNATURE=$({ echo "$ofed_version";
+                                  echo "$(find_linux_release ${linux})";
+                                  cat "${linux}/include/linux/autoconf.h"; } |
+                                md5sum | cut -d" " -f1)
+        if ! $REUSERPM || ! reuse ofed "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
                         "$REUSE_SIGNATURE"; then
             # stash away the existing built articles for a moment
             mkdir bak
@@ -1292,19 +1459,63 @@ build_with_srpm() {
         cd kernel-ib-devel
         # the actual ofed RPMs don't have the -rc$n or -$date string appened that
         # might be present on the file
-        local ofed_version=$(echo $OFED_VERSION |
+        local linuxrelease=$(find_linux_release "$linux")
+        ofed_version=$(echo $ofed_version |
                          sed -re 's/-(20[0-9]{6,6}-[0-9]{4,4}|rc[0-9]*)$//')
-        local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${ofed_version}-${LINUXRELEASE//-/_}.*.rpm)
+        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
     fi
 
+}
+
+build_with_srpm() {
+
+    if ! $PATCHLESS; then
+        local kernel_extra_version
+        if ! kernel_extra_version=$(build_kernel_with_srpm); then
+            fatal 1 "Failed to build the kernel from it's SRPM"
+        fi
+
+        for arch in $BUILD_ARCHS; do
+
+            local kernel_devel_rpm
+            if ! kernel_devel_rpm=$(find_rpm "$TOPDIR/RPMS/$arch/" provides "^$(devel_kernel_name $KERNEL_LUSTRE_NAMING) ="); then
+                fatal 1 "Failed to find a kernel development RPM in $TOPDIR/RPMS/$arch/"
+            fi
+
+            # install the -devel RPM in preparation for the lustre build
+            # note that the EXTRA_VERSION_DELIMITER is *NOT* used in the
+            # version of the directory name under /usr/src
+            if ! lnxrel="$kernel_extra_version" unpack_linux_devel_rpm \
+                           "$TOPDIR/RPMS/$arch/$kernel_devel_rpm" "-"; then
+                fatal 1 "Could not find the Linux tree in $TOPDIR/RPMS/$arch/$kernel_devel_rpm"
+            fi
+        done
+    else
+        # need to find and unpack the vendor's own kernel-devel for patchless
+        # client build
+        local kernelrpm
+        if ! kernelrpm=$(find_linux_rpm "-$DEVEL_KERNEL_TYPE" ${EXTRA_VERSION_DELIMITER:-"-"}); then
+            fatal 1 "Could not find the kernel-$DEVEL_KERNEL_TYPE RPM in ${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
+        fi
+        if ! lnxrel="$lnxrel" unpack_linux_devel_rpm "$kernelrpm" "-"; then
+            fatal 1 "Could not find the Linux tree in $kernelrpm"
+        fi
+    fi
+
+    build_ofed "${LINUXOBJ:-$LINUX}" "$OFED_VERSION" || fatal 1 "error building OFED"
+
+    build_rdac "${LINUXOBJ:-$LINUX}" || fatal 1 "error building RDAC"
+
+    build_mptlinux "${LINUX}" || fatal 1 "error building mptlinux"
+
     # now build Lustre
-    if build_lustre; then
+    if build_lustre "$LINUX" "$LINUXOBJ"; then
         # the build worked.  resolve any symlinked files (i.e. from reuse)
         # in RPMS/$arch to real files so that that that huge mess of
-        # complication knows as LTS can copy them yet somewhere else.
+        # complication known as LTS can copy them yet somewhere else.
         # is it any wonder this whole process is so damn so?  anyone ever
         # heard of hardlinks?  it this cool new thing that allows you save
         # tons of time and space by creating... well you can go read about
@@ -1579,15 +1790,33 @@ if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
     unpack_ofed || fatal 1 "Error unpacking OFED tarball"
 fi
 
+if [ -n "$MPTLINUX_VERSION" -a "$MPTLINUX_VERSION" != "inkernel" ]; then
+    download_mptlinux
+    unpack_mptlinux || fatal 1 "Error unpacking MPTLINUX distribution"
+fi
+
+unpack_mptlinux || fatal 1 "Error unpacking mptlinux"
+
 # make sure the RPM build environment is set up
 create_rpmbuild_dirs
 
+if [ -n "$RDAC_VERSION" -a "$RDAC_VERSION" != "inkernel" ]; then
+    download_rdac
+    # we don't actually need to unpack this.  just put it in the SOURCES dir
+    #unpack_rdac || fatal 1 "Error unpacking RDAC tarball"
+    cp "$KERNELTREE/rdac-LINUX-${RDAC_VERSION}-source.tar.gz" ${TOPDIR}/SOURCES/ ||
+        fatal 1 "Error copying RDAC source tarball to RPM SOURCES dir"
+fi
+
 trap '[ -n "$CCACHE" ] && ccache -s' EXIT
 
 # if an unpacked kernel source tree was given on the command line
 # just build lustre with it (nothing distro kernel specific here)
 if [ -n "$LINUX" ]; then
-    build_lustre
+    build_mptlinux "${LINUX}" || fatal 1 "error building mptlinux"
+    build_ofed "${LINUX}" "$OFED_VERSION" || fatal 1 "error building OFED"
+    build_rdac "${LINUX}" || fatal 1 "error building RDAC"
+    build_lustre "$LINUX" "$LINUXOBJ"
 else
     if [ -f "${0%/*}/lbuild-$DISTRO" ]; then
         seen_list=$(new_list)
diff --git a/build/mptlinux.spec.patch b/build/mptlinux.spec.patch
new file mode 100644 (file)
index 0000000..a83c818
--- /dev/null
@@ -0,0 +1,434 @@
+--- mptlinux.spec.dist 2008-11-07 02:16:26.000000000 -0500
++++ mptlinux.spec      2009-10-28 12:10:05.000000000 -0400
+@@ -1,13 +1,15 @@
++%{!?kernel_obj: %define kernel_obj ""}
++
+ %define name mptlinux
+ %define version 4.16.00.00
+-%define release 2
+-Summary: MPT Fusion drivers for 53C1030, FC9XX, and SAS Adapters
++%define release 2sun1
++Summary: Common files for the MPT Fusion drivers for 53C1030, FC9XX, and SAS Adapters
+ Name: %{name}
+ Version: %{version}
+ Release: %{release}
+ Vendor: LSI Logic
+ License: GPL
+-Group: System Environment/Kernel
++Group: Utilities/System
+ Source0: %{name}-%{version}.tar.gz
+ Source1: fusion.mptctl
+ URL: http://www.lsilogic.com
+@@ -22,228 +24,284 @@
+ Fibre Channel FC909, FC919, FC929, FC919X, FC929X, and FC949X adapters
+ SAS SAS1064, SAS1068, and SAS1078 adapters.
++This package contains the common file(s).
++
++%package modules
++Summary: Kernel modules for the MPT Fusion drivers for 53C1030, FC9XX, and SAS Adapters
++Group: System Environment/Kernel
++Requires: mptlinux
++
++%description modules
++Drivers for (suse i686, x86_64, ia64 and updates) for the
++LSI Logic Fusion-MPT Architecture parts.
++These include the Ultra320 53C1030 and 53C1020 adapters.
++Fibre Channel FC909, FC919, FC929, FC919X, FC929X, and FC949X adapters
++SAS SAS1064, SAS1068, and SAS1078 adapters.
++
++This package contains the drivers.
++
+ # prep #########################################################################
+ %prep
++#exit 0
+ echo prep %{version}
+-%setup -c -b 0
++%setup -c
+ # build ########################################################################
+ %build
++#exit 0
+ echo build %{version}
++if [ "%{kernel_obj}" != "" ]; then
++      # dig the version out of the tree
++        LINUXRELEASEHEADER=%{kernel_obj}/include/linux/version.h
++        if [ -s %{kernel_obj}/include/linux/utsrelease.h ]; then
++            LINUXRELEASEHEADER=%{kernel_obj}/include/linux/utsrelease.h
++        fi
++        LINUXRELEASE=$(sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER)
++
++      make build LINUX=%{kernel_obj} KERNEL=$LINUXRELEASE
++else
+ for i in /lib/modules/2.6.*; do
+-      kernel=`basename ${i}`;
++      kernel=`basename ${i}`
+       if [ -f /lib/modules/${kernel}/source/drivers/message/fusion/Kconfig ]; then
+-              make build KERNEL=$kernel;
+-      fi;
+-done;
++              make build KERNEL=$kernel
++      fi
++done
++fi
+ # install ######################################################################
+ %install
+ echo install %{version}
+ echo "%defattr(-,root,root)" > $RPM_BUILD_DIR/file.list.%{name}
++echo "%defattr(-,root,root)" > $RPM_BUILD_DIR/file.list.%{name}-modules
+ echo "/etc/init.d/fusion.mptctl" >> $RPM_BUILD_DIR/file.list.%{name}
+ mkdir -p $RPM_BUILD_ROOT/etc/init.d
+-cp -rf $RPM_SOURCE_DIR/fusion.mptctl $RPM_BUILD_ROOT/etc/init.d
++cp -f $RPM_SOURCE_DIR/fusion.mptctl $RPM_BUILD_ROOT/etc/init.d
++if [ "%{kernel_obj}" != "" ]; then
++      # dig the version out of the tree
++        LINUXRELEASEHEADER=%{kernel_obj}/include/linux/version.h
++        if [ -s %{kernel_obj}/include/linux/utsrelease.h ]; then
++            LINUXRELEASEHEADER=%{kernel_obj}/include/linux/utsrelease.h
++        fi
++        kernel="$(sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER)"
++
++      #if [ ! -e /lib/modules/${kernel}/source/drivers/message/fusion/Kconfig ]; then
++      #       continue
++      #fi
++      MPTLINUX_IPATH=/lib/modules/${kernel}/updates/drivers/message/fusion
++      mkdir -p $RPM_BUILD_ROOT/lib/modules/${kernel}/{kernel,updates}/drivers/message/fusion
++
++      # create the file list used in %files to indicate which files are in package
++      for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
++              echo "$MPTLINUX_IPATH/${driver_name}" >> $RPM_BUILD_DIR/file.list.%{name}-modules
++      done
++
++      make install PREFIX=$RPM_BUILD_ROOT LINUX=%{kernel_obj} KERNEL=$kernel
++      # the Makefile hardcodes the destination path to
++      # $(PREFIX)/lib/modules/$(KERNEL)/kernel/drivers/message/fusion
++      # so lets move these to where they really go
++      # ideally, the Makefile should take this location as an (optional if you
++      # wish) argument
++      mv -f $RPM_BUILD_ROOT/lib/modules/${kernel}/kernel/drivers/message/fusion/* \
++            $RPM_BUILD_ROOT/$MPTLINUX_IPATH/
++else
+ for i in /lib/modules/2.6.*; do
+       kernel=`basename ${i}`
+       if [ ! -e /lib/modules/${kernel}/source/drivers/message/fusion/Kconfig ]; then
+-              continue;
+-      fi;
+-      MPTLINUX_IPATH=/lib/modules/${kernel}/kernel/drivers/message/fusion
+-      mkdir -p $RPM_BUILD_ROOT/lib/modules/${kernel}/kernel/drivers/message/fusion
++              continue
++      fi
++      MPTLINUX_IPATH=/lib/modules/${kernel}/updates/drivers/message/fusion
++      mkdir -p $RPM_BUILD_ROOT/lib/modules/${kernel}/{kernel,updates}/drivers/message/fusion
+       # create the file list used in %files to indicate which files are in package
+       for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
+-              echo "$MPTLINUX_IPATH/${driver_name}.new" >> $RPM_BUILD_DIR/file.list.%{name}
+-      done;
++              echo "$MPTLINUX_IPATH/${driver_name}" >> $RPM_BUILD_DIR/file.list.%{name}-modules
++      done
+       make install PREFIX=$RPM_BUILD_ROOT KERNEL=$kernel
+-
+-      for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
+-              mv -f $RPM_BUILD_ROOT/$MPTLINUX_IPATH/${driver_name} \
+-                      $RPM_BUILD_ROOT/$MPTLINUX_IPATH/${driver_name}.new
+-      done;
+-done;
++      # the Makefile hardcodes the destination path to
++      # $(PREFIX)/lib/modules/$(KERNEL)/kernel/drivers/message/fusion
++      # so lets move these to where they really go
++      # ideally, the Makefile should take this location as an (optional if you
++      # wish) argument
++      mv -f $RPM_BUILD_ROOT/lib/modules/${kernel}/kernel/drivers/message/fusion/* \
++            $RPM_BUILD_ROOT/$MPTLINUX_IPATH/
++done
++fi
+ # pre #########################################################################
+-%pre
++%pre modules
+ echo pre %{version}
+ system_arch=`uname -m`
+ if [ -f /etc/SuSE-release ] && [ ${system_arch} == i686 ]; then
+-      system_arch=i586;
+-fi;
++      system_arch=i586
++fi
+ if [ %{_target_cpu} != ${system_arch} ]; then
+       echo "ERROR: Failed installing this rpm!!!!"
+-      echo "This rpm is intended for %{_target_cpu} platform. It seems your system is ${system_arch}.";
+-      exit 1;
+-fi;
++      echo "This rpm is intended for %{_target_cpu} platform. It seems your system is ${system_arch}."
++      exit 1
++fi
+ # post #########################################################################
+-%post
++%post modules
+ echo post %{version}
+ chkconfig fusion.mptctl --add >/dev/null 2>&1
+ if [ -f /etc/redhat-release ]; then
+       # RHEL 4
+-      if [ -f /etc/modprobe.conf ] ; then
+-              cp /etc/modprobe.conf /etc/modprobe.conf.orig.%{version};
+-              sed -e '/mptbase/d' /etc/modprobe.conf > modprobe.edit;
+-              sed -e '/mptscsih/d' modprobe.edit > modprobe.edit.1;
+-              sed -e '/mptspi/d' modprobe.edit.1 > modprobe.edit.2;
+-              sed -e '/mptfc/d' modprobe.edit.2 > modprobe.edit.3;
+-              sed -e '/mptsas/d' modprobe.edit.3 > modprobe.edit;
+-              echo "alias scsi_hostadapter mptspi" >> modprobe.edit;
+-              echo "alias scsi_hostadapter1 mptfc" >> modprobe.edit;
+-              echo "alias scsi_hostadapter2 mptsas" >> modprobe.edit;
+-              mv -f modprobe.edit /etc/modprobe.conf;
+-              rm -fr modprobe.edit.*;
+-      fi;
++      # per the comments below, i can't see any modprobe.conf editing here that's
++      # valid
++      #if [ -f /etc/modprobe.conf ] ; then
++      #       cp /etc/modprobe.conf /etc/modprobe.conf.orig.mptlinux-%{version}
++              # i don't think this is kosher.  what sort of entries are
++              # being deleted here?
++              #sed -e '/mptbase/d' -e '/mptscsih/d' -e '/mptspi/d' \
++              #    -e '/mptfc/d' -e '/mptsas/d' /etc/modprobe.conf > /etc/modprobe.edit
++              # this really isn't kosher.  you can't assume that the
++              # administrator has not already defined the scsi_hostadapter
++              # aliases for some other HBA that's already in the system
++              #echo "alias scsi_hostadapter mptspi" >> /etc/modprobe.edit
++              #echo "alias scsi_hostadapter1 mptfc" >> /etc/modprobe.edit
++              #echo "alias scsi_hostadapter2 mptsas" >> /etc/modprobe.edit
++              #mv -f /etc/modprobe.edit /etc/modprobe.conf
++      #fi
+ elif [ -f /etc/SuSE-release ]; then
+       # SLES 9
+       if [ -f /etc/sysconfig/kernel ] ; then
+-              cp /etc/sysconfig/kernel /etc/sysconfig/kernel.orig.%{version};
+-              sed -e 's/mptscsih//g' /etc/sysconfig/kernel > kernel.edit;
+-              sed -e 's/mptsas//g' kernel.edit > kernel.edit.1;
+-              sed -e 's/mptfc//g' kernel.edit.1 > kernel.edit.2;
+-              sed -e 's/mptspi//g' kernel.edit.2 > kernel.edit.3;
+-              sed -e 's/INITRD_MODULES="/INITRD_MODULES="mptsas /g' kernel.edit.3 > kernel.edit.4;
+-              sed -e 's/INITRD_MODULES="/INITRD_MODULES="mptfc /g' kernel.edit.4 > kernel.edit.5;
+-              sed -e 's/INITRD_MODULES="/INITRD_MODULES="mptspi /g' kernel.edit.5 > kernel.edit;
+-              mv -f kernel.edit /etc/sysconfig/kernel;
+-              rm -fr kernel.edit.*;
+-      fi;
++              cp /etc/sysconfig/kernel /etc/sysconfig/kernel.orig.mptlinux-%{version}
++              sed -e 's/mptscsih//g' -e 's/mptsas//g' -e 's/mptfc//g' \
++                  -e 's/mptspi//g' \
++                  -e 's/INITRD_MODULES="/INITRD_MODULES="mptsas /g' \
++                  -e 's/INITRD_MODULES="/INITRD_MODULES="mptfc /g' \
++                  -e 's/INITRD_MODULES="/INITRD_MODULES="mptspi /g' \
++                  /etc/sysconfig/kernel > /etc/sysconfig/kernel.edit
++              mv -f /etc/sysconfig/kernel.edit /etc/sysconfig/kernel
++      fi
+ fi
+ # adding device nodes
+ if [ ! -e /dev/mptctl ]; then
+-      echo "Creating /dev/mptctl ioctl node file";
+-      mknod /dev/mptctl c 10 220;
+-fi;
++      echo "Creating /dev/mptctl ioctl node file"
++      mknod /dev/mptctl c 10 220
++fi
++# i think this is wrong.  we should not muck around with kernels we did not
++# install new drivers into.  but how to determine which kernels those are?
++# maybe look for the new driver in the /lib/modules/*/updates tree?
+ for i in /lib/modules/2.6.*; do
+-      kernel=`basename ${i}`;
+-      MPTLINUX_IPATH=/lib/modules/${kernel}/kernel/drivers/message/fusion
+-      if [ ! -e $MPTLINUX_IPATH/mptbase.ko ] || \
+-          [ ! -e $MPTLINUX_IPATH/mptbase.ko.new ]; then
+-              continue;
+-      fi;
++      kernel=`basename ${i}`
+       if [ -f /etc/SuSE-release ] &&
+           [ ! -e /boot/initrd-${kernel} ]; then
+-              continue;
+-      fi;
++              continue
++      fi
+-      echo "The mpt driver for kernel ${kernel} is now version 4.16.00.00";
+-      #backup original fusion drivers here if not already done
+-      for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
+-              if [ ! -e $MPTLINUX_IPATH/${driver_name}.orig ]; then
+-                      cp $MPTLINUX_IPATH/${driver_name} \
+-                              $MPTLINUX_IPATH/${driver_name}.orig
+-              fi;
+-              cp -f $MPTLINUX_IPATH/${driver_name}.new $MPTLINUX_IPATH/${driver_name}
+-      done;
++      echo "The mpt driver for kernel ${kernel} is now version 4.16.00.00"
+       # Remake the initrd image for the user, depending on their OS
+       if [ -f /etc/redhat-release ]; then
+-
+-              # taking care of dud migration, by moving all the ko's to ko.orig
+-              for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
+-                      MPTLINUX_IPATH=/lib/modules/${kernel}/updates
+-                      if [ -e $MPTLINUX_IPATH/${driver_name} ]; then
+-                              mv $MPTLINUX_IPATH/${driver_name} \
+-                                  $MPTLINUX_IPATH/${driver_name}.orig
+-                      fi;
+-              done;
+-
+               # RHEL 4
+               if [ -d /boot/efi/efi/redhat ]; then
+-                      bootpart=/boot/efi/efi/redhat;
++                      bootpart=/boot/efi/efi/redhat
+               elif [ -d /boot/efi ]; then
+-                      bootpart=/boot/efi;
++                      bootpart=/boot/efi
+               else
+-                      bootpart=/boot;
++                      bootpart=/boot
+               fi
+               if [ ! -e ${bootpart}/initrd-${kernel}.img.orig ]; then
+                       echo Saving initrd-${kernel}.img in ${bootpart} directory.
+                       cp ${bootpart}/initrd-${kernel}.img \
+-                          ${bootpart}/initrd-${kernel}.img.orig
+-              fi;
++                          ${bootpart}/initrd-${kernel}.img.orig.mptlinux-%{version}
++              fi
+               # Calling depmod
+-              depmod -v ${kernel} > /dev/null 2>&1;
++              depmod -v ${kernel} > /dev/null 2>&1
+               mkinitrd -f ${bootpart}/initrd-${kernel}.img ${kernel}
+       elif [ -f /etc/SuSE-release ]; then
+               # SLES 9
+               if [ ! -e /boot/initrd-${kernel}.orig ]; then
+                       echo Saving initrd-${kernel} in /boot directory.
+-                      cp /boot/initrd-${kernel} /boot/initrd-${kernel}.orig
+-              fi;
++                      cp /boot/initrd-${kernel} /boot/initrd-${kernel}.orig.mptlinux-%{version}
++              fi
+               # Calling depmod
+-              depmod -v ${kernel} > /dev/null 2>&1;
++              depmod -v ${kernel} > /dev/null 2>&1
+               mk_initrd -k vmlinuz-${kernel} -i /boot/initrd-${kernel}
+-      fi;
+-done;
++      fi
++done
+ echo -e "post Install Done."
+ # postun #######################################################################
+-%postun
++%postun modules
+ echo postun %{version}
+ for i in /lib/modules/2.6.*; do
+-      kernel=`basename ${i}`;
+-      MPTLINUX_IPATH=/lib/modules/${kernel}/kernel/drivers/message/fusion
+-      if [ ! -e $MPTLINUX_IPATH/mptbase.ko ] || \
+-          [ -e $MPTLINUX_IPATH/mptbase.ko.new ]; then
+-              continue;
+-      fi;
++      kernel=`basename ${i}`
++      MPTLINUX_IPATH=/lib/modules/${kernel}/updates/drivers/message/fusion
++      if [ ! -e $MPTLINUX_IPATH/mptbase.ko ]; then
++              continue
++      fi
+       if [ ! -e /etc/init.d/fusion.mptctl ]; then
++              # why are we only doing this if the fustion.mptctl file
++              # *doesn't* exist?  running chkconfig on a file that doesn't
++              # exist is surely an error
++              #chkconfig fusion.mptctl --del >/dev/null 2>&1
++              :
++      else
+               chkconfig fusion.mptctl --del >/dev/null 2>&1
+-      fi;
+-      if [ -f /etc/modprobe.conf.orig ]; then
++      fi
++
++      if [ -f /etc/modprobe.conf.orig.mptlinux-%{version} ]; then
+               # RHEL 4
+-              mv -f /etc/modprobe.conf.orig /etc/modprobe.conf;
+-      elif [ -f /etc/sysconfig/kernel.orig ]; then
++              mv -f /etc/modprobe.conf.orig.mptlinux-%{version} /etc/modprobe.conf
++      elif [ -f /etc/sysconfig/kernel.orig.mptlinux-%{version} ]; then
+               # SLES 9
+-              mv -f /etc/sysconfig/kernel.orig /etc/sysconfig/kernel;
+-      fi;
+-      for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
+-              if [ -f $MPTLINUX_IPATH/${driver_name}.orig ]; then
+-                      mv -f $MPTLINUX_IPATH/${driver_name}.orig $MPTLINUX_IPATH/${driver_name}
+-              fi;
+-      done;
++              mv -f /etc/sysconfig/kernel.orig.mptlinux-%{version} /etc/sysconfig/kernel
++      fi
+       # restore original initrd images
++      # i don't think this is a good idea.  lots of stuff may have happened
++      # to the system between the time this backup was made and now that
++      # renders the original initrd images useless now
++      # probably should just generate new ones
+       if [ -f /etc/redhat-release ]; then
+-              # restoring the state of dud migration
+-              for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
+-                      MPTLINUX_IPATH=/lib/modules/${kernel}/udpates
+-                      if [ -f $MPTLINUX_IPATH/${driver_name}.orig ]; then
+-                              mv -f $MPTLINUX_IPATH/${driver_name}.orig $MPTLINUX_IPATH/${driver_name}
+-                      fi;
+-              done;
+-
+               # RHEL 4
+               if [ -d /boot/efi/efi/redhat ]; then
+-                      bootpart=/boot/efi/efi/redhat;
++                      bootpart=/boot/efi/efi/redhat
+               elif [ -d /boot/efi ]; then
+-                      bootpart=/boot/efi;
++                      bootpart=/boot/efi
+               else
+-                      bootpart=/boot;
++                      bootpart=/boot
+               fi
+-              if [ -f ${bootpart}/initrd-${kernel}.img.orig ]; then
+-                      mv -f ${bootpart}/initrd-${kernel}.img.orig ${bootpart}/initrd-${kernel}.img;
+-              fi;
++              #if [ -f ${bootpart}/initrd-${kernel}.img.orig.mptlinux-%{version} ]; then
++              #       mv -f ${bootpart}/initrd-${kernel}.img.orig.mptlinux-%{version} ${bootpart}/initrd-${kernel}.img
++              #fi
++              # Calling depmod
++              depmod -v ${kernel} > /dev/null 2>&1
++              mkinitrd -f ${bootpart}/initrd-${kernel}.img ${kernel}
+       elif [ -f /etc/SuSE-release ]; then
+               # SLES 9
+-              if [ -f /boot/initrd-${kernel}.orig ]; then
+-                      mv -f /boot/initrd-${kernel}.orig /boot/initrd-${kernel};
+-              fi;
+-      fi;
+-      depmod -v ${kernel} > /dev/null 2>&1;
+-done;
++              #if [ -f /boot/initrd-${kernel}.orig.mptlinux-%{version} ]; then
++              #       mv -f /boot/initrd-${kernel}.orig.mptlinux-%{version} /boot/initrd-${kernel}
++              #fi
++              # Calling depmod
++              depmod -v ${kernel} > /dev/null 2>&1
++              mk_initrd -k vmlinuz-${kernel} -i /boot/initrd-${kernel}
++      fi
++done
+ echo -e "Uninstall Done."
+ # files ########################################################################
+ %files -f ../file.list.%{name}
++%files modules -f ../file.list.%{name}-modules
+ # changelog  ###################################################################
+ %changelog
++* Wed Oct 28 2009 Brian J. Murrell <Brian.Murrell@Sun.COM>
++ - split into modules and non-modules packages so that multiple
++   modules packages can be installed, for several kernels
++ - don't fiddle with files once RPM has installed them
++ - put modules into the updates tree under the modules dir, where
++   they belong
++ - don't use the "orig" initrd, but generate a new one on removal
++   + the orig initrd could very well no longer be suitable
++ - don't edit the modprobe.conf file as that's a job for the admin
++   + we really can't assume which other scsi_host_adapters are in
++     the machine and what position we are to take relative to them
+ * Tue Apr 24 2007 Eric Moore <Eric.Moore@lsi.com>
+  - Fix RHEL5 DUD to RPM migration
+ * Tue Apr 17 2007 Eric Moore <Eric.Moore@lsi.com>
diff --git a/build/rdac_spec b/build/rdac_spec
new file mode 100644 (file)
index 0000000..eabf002
--- /dev/null
@@ -0,0 +1,130 @@
+%{!?kernel_obj: %define kernel_obj /lib/modules/$(uname -r)/build}
+# legal values are REDHAT and SUSE.  default to REDHAT
+%{!?dist: %define dist REDHAT}
+
+%define version 09.03.0C02.0013
+
+Name: rdac
+License: GPL
+Group: System/Kernel
+Summary: Multipathing tools
+Version: %{version}
+Release: 1
+Source: http://codeman.central.sun.com/LSI/USR-SDLC/RDAC-Linux/rdac-LINUX-%{version}-source.tar.gz
+#?? BuildRequires: kernel-source kernel-syms
+BuildRoot: %{_tmppath}/rdac-%{version}-root
+
+%description
+This package provides the mppUtil (multipathing command line utilities).
+
+%package modules
+Summary: Multipathing driver for disk subsystems.
+Group: System/Kernel
+
+%description modules
+This package provides the multipathing kernel modules.
+
+%prep
+if true; then
+#exit 0
+%setup -n linuxrdac-%{version}
+else
+cd linuxrdac-%{version}
+fi
+find_linux_release() {
+    local SRCDIR="$1"
+
+    local LINUXRELEASEHEADER=$SRCDIR/include/linux/version.h
+    if [ -s $SRCDIR/include/linux/utsrelease.h ]; then
+        LINUXRELEASEHEADER=$SRCDIR/include/linux/utsrelease.h
+    fi
+
+    sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER
+
+}
+
+# need to fix up silly Makefile madness
+chmod u+w Makefile
+ed Makefile << EOF
+/^GCC_CHK_FLAG :=/c
+GCC_CHK_FLAG := 1
+.
+/^DIST :=/c
+DIST := %{dist}
+.
+/^%{dist}_KERNEL_CHECK :=/c
+%{dist}_KERNEL_CHECK := 1
+.
+/^OS_VER :=/c
+OS_VER := $(find_linux_release %{kernel_obj})
+.
+g/install -o root -g root -m [0-9]\{4,4\}/s//install/
+wq
+EOF
+
+# and other silliness
+#ed genfileattributes << "EOF"
+#EOF
+sed -i -e 's/\/bin\/\(basename\)/\1/g' -e 's/\/bin\/\(awk\)/\1/g' genfileattributes
+
+#sed -i -e 's/install -o root -g root/install/g Makefile
+
+%build
+#exit 0
+export KERNEL_OBJ=%{kernel_obj}
+make all
+
+%install
+rm -rf $RPM_BUILD_ROOT
+export KERNEL_OBJ=%{kernel_obj}
+DIST=%{dist}
+make DEST_DIR=$RPM_BUILD_ROOT copyfiles copyrpmfiles
+install -m 0755 -D mpp_rcscript.$DIST $RPM_BUILD_ROOT/etc/init.d/mpp
+gzip $RPM_BUILD_ROOT/usr/share/man/man9/RDAC.9
+gzip $RPM_BUILD_ROOT/usr/share/man/man1/mppBusRescan.1
+ln -s mppBusRescan $RPM_BUILD_ROOT/usr/sbin/hot_add
+ln -s mppBusRescan.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/hot_add.1.gz
+gzip $RPM_BUILD_ROOT/usr/share/man/man1/mppUpdate.1
+gzip $RPM_BUILD_ROOT/usr/share/man/man1/mppUtil.1
+install -m 0444 -D mpp.conf $RPM_BUILD_ROOT/etc/mpp.conf
+touch devicemapping
+install -m 0755 -d $RPM_BUILD_ROOT/var/mpp
+install -m 0644 -D devicemapping $RPM_BUILD_ROOT/var/mpp/devicemapping
+rm devicemapping
+rm -rf $RPM_BUILD_ROOT/opt/mpp/.mppLnx_rpm_helpers
+
+%post modules
+depmod -a
+
+%files
+%defattr (-,root,root)
+/usr/sbin/hot_add
+/usr/share/man/man1/hot_add.1.gz
+%attr (755,root,root) /etc/init.d/mpp
+%attr (444,root,root) %config(noreplace) /etc/mpp.conf
+%attr (755,root,root) %dir /var/mpp
+%attr (644,root,root) %config(noreplace) /var/mpp/devicemapping
+%attr (755,root,root) %dir /opt/mpp
+%defattr (0500,root,root)
+/opt/mpp/genuniqueid
+/opt/mpp/mppSupport
+/opt/mpp/lsvdev
+/opt/mpp/mppiscsi_umountall
+/usr/sbin/mppBusRescan
+/opt/mpp/mppMkInitrdHelper
+/usr/sbin/mppUpdate
+/usr/sbin/mppUtil
+%defattr (0644,root,root)
+/usr/share/man/man1/mppBusRescan.1.gz
+/usr/share/man/man1/mppUpdate.1.gz
+/usr/share/man/man1/mppUtil.1.gz
+/usr/share/man/man9/RDAC.9.gz
+
+%files modules
+%defattr (0644,root,root)
+/lib/modules
+
+
+%changelog
+* Fri Oct 23 2009 - brian@sun.com 09.03.0C02.0013-1
+  - initial packaging