Whamcloud - gitweb
b=20615 always send ZC_ACK on non-blocking connection
[fs/lustre-release.git] / build / mptlinux.spec.patch
1 --- mptlinux.spec.dist  2008-11-07 02:16:26.000000000 -0500
2 +++ mptlinux.spec       2009-12-01 14:17:11.000000000 -0500
3 @@ -1,13 +1,15 @@
4 +%{!?kernel_obj: %define kernel_obj ""}
5 +
6  %define name mptlinux
7  %define version 4.16.00.00
8 -%define release 2
9 -Summary: MPT Fusion drivers for 53C1030, FC9XX, and SAS Adapters
10 +%define release 2sun1
11 +Summary: Common files for the MPT Fusion drivers for 53C1030, FC9XX, and SAS Adapters
12  Name: %{name}
13  Version: %{version}
14  Release: %{release}
15  Vendor: LSI Logic
16  License: GPL
17 -Group: System Environment/Kernel
18 +Group: Utilities/System
19  Source0: %{name}-%{version}.tar.gz
20  Source1: fusion.mptctl
21  URL: http://www.lsilogic.com
22 @@ -22,228 +24,272 @@
23  Fibre Channel FC909, FC919, FC929, FC919X, FC929X, and FC949X adapters
24  SAS SAS1064, SAS1068, and SAS1078 adapters.
25  
26 +This package contains the common file(s).
27 +
28 +%package modules
29 +Summary: Kernel modules for the MPT Fusion drivers for 53C1030, FC9XX, and SAS Adapters
30 +Group: System Environment/Kernel
31 +Requires: mptlinux
32 +
33 +%description modules
34 +Drivers for (suse i686, x86_64, ia64 and updates) for the
35 +LSI Logic Fusion-MPT Architecture parts.
36 +These include the Ultra320 53C1030 and 53C1020 adapters.
37 +Fibre Channel FC909, FC919, FC929, FC919X, FC929X, and FC949X adapters
38 +SAS SAS1064, SAS1068, and SAS1078 adapters.
39 +
40 +This package contains the drivers.
41 +
42  # prep #########################################################################
43  %prep
44 +#exit 0
45  echo prep %{version}
46 -%setup -c -b 0
47 +%setup -c
48  
49  # build ########################################################################
50  %build
51 +#exit 0
52  echo build %{version}
53 +if [ "%{kernel_obj}" != "" ]; then
54 +       # dig the version out of the tree
55 +        LINUXRELEASEHEADER=%{kernel_obj}/include/linux/version.h
56 +        if [ -s %{kernel_obj}/include/linux/utsrelease.h ]; then
57 +            LINUXRELEASEHEADER=%{kernel_obj}/include/linux/utsrelease.h
58 +        fi
59 +        LINUXRELEASE=$(sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER)
60 +
61 +       make build LINUX=%{kernel_obj} KERNEL=$LINUXRELEASE
62 +else
63  for i in /lib/modules/2.6.*; do
64 -       kernel=`basename ${i}`;
65 +       kernel=`basename ${i}`
66         if [ -f /lib/modules/${kernel}/source/drivers/message/fusion/Kconfig ]; then
67 -               make build KERNEL=$kernel;
68 -       fi;
69 -done;
70 +               make build KERNEL=$kernel
71 +       fi
72 +done
73 +fi
74  
75  # install ######################################################################
76  %install
77  echo install %{version}
78  echo "%defattr(-,root,root)" > $RPM_BUILD_DIR/file.list.%{name}
79 +echo "%defattr(-,root,root)" > $RPM_BUILD_DIR/file.list.%{name}-modules
80  echo "/etc/init.d/fusion.mptctl" >> $RPM_BUILD_DIR/file.list.%{name}
81  mkdir -p $RPM_BUILD_ROOT/etc/init.d
82 -cp -rf $RPM_SOURCE_DIR/fusion.mptctl $RPM_BUILD_ROOT/etc/init.d
83 +cp -f $RPM_SOURCE_DIR/fusion.mptctl $RPM_BUILD_ROOT/etc/init.d
84 +if [ "%{kernel_obj}" != "" ]; then
85 +       # dig the version out of the tree
86 +        LINUXRELEASEHEADER=%{kernel_obj}/include/linux/version.h
87 +        if [ -s %{kernel_obj}/include/linux/utsrelease.h ]; then
88 +            LINUXRELEASEHEADER=%{kernel_obj}/include/linux/utsrelease.h
89 +        fi
90 +        kernel="$(sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER)"
91 +
92 +       #if [ ! -e /lib/modules/${kernel}/source/drivers/message/fusion/Kconfig ]; then
93 +       #       continue
94 +       #fi
95 +       MPTLINUX_IPATH=/lib/modules/${kernel}/updates/drivers/message/fusion
96 +       mkdir -p $RPM_BUILD_ROOT/lib/modules/${kernel}/{kernel,updates}/drivers/message/fusion
97 +
98 +       # create the file list used in %files to indicate which files are in package
99 +       for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
100 +               echo "$MPTLINUX_IPATH/${driver_name}" >> $RPM_BUILD_DIR/file.list.%{name}-modules
101 +       done
102 +
103 +       make install PREFIX=$RPM_BUILD_ROOT LINUX=%{kernel_obj} KERNEL=$kernel
104 +       # the Makefile hardcodes the destination path to
105 +       # $(PREFIX)/lib/modules/$(KERNEL)/kernel/drivers/message/fusion
106 +       # so lets move these to where they really go
107 +       # ideally, the Makefile should take this location as an (optional if you
108 +       # wish) argument
109 +       mv -f $RPM_BUILD_ROOT/lib/modules/${kernel}/kernel/drivers/message/fusion/* \
110 +             $RPM_BUILD_ROOT/$MPTLINUX_IPATH/
111 +else
112  for i in /lib/modules/2.6.*; do
113         kernel=`basename ${i}`
114         if [ ! -e /lib/modules/${kernel}/source/drivers/message/fusion/Kconfig ]; then
115 -               continue;
116 -       fi;
117 -       MPTLINUX_IPATH=/lib/modules/${kernel}/kernel/drivers/message/fusion
118 -       mkdir -p $RPM_BUILD_ROOT/lib/modules/${kernel}/kernel/drivers/message/fusion
119 +               continue
120 +       fi
121 +       MPTLINUX_IPATH=/lib/modules/${kernel}/updates/drivers/message/fusion
122 +       mkdir -p $RPM_BUILD_ROOT/lib/modules/${kernel}/{kernel,updates}/drivers/message/fusion
123  
124         # create the file list used in %files to indicate which files are in package
125         for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
126 -               echo "$MPTLINUX_IPATH/${driver_name}.new" >> $RPM_BUILD_DIR/file.list.%{name}
127 -       done;
128 +               echo "$MPTLINUX_IPATH/${driver_name}" >> $RPM_BUILD_DIR/file.list.%{name}-modules
129 +       done
130  
131         make install PREFIX=$RPM_BUILD_ROOT KERNEL=$kernel
132 -
133 -       for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
134 -               mv -f $RPM_BUILD_ROOT/$MPTLINUX_IPATH/${driver_name} \
135 -                       $RPM_BUILD_ROOT/$MPTLINUX_IPATH/${driver_name}.new
136 -       done;
137 -done;
138 -
139 -# pre #########################################################################
140 -%pre
141 -echo pre %{version}
142 -system_arch=`uname -m`
143 -if [ -f /etc/SuSE-release ] && [ ${system_arch} == i686 ]; then
144 -       system_arch=i586;
145 -fi;
146 -if [ %{_target_cpu} != ${system_arch} ]; then
147 -       echo "ERROR: Failed installing this rpm!!!!"
148 -       echo "This rpm is intended for %{_target_cpu} platform. It seems your system is ${system_arch}.";
149 -       exit 1;
150 -fi;
151 +       # the Makefile hardcodes the destination path to
152 +       # $(PREFIX)/lib/modules/$(KERNEL)/kernel/drivers/message/fusion
153 +       # so lets move these to where they really go
154 +       # ideally, the Makefile should take this location as an (optional if you
155 +       # wish) argument
156 +       mv -f $RPM_BUILD_ROOT/lib/modules/${kernel}/kernel/drivers/message/fusion/* \
157 +             $RPM_BUILD_ROOT/$MPTLINUX_IPATH/
158 +done
159 +fi
160  
161  # post #########################################################################
162 -%post
163 +%post modules
164  echo post %{version}
165  chkconfig fusion.mptctl --add >/dev/null 2>&1
166  if [ -f /etc/redhat-release ]; then
167         # RHEL 4
168 -       if [ -f /etc/modprobe.conf ] ; then
169 -               cp /etc/modprobe.conf /etc/modprobe.conf.orig.%{version};
170 -               sed -e '/mptbase/d' /etc/modprobe.conf > modprobe.edit;
171 -               sed -e '/mptscsih/d' modprobe.edit > modprobe.edit.1;
172 -               sed -e '/mptspi/d' modprobe.edit.1 > modprobe.edit.2;
173 -               sed -e '/mptfc/d' modprobe.edit.2 > modprobe.edit.3;
174 -               sed -e '/mptsas/d' modprobe.edit.3 > modprobe.edit;
175 -               echo "alias scsi_hostadapter mptspi" >> modprobe.edit;
176 -               echo "alias scsi_hostadapter1 mptfc" >> modprobe.edit;
177 -               echo "alias scsi_hostadapter2 mptsas" >> modprobe.edit;
178 -               mv -f modprobe.edit /etc/modprobe.conf;
179 -               rm -fr modprobe.edit.*;
180 -       fi;
181 +       # per the comments below, i can't see any modprobe.conf editing here that's
182 +       # valid
183 +       #if [ -f /etc/modprobe.conf ] ; then
184 +       #       cp /etc/modprobe.conf /etc/modprobe.conf.orig.mptlinux-%{version}
185 +               # i don't think this is kosher.  what sort of entries are
186 +               # being deleted here?
187 +               #sed -e '/mptbase/d' -e '/mptscsih/d' -e '/mptspi/d' \
188 +               #    -e '/mptfc/d' -e '/mptsas/d' /etc/modprobe.conf > /etc/modprobe.edit
189 +               # this really isn't kosher.  you can't assume that the
190 +               # administrator has not already defined the scsi_hostadapter
191 +               # aliases for some other HBA that's already in the system
192 +               #echo "alias scsi_hostadapter mptspi" >> /etc/modprobe.edit
193 +               #echo "alias scsi_hostadapter1 mptfc" >> /etc/modprobe.edit
194 +               #echo "alias scsi_hostadapter2 mptsas" >> /etc/modprobe.edit
195 +               #mv -f /etc/modprobe.edit /etc/modprobe.conf
196 +       #fi
197 +       :
198  elif [ -f /etc/SuSE-release ]; then
199         # SLES 9
200         if [ -f /etc/sysconfig/kernel ] ; then
201 -               cp /etc/sysconfig/kernel /etc/sysconfig/kernel.orig.%{version};
202 -               sed -e 's/mptscsih//g' /etc/sysconfig/kernel > kernel.edit;
203 -               sed -e 's/mptsas//g' kernel.edit > kernel.edit.1;
204 -               sed -e 's/mptfc//g' kernel.edit.1 > kernel.edit.2;
205 -               sed -e 's/mptspi//g' kernel.edit.2 > kernel.edit.3;
206 -               sed -e 's/INITRD_MODULES="/INITRD_MODULES="mptsas /g' kernel.edit.3 > kernel.edit.4;
207 -               sed -e 's/INITRD_MODULES="/INITRD_MODULES="mptfc /g' kernel.edit.4 > kernel.edit.5;
208 -               sed -e 's/INITRD_MODULES="/INITRD_MODULES="mptspi /g' kernel.edit.5 > kernel.edit;
209 -               mv -f kernel.edit /etc/sysconfig/kernel;
210 -               rm -fr kernel.edit.*;
211 -       fi;
212 +               cp /etc/sysconfig/kernel /etc/sysconfig/kernel.orig.mptlinux-%{version}
213 +               sed -e 's/mptscsih//g' -e 's/mptsas//g' -e 's/mptfc//g' \
214 +                   -e 's/mptspi//g' \
215 +                   -e 's/INITRD_MODULES="/INITRD_MODULES="mptsas /g' \
216 +                   -e 's/INITRD_MODULES="/INITRD_MODULES="mptfc /g' \
217 +                   -e 's/INITRD_MODULES="/INITRD_MODULES="mptspi /g' \
218 +                   /etc/sysconfig/kernel > /etc/sysconfig/kernel.edit
219 +               mv -f /etc/sysconfig/kernel.edit /etc/sysconfig/kernel
220 +       fi
221  fi
222  
223  # adding device nodes
224  if [ ! -e /dev/mptctl ]; then
225 -       echo "Creating /dev/mptctl ioctl node file";
226 -       mknod /dev/mptctl c 10 220;
227 -fi;
228 +       echo "Creating /dev/mptctl ioctl node file"
229 +       mknod /dev/mptctl c 10 220
230 +fi
231  
232 +# i think this is wrong.  we should not muck around with kernels we did not
233 +# install new drivers into.  but how to determine which kernels those are?
234 +# maybe look for the new driver in the /lib/modules/*/updates tree?
235  for i in /lib/modules/2.6.*; do
236 -       kernel=`basename ${i}`;
237 -       MPTLINUX_IPATH=/lib/modules/${kernel}/kernel/drivers/message/fusion
238 -       if [ ! -e $MPTLINUX_IPATH/mptbase.ko ] || \
239 -           [ ! -e $MPTLINUX_IPATH/mptbase.ko.new ]; then
240 -               continue;
241 -       fi;
242 +       kernel=`basename ${i}`
243  
244         if [ -f /etc/SuSE-release ] &&
245             [ ! -e /boot/initrd-${kernel} ]; then
246 -               continue;
247 -       fi;
248 +               continue
249 +       fi
250  
251 -       echo "The mpt driver for kernel ${kernel} is now version 4.16.00.00";
252 -       #backup original fusion drivers here if not already done
253 -       for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
254 -               if [ ! -e $MPTLINUX_IPATH/${driver_name}.orig ]; then
255 -                       cp $MPTLINUX_IPATH/${driver_name} \
256 -                               $MPTLINUX_IPATH/${driver_name}.orig
257 -               fi;
258 -               cp -f $MPTLINUX_IPATH/${driver_name}.new $MPTLINUX_IPATH/${driver_name}
259 -       done;
260 +       echo "The mpt driver for kernel ${kernel} is now version 4.16.00.00"
261         # Remake the initrd image for the user, depending on their OS
262         if [ -f /etc/redhat-release ]; then
263 -
264 -               # taking care of dud migration, by moving all the ko's to ko.orig
265 -               for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
266 -                       MPTLINUX_IPATH=/lib/modules/${kernel}/updates
267 -                       if [ -e $MPTLINUX_IPATH/${driver_name} ]; then
268 -                               mv $MPTLINUX_IPATH/${driver_name} \
269 -                                   $MPTLINUX_IPATH/${driver_name}.orig
270 -                       fi;
271 -               done;
272 -
273                 # RHEL 4
274                 if [ -d /boot/efi/efi/redhat ]; then
275 -                       bootpart=/boot/efi/efi/redhat;
276 +                       bootpart=/boot/efi/efi/redhat
277                 elif [ -d /boot/efi ]; then
278 -                       bootpart=/boot/efi;
279 +                       bootpart=/boot/efi
280                 else
281 -                       bootpart=/boot;
282 +                       bootpart=/boot
283                 fi
284                 if [ ! -e ${bootpart}/initrd-${kernel}.img.orig ]; then
285                         echo Saving initrd-${kernel}.img in ${bootpart} directory.
286                         cp ${bootpart}/initrd-${kernel}.img \
287 -                           ${bootpart}/initrd-${kernel}.img.orig
288 -               fi;
289 +                           ${bootpart}/initrd-${kernel}.img.orig.mptlinux-%{version}
290 +               fi
291                 # Calling depmod
292 -               depmod -v ${kernel} > /dev/null 2>&1;
293 +               depmod -v ${kernel} > /dev/null 2>&1
294                 mkinitrd -f ${bootpart}/initrd-${kernel}.img ${kernel}
295         elif [ -f /etc/SuSE-release ]; then
296                 # SLES 9
297                 if [ ! -e /boot/initrd-${kernel}.orig ]; then
298                         echo Saving initrd-${kernel} in /boot directory.
299 -                       cp /boot/initrd-${kernel} /boot/initrd-${kernel}.orig
300 -               fi;
301 +                       cp /boot/initrd-${kernel} /boot/initrd-${kernel}.orig.mptlinux-%{version}
302 +               fi
303                 # Calling depmod
304 -               depmod -v ${kernel} > /dev/null 2>&1;
305 +               depmod -v ${kernel} > /dev/null 2>&1
306                 mk_initrd -k vmlinuz-${kernel} -i /boot/initrd-${kernel}
307 -       fi;
308 -done;
309 +       fi
310 +done
311  echo -e "post Install Done."
312  
313  # postun #######################################################################
314 -%postun
315 +%postun modules
316  echo postun %{version}
317  for i in /lib/modules/2.6.*; do
318 -       kernel=`basename ${i}`;
319 -       MPTLINUX_IPATH=/lib/modules/${kernel}/kernel/drivers/message/fusion
320 -       if [ ! -e $MPTLINUX_IPATH/mptbase.ko ] || \
321 -           [ -e $MPTLINUX_IPATH/mptbase.ko.new ]; then
322 -               continue;
323 -       fi;
324 +       kernel=`basename ${i}`
325 +       MPTLINUX_IPATH=/lib/modules/${kernel}/updates/drivers/message/fusion
326 +       if [ ! -e $MPTLINUX_IPATH/mptbase.ko ]; then
327 +               continue
328 +       fi
329         if [ ! -e /etc/init.d/fusion.mptctl ]; then
330 +               # why are we only doing this if the fustion.mptctl file
331 +               # *doesn't* exist?  running chkconfig on a file that doesn't
332 +               # exist is surely an error
333 +               #chkconfig fusion.mptctl --del >/dev/null 2>&1
334 +               :
335 +       else
336                 chkconfig fusion.mptctl --del >/dev/null 2>&1
337 -       fi;
338 -       if [ -f /etc/modprobe.conf.orig ]; then
339 +       fi
340 +
341 +       if [ -f /etc/modprobe.conf.orig.mptlinux-%{version} ]; then
342                 # RHEL 4
343 -               mv -f /etc/modprobe.conf.orig /etc/modprobe.conf;
344 -       elif [ -f /etc/sysconfig/kernel.orig ]; then
345 +               mv -f /etc/modprobe.conf.orig.mptlinux-%{version} /etc/modprobe.conf
346 +       elif [ -f /etc/sysconfig/kernel.orig.mptlinux-%{version} ]; then
347                 # SLES 9
348 -               mv -f /etc/sysconfig/kernel.orig /etc/sysconfig/kernel;
349 -       fi;
350 -       for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
351 -               if [ -f $MPTLINUX_IPATH/${driver_name}.orig ]; then
352 -                       mv -f $MPTLINUX_IPATH/${driver_name}.orig $MPTLINUX_IPATH/${driver_name}
353 -               fi;
354 -       done;
355 +               mv -f /etc/sysconfig/kernel.orig.mptlinux-%{version} /etc/sysconfig/kernel
356 +       fi
357         # restore original initrd images
358 +       # i don't think this is a good idea.  lots of stuff may have happened
359 +       # to the system between the time this backup was made and now that
360 +       # renders the original initrd images useless now
361 +       # probably should just generate new ones
362         if [ -f /etc/redhat-release ]; then
363  
364 -               # restoring the state of dud migration
365 -               for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
366 -                       MPTLINUX_IPATH=/lib/modules/${kernel}/udpates
367 -                       if [ -f $MPTLINUX_IPATH/${driver_name}.orig ]; then
368 -                               mv -f $MPTLINUX_IPATH/${driver_name}.orig $MPTLINUX_IPATH/${driver_name}
369 -                       fi;
370 -               done;
371 -
372                 # RHEL 4
373                 if [ -d /boot/efi/efi/redhat ]; then
374 -                       bootpart=/boot/efi/efi/redhat;
375 +                       bootpart=/boot/efi/efi/redhat
376                 elif [ -d /boot/efi ]; then
377 -                       bootpart=/boot/efi;
378 +                       bootpart=/boot/efi
379                 else
380 -                       bootpart=/boot;
381 +                       bootpart=/boot
382                 fi
383 -               if [ -f ${bootpart}/initrd-${kernel}.img.orig ]; then
384 -                       mv -f ${bootpart}/initrd-${kernel}.img.orig ${bootpart}/initrd-${kernel}.img;
385 -               fi;
386 +               #if [ -f ${bootpart}/initrd-${kernel}.img.orig.mptlinux-%{version} ]; then
387 +               #       mv -f ${bootpart}/initrd-${kernel}.img.orig.mptlinux-%{version} ${bootpart}/initrd-${kernel}.img
388 +               #fi
389 +               # Calling depmod
390 +               depmod -v ${kernel} > /dev/null 2>&1
391 +               mkinitrd -f ${bootpart}/initrd-${kernel}.img ${kernel}
392         elif [ -f /etc/SuSE-release ]; then
393                 # SLES 9
394 -               if [ -f /boot/initrd-${kernel}.orig ]; then
395 -                       mv -f /boot/initrd-${kernel}.orig /boot/initrd-${kernel};
396 -               fi;
397 -       fi;
398 -       depmod -v ${kernel} > /dev/null 2>&1;
399 -done;
400 +               #if [ -f /boot/initrd-${kernel}.orig.mptlinux-%{version} ]; then
401 +               #       mv -f /boot/initrd-${kernel}.orig.mptlinux-%{version} /boot/initrd-${kernel}
402 +               #fi
403 +               # Calling depmod
404 +               depmod -v ${kernel} > /dev/null 2>&1
405 +               mk_initrd -k vmlinuz-${kernel} -i /boot/initrd-${kernel}
406 +       fi
407 +done
408  echo -e "Uninstall Done."
409  
410  # files ########################################################################
411  %files -f ../file.list.%{name}
412 +%files modules -f ../file.list.%{name}-modules
413  
414  # changelog  ###################################################################
415  %changelog
416 +* Wed Oct 28 2009 Brian J. Murrell <Brian.Murrell@Sun.COM>
417 + - split into modules and non-modules packages so that multiple
418 +   modules packages can be installed, for several kernels
419 + - don't fiddle with files once RPM has installed them
420 + - put modules into the updates tree under the modules dir, where
421 +   they belong
422 + - don't use the "orig" initrd, but generate a new one on removal
423 +   + the orig initrd could very well no longer be suitable
424 + - don't edit the modprobe.conf file as that's a job for the admin
425 +   + we really can't assume which other scsi_host_adapters are in
426 +     the machine and what position we are to take relative to them
427  * Tue Apr 24 2007 Eric Moore <Eric.Moore@lsi.com>
428   - Fix RHEL5 DUD to RPM migration
429  * Tue Apr 17 2007 Eric Moore <Eric.Moore@lsi.com>