--- mptlinux.spec.dist 2008-11-07 02:16:26.000000000 -0500 +++ mptlinux.spec 2009-12-01 14:17:11.000000000 -0500 @@ -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,272 @@ 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; - -# pre ######################################################################### -%pre -echo pre %{version} -system_arch=`uname -m` -if [ -f /etc/SuSE-release ] && [ ${system_arch} == i686 ]; then - 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; + # 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 # 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 + - 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 - Fix RHEL5 DUD to RPM migration * Tue Apr 17 2007 Eric Moore