diff --git a/Module.supported b/Module.supported new file mode 100644 index 0000000..2bf848c --- /dev/null +++ b/Module.supported @@ -0,0 +1 @@ +smartpqi.ko external diff --git a/smartpqi-2.1.22-040.tar.bz2 b/smartpqi-2.1.22-040.tar.bz2 new file mode 100644 index 0000000..e1de81a Binary files /dev/null and b/smartpqi-2.1.22-040.tar.bz2 differ diff --git a/smartpqi-fromsrc.conf b/smartpqi-fromsrc.conf new file mode 100644 index 0000000..e786baf --- /dev/null +++ b/smartpqi-fromsrc.conf @@ -0,0 +1 @@ +add_drivers+=" smartpqi " diff --git a/smartpqi-src.spec b/smartpqi-src.spec new file mode 100644 index 0000000..7c07385 --- /dev/null +++ b/smartpqi-src.spec @@ -0,0 +1,214 @@ +%define name smartpqi +%define version 2.1.22 +%define release 040 +%define kernel `uname -r` +Summary: Microchip smartpqi driver for SmartRAID/SmartHBA controllers +Name: %{name} +Version: %{version} +Release: %{release} +Vendor: Microchip Technology Inc. +License: GPLv2 +Group: System Environment/Kernel +Source0: %{name}-%{version}-%{release}.tar.bz2 +Source1: Module.supported +Source2: %{name}-fromsrc.conf +URL: http://www.microchip.com +Distribution: Microchip Technology Inc. +BuildRoot: /var/tmp/%{name}-buildroot + +%define debug_package %{nil} + +%description +Driver for Microchip Technology SmartRAID and SmartHBA controllers + +# prep ######################################################################### +%prep +echo prep %{version}-%{release} +%setup -c -b 0 +cp %_sourcedir/Module.supported src/Module.supported + + +# build ######################################################################## +%build +echo build %{version}-%{release} +make build KERNEL=%{kernel}; + +# install ###################################################################### +%install +echo install %{version}-%{release} +echo "%defattr(-,root,root)" > $RPM_BUILD_DIR/file.list.%{name} + +SMARTPQI_IPATH=/lib/modules/%{kernel}/weak-updates/smartpqi + +if modinfo smartpqi -n |xargs file |grep -c "compressed" >> /dev/null; then + driver_bin="smartpqi.ko.xz" +elif [ $(find /lib/modules/%{kernel}/ -name smartpqi.ko.xz*) ]; then + driver_bin="smartpqi.ko.xz" +else + driver_bin="smartpqi.ko" +fi + +mkdir -p $RPM_BUILD_ROOT/lib/modules/%{kernel}/weak-updates/smartpqi + +# create the file list used in %files to indicate which files are in package +echo "$SMARTPQI_IPATH/${driver_bin}.new" >> $RPM_BUILD_DIR/file.list.%{name} +echo "/etc/dracut.conf.d/smartpqi-fromsrc.conf" >> $RPM_BUILD_DIR/file.list.%{name} + +make install PREFIX=$RPM_BUILD_ROOT KERNEL=%{kernel} +if [ ${driver_bin} == "smartpqi.ko.xz" ]; then + xz $RPM_BUILD_ROOT/$SMARTPQI_IPATH/smartpqi.ko +fi +mv -f $RPM_BUILD_ROOT/$SMARTPQI_IPATH/${driver_bin} \ + $RPM_BUILD_ROOT/$SMARTPQI_IPATH/${driver_bin}.new +install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT/etc/dracut.conf.d/smartpqi-fromsrc.conf + +# pre ######################################################################### +%pre +echo pre %{version}-%{release} +system_arch=`uname -m` +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; + +# post ######################################################################### +%post +echo post %{version}-%{release} + +if modinfo smartpqi -n |xargs file |grep -c "compressed" >> /dev/null; then + driver_bin="smartpqi.ko.xz" +elif [ $(find /lib/modules/%{kernel}/ -name smartpqi.ko.xz*) ]; then + driver_bin="smartpqi.ko.xz" +else + driver_bin="smartpqi.ko" +fi + +if [ ! -e /boot/vmlinuz-%{kernel} ] && [ ! -e /boot/vmlinux-%{kernel} ]; then + continue; +fi; + +SMARTPQI_IPATH=/lib/modules/%{kernel}/weak-updates/smartpqi +if [ ! -e $SMARTPQI_IPATH/${driver_bin}.new ]; then + continue; +fi; + +SMARTPQI_ORIG_IPATH=/lib/modules/%{kernel}/kernel/drivers/scsi/smartpqi +echo "The smartpqi driver for kernel %{kernel} is now version %{version}-%{release}"; +cp -f $SMARTPQI_IPATH/${driver_bin}.new $SMARTPQI_IPATH/${driver_bin} + +# Remake the initrd image +SMARTPQI_IPATH=/lib/modules/%{kernel}/kernel/drivers/scsi/smartpqi +if [ -e $SMARTPQI_IPATH/${driver_bin} ]; then + mv $SMARTPQI_IPATH/${driver_bin} \ + $SMARTPQI_IPATH/${driver_bin}.orig +fi; + +SMARTPQI_IPATH=/lib/modules/%{kernel}/updates +if [ -e $SMARTPQI_IPATH/${driver_bin} ]; then + mv $SMARTPQI_IPATH/${driver_bin} \ + $SMARTPQI_IPATH/${driver_bin}.orig +fi; + +SMARTPQI_IPATH=/lib/modules/%{kernel}/extra/smartpqi +if [ -e $SMARTPQI_IPATH/${driver_bin} ]; then + mv $SMARTPQI_IPATH/${driver_bin} \ + $SMARTPQI_IPATH/${driver_bin}.orig +fi; + +bootpart=/boot; +depmod -v %{kernel} > /dev/null 2>&1; + + + +if which mkinitrd |grep -c "mkinitrd" >> /dev/null; then + if which mkinitrd |grep -c "no mkinitrd" >> /dev/null ; then + module_init_tool="unknown" + else + module_init_tool="mkinitrd" + #SuSE + if [ -h /boot/initrd ] ; then + mkinitrd -f /boot/initrd-%{kernel} %{kernel} + else + mkinitrd -f /boot/initramfs-%{kernel}.img %{kernel} + fi + echo -e "${module_init_tool} post Install Done." + exit 0; + fi +fi + +echo -e "post Install Done." + +# postun ####################################################################### +%postun +echo postun %{version}-%{release} + +if modinfo smartpqi -n |xargs file |grep -c "compressed" >> /dev/null; then + driver_bin="smartpqi.ko.xz" +elif [ $(find /lib/modules/%{kernel}/ -name smartpqi.ko.xz*) ]; then + driver_bin="smartpqi.ko.xz" +else + driver_bin="smartpqi.ko" +fi + +SMARTPQI_IPATH=/lib/modules/%{kernel}/weak-updates/smartpqi +if [ ! -e $SMARTPQI_IPATH/${driver_bin}.new ] && \ + [ -e $SMARTPQI_IPATH/${driver_bin} ]; then + + rm -rf $SMARTPQI_IPATH; + + SMARTPQI_IPATH=/lib/modules/%{kernel}/kernel/drivers/scsi/smartpqi + if [ -e $SMARTPQI_IPATH/${driver_bin}.orig ]; then + mv $SMARTPQI_IPATH/${driver_bin}.orig \ + $SMARTPQI_IPATH/${driver_bin} + fi; + + SMARTPQI_IPATH=/lib/modules/%{kernel}/updates + if [ -e $SMARTPQI_IPATH/${driver_bin}.orig ]; then + mv $SMARTPQI_IPATH/${driver_bin}.orig \ + $SMARTPQI_IPATH/${driver_bin} + fi; + + SMARTPQI_IPATH=/lib/modules/%{kernel}/extra/smartpqi + if [ -e $SMARTPQI_IPATH/${driver_bin}.orig ]; then + mv $SMARTPQI_IPATH/${driver_bin}.orig \ + $SMARTPQI_IPATH/${driver_bin} + fi; +fi; + +bootpart=/boot; + +if [ ! -f /lib/modules/%{kernel}/kernel/drivers/scsi/smartpqi/${driver_bin} ] && \ + [ ! -f /lib/modules/%{kernel}/udpates/${driver_bin} ] && \ + [ ! -f /lib/modules/%{kernel}/weak-updates/smartpqi/${driver_bin} ] && \ + [ ! -f /lib/modules/%{kernel}/extra/smartpqi/${driver_bin} ]; then + sed -e '/smartpqi/d' /etc/modprobe.conf > modprobe.edit; + mv -f modprobe.edit /etc/modprobe.conf; +fi; + +depmod -v %{kernel} > /dev/null 2>&1; + + +if which mkinitrd |grep -c "mkinitrd" >> /dev/null; then + if which mkinitrd |grep -c "no mkinitrd" >> /dev/null ; then + module_init_tool="unknown" + else + module_init_tool="mkinitrd" + #SuSE + if [ -h /boot/initrd ] ; then + mkinitrd -f /boot/initrd-%{kernel} %{kernel} + else + mkinitrd -f /boot/initramfs-%{kernel}.img %{kernel} + fi + echo -e "${module_init_tool} Uninstall Done." + exit 0; + fi +fi + +echo -e "Uninstall Done." + +# files ######################################################################## +%files -f ../file.list.%{name} + +# changelog ################################################################### +%changelog