Whamcloud - gitweb
da284e54cee4c58ea3bd4709636edeeffee86519
[fs/lustre-release.git] / build / mptlinux.spec.patch
1 --- mptlinux.spec.dist  2008-11-07 02:16:26.000000000 -0500
2 +++ mptlinux.spec       2009-10-28 12:10:05.000000000 -0400
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,285 @@
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 +       # the Makefile hardcodes the destination path to
139 +       # $(PREFIX)/lib/modules/$(KERNEL)/kernel/drivers/message/fusion
140 +       # so lets move these to where they really go
141 +       # ideally, the Makefile should take this location as an (optional if you
142 +       # wish) argument
143 +       mv -f $RPM_BUILD_ROOT/lib/modules/${kernel}/kernel/drivers/message/fusion/* \
144 +             $RPM_BUILD_ROOT/$MPTLINUX_IPATH/
145 +done
146 +fi
147  
148  # pre #########################################################################
149 -%pre
150 +%pre modules
151  echo pre %{version}
152  system_arch=`uname -m`
153  if [ -f /etc/SuSE-release ] && [ ${system_arch} == i686 ]; then
154 -       system_arch=i586;
155 -fi;
156 +       system_arch=i586
157 +fi
158  if [ %{_target_cpu} != ${system_arch} ]; then
159         echo "ERROR: Failed installing this rpm!!!!"
160 -       echo "This rpm is intended for %{_target_cpu} platform. It seems your system is ${system_arch}.";
161 -       exit 1;
162 -fi;
163 +       echo "This rpm is intended for %{_target_cpu} platform. It seems your system is ${system_arch}."
164 +       exit 1
165 +fi
166  
167  # post #########################################################################
168 -%post
169 +%post modules
170  echo post %{version}
171  chkconfig fusion.mptctl --add >/dev/null 2>&1
172  if [ -f /etc/redhat-release ]; then
173         # RHEL 4
174 -       if [ -f /etc/modprobe.conf ] ; then
175 -               cp /etc/modprobe.conf /etc/modprobe.conf.orig.%{version};
176 -               sed -e '/mptbase/d' /etc/modprobe.conf > modprobe.edit;
177 -               sed -e '/mptscsih/d' modprobe.edit > modprobe.edit.1;
178 -               sed -e '/mptspi/d' modprobe.edit.1 > modprobe.edit.2;
179 -               sed -e '/mptfc/d' modprobe.edit.2 > modprobe.edit.3;
180 -               sed -e '/mptsas/d' modprobe.edit.3 > modprobe.edit;
181 -               echo "alias scsi_hostadapter mptspi" >> modprobe.edit;
182 -               echo "alias scsi_hostadapter1 mptfc" >> modprobe.edit;
183 -               echo "alias scsi_hostadapter2 mptsas" >> modprobe.edit;
184 -               mv -f modprobe.edit /etc/modprobe.conf;
185 -               rm -fr modprobe.edit.*;
186 -       fi;
187 +       # per the comments below, i can't see any modprobe.conf editing here that's
188 +       # valid
189 +       #if [ -f /etc/modprobe.conf ] ; then
190 +       #       cp /etc/modprobe.conf /etc/modprobe.conf.orig.mptlinux-%{version}
191 +               # i don't think this is kosher.  what sort of entries are
192 +               # being deleted here?
193 +               #sed -e '/mptbase/d' -e '/mptscsih/d' -e '/mptspi/d' \
194 +               #    -e '/mptfc/d' -e '/mptsas/d' /etc/modprobe.conf > /etc/modprobe.edit
195 +               # this really isn't kosher.  you can't assume that the
196 +               # administrator has not already defined the scsi_hostadapter
197 +               # aliases for some other HBA that's already in the system
198 +               #echo "alias scsi_hostadapter mptspi" >> /etc/modprobe.edit
199 +               #echo "alias scsi_hostadapter1 mptfc" >> /etc/modprobe.edit
200 +               #echo "alias scsi_hostadapter2 mptsas" >> /etc/modprobe.edit
201 +               #mv -f /etc/modprobe.edit /etc/modprobe.conf
202 +       #fi
203 +       :
204  elif [ -f /etc/SuSE-release ]; then
205         # SLES 9
206         if [ -f /etc/sysconfig/kernel ] ; then
207 -               cp /etc/sysconfig/kernel /etc/sysconfig/kernel.orig.%{version};
208 -               sed -e 's/mptscsih//g' /etc/sysconfig/kernel > kernel.edit;
209 -               sed -e 's/mptsas//g' kernel.edit > kernel.edit.1;
210 -               sed -e 's/mptfc//g' kernel.edit.1 > kernel.edit.2;
211 -               sed -e 's/mptspi//g' kernel.edit.2 > kernel.edit.3;
212 -               sed -e 's/INITRD_MODULES="/INITRD_MODULES="mptsas /g' kernel.edit.3 > kernel.edit.4;
213 -               sed -e 's/INITRD_MODULES="/INITRD_MODULES="mptfc /g' kernel.edit.4 > kernel.edit.5;
214 -               sed -e 's/INITRD_MODULES="/INITRD_MODULES="mptspi /g' kernel.edit.5 > kernel.edit;
215 -               mv -f kernel.edit /etc/sysconfig/kernel;
216 -               rm -fr kernel.edit.*;
217 -       fi;
218 +               cp /etc/sysconfig/kernel /etc/sysconfig/kernel.orig.mptlinux-%{version}
219 +               sed -e 's/mptscsih//g' -e 's/mptsas//g' -e 's/mptfc//g' \
220 +                   -e 's/mptspi//g' \
221 +                   -e 's/INITRD_MODULES="/INITRD_MODULES="mptsas /g' \
222 +                   -e 's/INITRD_MODULES="/INITRD_MODULES="mptfc /g' \
223 +                   -e 's/INITRD_MODULES="/INITRD_MODULES="mptspi /g' \
224 +                   /etc/sysconfig/kernel > /etc/sysconfig/kernel.edit
225 +               mv -f /etc/sysconfig/kernel.edit /etc/sysconfig/kernel
226 +       fi
227  fi
228  
229  # adding device nodes
230  if [ ! -e /dev/mptctl ]; then
231 -       echo "Creating /dev/mptctl ioctl node file";
232 -       mknod /dev/mptctl c 10 220;
233 -fi;
234 +       echo "Creating /dev/mptctl ioctl node file"
235 +       mknod /dev/mptctl c 10 220
236 +fi
237  
238 +# i think this is wrong.  we should not muck around with kernels we did not
239 +# install new drivers into.  but how to determine which kernels those are?
240 +# maybe look for the new driver in the /lib/modules/*/updates tree?
241  for i in /lib/modules/2.6.*; do
242 -       kernel=`basename ${i}`;
243 -       MPTLINUX_IPATH=/lib/modules/${kernel}/kernel/drivers/message/fusion
244 -       if [ ! -e $MPTLINUX_IPATH/mptbase.ko ] || \
245 -           [ ! -e $MPTLINUX_IPATH/mptbase.ko.new ]; then
246 -               continue;
247 -       fi;
248 +       kernel=`basename ${i}`
249  
250         if [ -f /etc/SuSE-release ] &&
251             [ ! -e /boot/initrd-${kernel} ]; then
252 -               continue;
253 -       fi;
254 +               continue
255 +       fi
256  
257 -       echo "The mpt driver for kernel ${kernel} is now version 4.16.00.00";
258 -       #backup original fusion drivers here if not already done
259 -       for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
260 -               if [ ! -e $MPTLINUX_IPATH/${driver_name}.orig ]; then
261 -                       cp $MPTLINUX_IPATH/${driver_name} \
262 -                               $MPTLINUX_IPATH/${driver_name}.orig
263 -               fi;
264 -               cp -f $MPTLINUX_IPATH/${driver_name}.new $MPTLINUX_IPATH/${driver_name}
265 -       done;
266 +       echo "The mpt driver for kernel ${kernel} is now version 4.16.00.00"
267         # Remake the initrd image for the user, depending on their OS
268         if [ -f /etc/redhat-release ]; then
269 -
270 -               # taking care of dud migration, by moving all the ko's to ko.orig
271 -               for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
272 -                       MPTLINUX_IPATH=/lib/modules/${kernel}/updates
273 -                       if [ -e $MPTLINUX_IPATH/${driver_name} ]; then
274 -                               mv $MPTLINUX_IPATH/${driver_name} \
275 -                                   $MPTLINUX_IPATH/${driver_name}.orig
276 -                       fi;
277 -               done;
278 -
279                 # RHEL 4
280                 if [ -d /boot/efi/efi/redhat ]; then
281 -                       bootpart=/boot/efi/efi/redhat;
282 +                       bootpart=/boot/efi/efi/redhat
283                 elif [ -d /boot/efi ]; then
284 -                       bootpart=/boot/efi;
285 +                       bootpart=/boot/efi
286                 else
287 -                       bootpart=/boot;
288 +                       bootpart=/boot
289                 fi
290                 if [ ! -e ${bootpart}/initrd-${kernel}.img.orig ]; then
291                         echo Saving initrd-${kernel}.img in ${bootpart} directory.
292                         cp ${bootpart}/initrd-${kernel}.img \
293 -                           ${bootpart}/initrd-${kernel}.img.orig
294 -               fi;
295 +                           ${bootpart}/initrd-${kernel}.img.orig.mptlinux-%{version}
296 +               fi
297                 # Calling depmod
298 -               depmod -v ${kernel} > /dev/null 2>&1;
299 +               depmod -v ${kernel} > /dev/null 2>&1
300                 mkinitrd -f ${bootpart}/initrd-${kernel}.img ${kernel}
301         elif [ -f /etc/SuSE-release ]; then
302                 # SLES 9
303                 if [ ! -e /boot/initrd-${kernel}.orig ]; then
304                         echo Saving initrd-${kernel} in /boot directory.
305 -                       cp /boot/initrd-${kernel} /boot/initrd-${kernel}.orig
306 -               fi;
307 +                       cp /boot/initrd-${kernel} /boot/initrd-${kernel}.orig.mptlinux-%{version}
308 +               fi
309                 # Calling depmod
310 -               depmod -v ${kernel} > /dev/null 2>&1;
311 +               depmod -v ${kernel} > /dev/null 2>&1
312                 mk_initrd -k vmlinuz-${kernel} -i /boot/initrd-${kernel}
313 -       fi;
314 -done;
315 +       fi
316 +done
317  echo -e "post Install Done."
318  
319  # postun #######################################################################
320 -%postun
321 +%postun modules
322  echo postun %{version}
323  for i in /lib/modules/2.6.*; do
324 -       kernel=`basename ${i}`;
325 -       MPTLINUX_IPATH=/lib/modules/${kernel}/kernel/drivers/message/fusion
326 -       if [ ! -e $MPTLINUX_IPATH/mptbase.ko ] || \
327 -           [ -e $MPTLINUX_IPATH/mptbase.ko.new ]; then
328 -               continue;
329 -       fi;
330 +       kernel=`basename ${i}`
331 +       MPTLINUX_IPATH=/lib/modules/${kernel}/updates/drivers/message/fusion
332 +       if [ ! -e $MPTLINUX_IPATH/mptbase.ko ]; then
333 +               continue
334 +       fi
335         if [ ! -e /etc/init.d/fusion.mptctl ]; then
336 +               # why are we only doing this if the fustion.mptctl file
337 +               # *doesn't* exist?  running chkconfig on a file that doesn't
338 +               # exist is surely an error
339 +               #chkconfig fusion.mptctl --del >/dev/null 2>&1
340 +               :
341 +       else
342                 chkconfig fusion.mptctl --del >/dev/null 2>&1
343 -       fi;
344 -       if [ -f /etc/modprobe.conf.orig ]; then
345 +       fi
346 +
347 +       if [ -f /etc/modprobe.conf.orig.mptlinux-%{version} ]; then
348                 # RHEL 4
349 -               mv -f /etc/modprobe.conf.orig /etc/modprobe.conf;
350 -       elif [ -f /etc/sysconfig/kernel.orig ]; then
351 +               mv -f /etc/modprobe.conf.orig.mptlinux-%{version} /etc/modprobe.conf
352 +       elif [ -f /etc/sysconfig/kernel.orig.mptlinux-%{version} ]; then
353                 # SLES 9
354 -               mv -f /etc/sysconfig/kernel.orig /etc/sysconfig/kernel;
355 -       fi;
356 -       for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
357 -               if [ -f $MPTLINUX_IPATH/${driver_name}.orig ]; then
358 -                       mv -f $MPTLINUX_IPATH/${driver_name}.orig $MPTLINUX_IPATH/${driver_name}
359 -               fi;
360 -       done;
361 +               mv -f /etc/sysconfig/kernel.orig.mptlinux-%{version} /etc/sysconfig/kernel
362 +       fi
363         # restore original initrd images
364 +       # i don't think this is a good idea.  lots of stuff may have happened
365 +       # to the system between the time this backup was made and now that
366 +       # renders the original initrd images useless now
367 +       # probably should just generate new ones
368         if [ -f /etc/redhat-release ]; then
369  
370 -               # restoring the state of dud migration
371 -               for driver_name in mptbase.ko mptscsih.ko mptctl.ko mptlan.ko mptspi.ko mptfc.ko mptsas.ko; do
372 -                       MPTLINUX_IPATH=/lib/modules/${kernel}/udpates
373 -                       if [ -f $MPTLINUX_IPATH/${driver_name}.orig ]; then
374 -                               mv -f $MPTLINUX_IPATH/${driver_name}.orig $MPTLINUX_IPATH/${driver_name}
375 -                       fi;
376 -               done;
377 -
378                 # RHEL 4
379                 if [ -d /boot/efi/efi/redhat ]; then
380 -                       bootpart=/boot/efi/efi/redhat;
381 +                       bootpart=/boot/efi/efi/redhat
382                 elif [ -d /boot/efi ]; then
383 -                       bootpart=/boot/efi;
384 +                       bootpart=/boot/efi
385                 else
386 -                       bootpart=/boot;
387 +                       bootpart=/boot
388                 fi
389 -               if [ -f ${bootpart}/initrd-${kernel}.img.orig ]; then
390 -                       mv -f ${bootpart}/initrd-${kernel}.img.orig ${bootpart}/initrd-${kernel}.img;
391 -               fi;
392 +               #if [ -f ${bootpart}/initrd-${kernel}.img.orig.mptlinux-%{version} ]; then
393 +               #       mv -f ${bootpart}/initrd-${kernel}.img.orig.mptlinux-%{version} ${bootpart}/initrd-${kernel}.img
394 +               #fi
395 +               # Calling depmod
396 +               depmod -v ${kernel} > /dev/null 2>&1
397 +               mkinitrd -f ${bootpart}/initrd-${kernel}.img ${kernel}
398         elif [ -f /etc/SuSE-release ]; then
399                 # SLES 9
400 -               if [ -f /boot/initrd-${kernel}.orig ]; then
401 -                       mv -f /boot/initrd-${kernel}.orig /boot/initrd-${kernel};
402 -               fi;
403 -       fi;
404 -       depmod -v ${kernel} > /dev/null 2>&1;
405 -done;
406 +               #if [ -f /boot/initrd-${kernel}.orig.mptlinux-%{version} ]; then
407 +               #       mv -f /boot/initrd-${kernel}.orig.mptlinux-%{version} /boot/initrd-${kernel}
408 +               #fi
409 +               # Calling depmod
410 +               depmod -v ${kernel} > /dev/null 2>&1
411 +               mk_initrd -k vmlinuz-${kernel} -i /boot/initrd-${kernel}
412 +       fi
413 +done
414  echo -e "Uninstall Done."
415  
416  # files ########################################################################
417  %files -f ../file.list.%{name}
418 +%files modules -f ../file.list.%{name}-modules
419  
420  # changelog  ###################################################################
421  %changelog
422 +* Wed Oct 28 2009 Brian J. Murrell <Brian.Murrell@Sun.COM>
423 + - split into modules and non-modules packages so that multiple
424 +   modules packages can be installed, for several kernels
425 + - don't fiddle with files once RPM has installed them
426 + - put modules into the updates tree under the modules dir, where
427 +   they belong
428 + - don't use the "orig" initrd, but generate a new one on removal
429 +   + the orig initrd could very well no longer be suitable
430 + - don't edit the modprobe.conf file as that's a job for the admin
431 +   + we really can't assume which other scsi_host_adapters are in
432 +     the machine and what position we are to take relative to them
433  * Tue Apr 24 2007 Eric Moore <Eric.Moore@lsi.com>
434   - Fix RHEL5 DUD to RPM migration
435  * Tue Apr 17 2007 Eric Moore <Eric.Moore@lsi.com>