Whamcloud - gitweb
bd5eb7ebb08293d9665fa5ecd7791d59dee7230e
[fs/lustre-release.git] / build / lustre-kernel-2.4.spec.in
1 Summary: The Linux kernel (the core of the Linux operating system)
2
3 # Versions of various parts
4
5 #
6 # Polite request for people who spin their own kernel rpms:
7 # please modify the "release" field in a way that identifies
8 # that the kernel isn't the stock RHL kernel, for example by
9 # adding some text to the end of the version number.
10 #
11 %define kversion @KERNEL_VERSION@
12 %define kextraver @KERNEL_EXTRA_VERSION@
13 %define release @KERNEL_RELEASE@
14 # /usr/src/%{kslnk} -> /usr/src/linux-%{KVERREL}
15 %define kslnk linux-2.4
16
17 # groups of related archs
18 %define all_x86 i386 i686 i586 athlon
19 #define all_x86 i686 i386 i586 athlon
20
21 %define nptlarchs %{all_x86}
22 #define nptlarchs noarch
23 %define rhbuild @RHBUILD@
24 %define susebuild @SUSEBUILD@
25 %define linux26 @LINUX26@
26
27 # disable build root strip policy
28 %define __spec_install_post /usr/lib/rpm/brp-compress || :
29 #
30 # RPM foo magic
31 %define _missing_doc_files_terminate_build 0
32 %define _unpackaged_files_terminate_build 0
33 %define debug_package %{nil}
34
35 # Enable this to build a board-specific kernel configuration 
36 # some architectures have LOTS of different setups and this 
37 # is a way to deal with that cleanly.
38 #
39 #define targetboard assabet
40 %define dashtargetboard %{?targetboard:-%{targetboard}}
41 %define withtargetboard 0
42 %{?targetboard: %{expand: %%define withtargetboard 1}}
43         
44 # Override generic defaults with per-arch defaults (which can
45 # themselves be overridden with --with/--without).  These must
46 # ONLY be "0", never "1"
47
48 %define buildbase 0
49 %define buildbigmem 0
50 %define buildBOOT 0
51 %define buildjensen 0
52 %define buildsmp 0
53 %define buildbigsmp 0
54 %define buildpseries64 0
55 %define buildup 0
56 %define buildsrc 0
57
58 %ifarch @BASE_ARCHS@
59 %define buildbase 1
60 %endif
61
62 %ifarch @BIGMEM_ARCHS@
63 %define buildbigmem 1
64 %endif
65
66 %ifarch @BOOT_ARCHS@
67 %define buildBOOT 1
68 %endif
69
70 %ifarch @JENSEN_ARCHS@
71 %define buildjensen 1
72 %endif
73
74 %ifarch @SMP_ARCHS@
75 %define buildsmp 1
76 %endif
77
78 %ifarch @BIGSMP_ARCHS@
79 %define buildbigsmp 1
80 %endif
81
82 %ifarch @PSERIES64_ARCHS@
83 %define buildpseries64 1
84 %endif
85
86 %ifarch @UP_ARCHS@
87 %define buildup 1
88 %endif
89
90 # For board-specific kernels, build only the normal kernel (which may actually be smp, not up).
91 %if %{withtargetboard}
92 %define buildsmp 0
93 %define buildbigsmp 0
94 %define buildBOOT 0
95 %define buildbigmem 0
96 %define buildpseries64 0
97 %define buildjensen 0
98 %endif
99
100 %if 0
101 Second, per-architecture exclusions (ifarch)
102 %ifarch i386
103 %define buildsmp 0
104 %endif
105 %ifarch ia64
106 %define buildBOOT 0
107 %endif
108 %endif
109
110 # we can't test values inline, only whether a macro exists
111 %{expand: %%define buildup_%{buildup} yadda}
112 %{expand: %%define buildsmp_%{buildsmp} yadda}
113 %{expand: %%define buildbigsmp_%{buildbigsmp} yadda}
114 %{expand: %%define buildpseries64_%{buildpseries64} yadda}
115 %{expand: %%define buildBOOT_%{buildBOOT} yadda}
116 %{expand: %%define buildbigmem_%{buildbigmem} yadda}
117 %{expand: %%define buildjensen_%{buildjensen} yadda}
118 %{expand: %%define ikd_%{ikd} yadda}
119 %{expand: %%define ibcs_%{ibcs} yadda}
120 %{expand: %%define debuglevel_%{debugging} yadda}
121
122 %{expand: %%define kernel_conflicts  ppp <= 2.3.15, pcmcia-cs <= 3.1.20, isdn4k-utils <= 3.0, mount < 2.10r-5, nfs-utils < 0.3.1, cipe < 1.4.5, tux < 2.1.0, kudzu <= 0.92, e2fsprogs < 1.22, initscripts < 5.84, dev < 3.2-7, iptables < 1.2.5-3, bcm5820 < 1.81, nvidia-rh72 <= 1.0, oprofile < 0.4}
123
124 %if %{rhbuild}
125 %define BOOT_kernel_prereq fileutils, modutils >=  2.4.18
126 %define kernel_prereq %{BOOT_kernel_prereq}, initscripts >= 5.83, mkinitrd >= 3.2.6
127 %endif
128
129 %ifarch ia64
130 %define initrd_dir /boot/efi/redhat
131 %else
132 %define initrd_dir /boot
133 %endif
134
135 %ifarch %{all_x86} x86_64
136 %define kernel_glob vmlinu?-%{KVERREL}
137 %endif
138 %ifarch ia64
139 # <sigh>, no GLOB_BRACE for filelists, efi needs to be done separately
140 %define kernel_glob vmlinuz-%{KVERREL}
141 %endif
142 %ifarch alpha
143 %define kernel_glob vmlinu?-%{KVERREL}
144 %endif
145 %ifarch ppc ppc64
146 %define kernel_glob vmlinu?-%{KVERREL}
147 %endif
148
149 Name: kernel
150 Version: %{kversion}
151 Release: %{release}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg}
152 %define KVERREL %{PACKAGE_VERSION}-%{kextraver}%{?targetboard:%{targetboard}}%{?debuglevel_1:.dbg}
153 License: GPL
154 Group: System Environment/Kernel
155 ExclusiveArch: %{all_x86} x86_64 ia64 ppc
156 ExclusiveOS: Linux
157 Obsoletes: kernel-modules, kernel-sparc
158 Provides: kernel = %{version}
159 BuildConflicts: rhbuildsys(DiscFree) < 500Mb
160 %ifarch %{all_x86} ia64 x86_64
161 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
162 %endif
163 Autoreqprov: no
164 %if %{rhbuild}
165 Prereq: %{kernel_prereq}
166 Conflicts: %{kernel_conflicts}
167
168 BuildPreReq: patch >= 2.5.4, bash >= 2.03, sh-utils, gnupg, tar
169 BuildPreReq: bzip2, findutils, dev, gzip, m4
170 %endif
171
172 Vendor: Cluster File Systems, Inc.
173 URL: http://www.kernel.org/
174 Buildroot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root
175
176 Source0: @LUSTRE_SOURCE@
177 Source1: @KERNEL_SOURCE@
178 Source2: external-patches.tar.gz
179
180 Source15: linux-rhconfig.h
181 Source16: linux-merge-config.awk
182 Source17: linux-merge-modules.awk
183
184 Source25: suse-functions.sh
185 Source26: suse-post.sh
186 Source27: suse-postun.sh
187 Source28: suse-trigger-script.sh.in
188
189 %package source
190 Summary: The source code for the Linux kernel.
191 Group: Development/System
192 Prereq: fileutils
193 Requires: gawk
194 Requires: gcc >= 2.96-98
195 Autoreqprov: 0
196
197 %package doc
198 Summary: Various documentation bits found in the kernel source.
199 Group: Documentation
200
201 %description
202 The kernel package contains the Linux kernel (vmlinuz), the core of a
203 Linux operating system.  The kernel handles the basic functions of the
204 operating system: memory allocation, process allocation, device input
205 and output, etc.
206
207 %description source
208 The kernel-source package contains the source code files for the Linux
209 kernel. These source files are needed to build custom/third party device
210 drivers. The source files can also be used to build a custom kernel that is
211 better tuned to your particular hardware, if you are so inclined (and you
212 know what you're doing).
213
214 %description doc
215 This package contains documentation files form the kernel
216 source. Various bits of information about the Linux kernel and the
217 device drivers shipped with it are documented in these files. 
218
219 You'll want to install this package if you need a reference to the
220 options that can be passed to Linux kernel modules at load time.
221
222 %package smp
223 Summary: The Linux kernel compiled for SMP machines.
224 Group: System Environment/Kernel
225 Provides: module-info, kernel = %{version}
226 %ifarch %{all_x86} ia64 x86_64
227 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
228 %endif
229 %if %{rhbuild}
230 Prereq: %{kernel_prereq}
231 Conflicts: %{kernel_conflicts}
232 %endif
233
234 %description smp
235 This package includes a SMP version of the Linux kernel. It is
236 required only on machines with two or more CPUs, although it should
237 work fine on single-CPU boxes.
238
239 Install the kernel-smp package if your machine uses two or more CPUs.
240
241 %package bigsmp
242 Summary: The Linux kernel compiled for SMP machines.
243 Group: System/Kernel
244 Provides: module-info, kernel = %{version}, k_smp4G
245 Obsoletes: k_smp4G
246 %ifarch %{all_x86} ia64 x86_64
247 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
248 %endif
249 %if %{rhbuild}
250 Prereq: %{kernel_prereq}
251 Conflicts: %{kernel_conflicts}
252 %endif
253
254 %description bigsmp
255 This package includes a SMP version of the Linux kernel. It is
256 required only on machines with two or more CPUs, although it should
257 work fine on single-CPU boxes.
258
259 Install the kernel-bigsmp package if your machine uses two or more CPUs.
260
261 %package pseries64
262 Summary: Standard Kernel for 64-bit Power based SMP and LPAR Machines
263 Group: System/Kernel
264 Provides: module-info, kernel = %{version}, k_smp4G
265 %ifarch %{all_x86} ia64 x86_64
266 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
267 %endif
268 %if %{rhbuild}
269 Prereq: %{kernel_prereq}
270 Conflicts: %{kernel_conflicts}
271 %endif
272
273 %description pseries64
274 The standard kernel for Power3, Power4 and PowerPC 970 64-bit SMP
275 machines.
276
277 This kernel can be used for all 64bit RS/6000, pSeries and JS20
278 machines.
279
280 %package bigmem
281 Summary: The Linux Kernel for machines with more than 4 Gigabyte of memory.
282 Group: System Environment/Kernel
283 Provides: module-info, kernel = %{version}
284 %ifarch %{all_x86} ia64 x86_64
285 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
286 %endif
287 %if %{rhbuild}
288 Prereq: %{kernel_prereq}
289 Conflicts: %{kernel_conflicts}
290 Obsoletes: kernel-enterprise <= 2.4.10
291 %endif
292
293 %description bigmem
294 This package includes a kernel that has appropriate configuration options
295 enabled for Pentium III machines with 4 Gigabyte of memory or more.
296
297 %package BOOT
298 Summary: The version of the Linux kernel used on installation boot disks.
299 Group: System Environment/Kernel
300 Provides: kernel = %{version}
301 %if %{rhbuild}
302 Prereq: %{BOOT_kernel_prereq}
303 Conflicts: %{kernel_conflicts}
304 %endif
305
306 %description BOOT
307 This package includes a trimmed down version of the Linux kernel.
308 This kernel is used on the installation boot disks only and should not
309 be used for an installed system, as many features in this kernel are
310 turned off because of the size constraints.
311
312 %package BOOTsmp
313 Summary: The Linux kernel used on installation boot disks for SMP machines.
314 Group: System Environment/Kernel
315 Provides: kernel = %{version}
316 %if %{rhbuild}
317 Prereq: %{BOOT_kernel_prereq}
318 Conflicts: %{kernel_conflicts}
319 %endif
320
321 %description BOOTsmp
322 This package includes a trimmed down version of the Linux kernel. This
323 kernel is used on the installation boot disks only and should not be used
324 for an installed system, as many features in this kernel are turned off
325 because of the size constraints. This kernel is used when booting SMP
326 machines that have trouble coming up to life with the uniprocessor kernel.
327
328 %package jensen
329 Summary: The Linux Kernel compiled for the Alpha Jensen platform.
330 Group: System Environment/Kernel
331 Provides: kernel = %{version}
332 %if %{rhbuild}
333 Prereq: %{kernel_prereq}
334 Conflicts: %{kernel_conflicts}
335 %endif
336
337 %description jensen
338 This package includes a kernel that has appropriate configuration
339 options enabled for use on the Alpha Jensen platform.  The Jensen
340 platform is not supported in the normal generic alpha kernel support.
341
342 %package -n lustre-lite-utils
343 Summary: Lustre utils for Linux
344 Group: Applications/System
345
346 %description -n lustre-lite-utils
347 The Lustre Lite file system utilities.  This includes the tools needed
348 to configure, mount, and administer a Lustre filesystem.  This package
349 is necessary if you want to access a Lustre filesystem.
350
351 # the lustre-doc files are just included as %doc wiht
352 # lustre-lite-utils
353
354 #%package -n lustre-doc
355 #Summary: Sample Lustre configurations and documentation
356 #Group: Documentation
357
358 #%description -n lustre-doc
359 #The Lustre book, sample configurations, and other documentation for
360 #Lustre.
361
362 %package -n lustre-ldap
363 Summary: LDAP schema files for Lustre
364 Group: System Environment/Daemons
365
366 %description -n lustre-ldap
367 LDAP schema files for Lustre.  These are needed if you plan to store
368 your Lustre configuration in LDAP, rather than on disk.
369
370 %prep
371 %setup -n lustre-kernel-%{version} -q -c
372 if [ ! -d lustre ] ; then
373     ln -sf lustre* lustre
374 fi
375 pushd lustre >/dev/null
376 if [ -s "%{SOURCE2}" ] ; then
377        tar zxf "%{SOURCE2}" -C lustre/kernel_patches
378 fi
379 sh -x ./build/lmake \
380         --unpack-kernel \
381         --target @LUSTRE_TARGET@ \
382         --target-arch %{_target_cpu} \
383         --kerneldir $RPM_SOURCE_DIR
384 popd >/dev/null
385
386 # handle both SuSE and Red Hat's new-kernel-pkg bits
387 for flavor in "" smp bigmem bigsmp pseries64 BOOT jensen ; do
388         for when in pre preun post postun ; do
389                 script="${when}${flavor}.sh"
390                 echo "if [ -f /etc/SuSE-release ] ; then" > ${script}
391                 sed -e "s/@when@/$when/g" -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE28} >> ${script}
392                 cat %{SOURCE25} >> ${script}
393                 case $when in
394                         post)
395                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE26} >> ${script}
396                                 ;;
397                         postun)
398                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE27} >> ${script}
399                                 ;;
400                 esac
401                 echo "exit 0; fi" >> ${script}
402                 case $when in
403                         post)
404                                 if [ -z "${flavor}" ] ; then
405                                         cat >> ${script} <<EOF
406 cd /boot
407 %ifnarch ia64 
408 ln -sf vmlinuz-%{KVERREL} vmlinuz
409 %endif
410 ln -sf System.map-%{KVERREL} System.map
411 ln -sf module-info-%{KVERREL} module-info
412 EOF
413                                 fi
414                                 cat >> ${script} <<EOF
415 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
416 [ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
417 if [ -x /sbin/new-kernel-pkg ] ; then
418         /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}${flavor}
419 fi
420 EOF
421                                 ;;
422                         postun)
423                                 ;;
424                         pre)
425                                 cat >> ${script} <<EOF
426 /sbin/modprobe loop 2>/dev/null >/dev/null || :
427 exit 0
428 EOF
429                                 ;;
430                         preun)
431                                 cat >> ${script} <<EOF
432 /sbin/modprobe loop 2> /dev/null > /dev/null  || :
433 rm -f /lib/modules/%{KVERREL}${flavor}/modules.*
434 if [ -x /sbin/new-kernel-pkg ] ; then
435  /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}${flavor}
436 fi
437 EOF
438                                 ;;
439                 esac
440         done
441
442         cat > "kernel$flavor.files" <<EOF
443 %%defattr(-, root, root)
444 /boot/%{kernel_glob}${flavor}
445 /boot/System.map-%{KVERREL}${flavor}
446 /boot/config-%{KVERREL}${flavor}
447 %%dir /lib/modules
448 %%dir /dev/shm
449 /lib/modules/%{KVERREL}${flavor}
450 %ifarch ia64
451 /boot/efi/redhat/%{kernel_glob}${flavor}
452 %endif
453 %if %{linux26}
454 %if %{susebuild}
455 /boot/Kerntypes-%{KVERREL}${flavor}
456 %endif
457 /boot/symvers-%{KVERREL}-%{_target_cpu}${flavor}.gz
458 %endif
459 EOF
460
461 done
462
463 cat > kernel-source.files <<EOF
464 %%defattr(-,root,root)
465 %%dir /usr/src/linux-%{KVERREL}
466 /usr/src/linux-%{KVERREL}/*
467 %if %{linux26}
468 %%dir /usr/src/linux-%{KVERREL}-obj
469 /usr/src/linux-%{KVERREL}-obj/*
470 %endif
471 EOF
472
473 %build
474 # if RPM_BUILD_NCPUS unset, set it
475 if [ -z "$RPM_BUILD_NCPUS" ] ; then
476     RPM_BUILD_NCPUS=$(egrep -c "^cpu[0-9]+" /proc/stat || :)
477     if [ $RPM_BUILD_NCPUS -eq 0 ] ; then
478         RPM_BUILD_NCPUS=1
479     fi
480     if [ $RPM_BUILD_NCPUS -gt 8 ] ; then
481         RPM_BUILD_NCPUS=8
482     fi
483 fi
484
485 rm -rf $RPM_BUILD_ROOT
486 mkdir -p $RPM_BUILD_ROOT
487
488 DependKernel()
489 {
490   target_config=${1:+--target-config $1}
491   sh -x ./build/lmake \
492         --depend-kernel \
493         --target @LUSTRE_TARGET@ \
494         --target-arch %{_target_cpu} \
495         ${target_config} \
496         --extraversion %{kextraver} \
497         -j $RPM_BUILD_NCPUS
498 }
499
500 BuildKernel()
501 {
502   target_config=${1:+--target-config $1}
503   sh -x ./build/lmake \
504         --build-kernel --build-lustre \
505         --install \
506         --save-headers \
507         --target @LUSTRE_TARGET@ \
508         --target-arch %{_target_cpu} \
509         ${target_config} \
510         --extraversion %{kextraver} \
511         --kerneldir $RPM_SOURCE_DIR \
512         -j $RPM_BUILD_NCPUS \
513         --destdir $RPM_BUILD_ROOT \
514         -- --enable-modules \
515         --disable-doc --disable-tests \
516         --disable-utils --disable-liblustre \
517         --sysconfdir=%{_sysconfdir} \
518         --mandir=%{_mandir} \
519         @CONFIGURE_FLAGS@
520 }
521
522 BuildLustre()
523 {
524   target_config=${1:+--target-config $1}
525   sh -x ./build/lmake \
526         --build-lustre \
527         --install-lustre \
528         --target @LUSTRE_TARGET@ \
529         --target-arch %{_target_cpu} \
530         ${target_config} \
531         --extraversion %{kextraver} \
532         --kerneldir $RPM_SOURCE_DIR \
533         -j $RPM_BUILD_NCPUS \
534         --destdir $RPM_BUILD_ROOT \
535         -- --enable-utils \
536         --disable-doc --disable-tests \
537         --disable-modules --disable-liblustre \
538         --sysconfdir=%{_sysconfdir} \
539         --mandir=%{_mandir} \
540         @CONFIGURE_FLAGS@
541 }
542
543 SaveHeaders()
544 {
545   sh -x ./build/lmake \
546         --save-headers \
547         --target @LUSTRE_TARGET@ \
548         --target-arch %{_target_cpu} \
549         --extraversion %{kextraver} \
550         --destdir $RPM_BUILD_ROOT
551 }
552
553 pushd lustre >/dev/null
554
555 %if %{buildbigmem}
556 BuildKernel bigmem
557 %endif
558
559 %if %{buildBOOT}
560 BuildKernel BOOT
561 %endif
562
563 %if %{buildjensen}
564 BuildKernel jensen
565 %endif
566
567 %if %{buildsmp}
568 BuildKernel smp
569 %endif
570
571 %if %{buildbigsmp}
572 BuildKernel bigsmp
573 %endif
574
575 %if %{buildpseries64}
576 BuildKernel pseries64
577 %endif
578
579 %if %{buildup}
580 BuildKernel
581 %endif
582
583 %if %{buildbase}
584 BuildLustre
585 %endif
586
587 popd >/dev/null
588
589 %install
590 pushd lustre >/dev/null
591 # it's already installed, so just clean up some things that are rpm
592 # specific
593 for i in $RPM_BUILD_ROOT/lib/modules/* ; do
594   rm -f $i/modules.*
595   rm -f $i/build
596   ln -sf ../../../usr/src/linux-%{KVERREL} $i/build
597 %ifarch %{ntplarchs}
598   # remove legacy pcmcia symlink that's no longer useful
599   rm -rf $i/pcmcia
600 %endif
601 done
602
603 # mark the vmlinux* non-executable to fool strip-to-file
604 chmod a-x $RPM_BUILD_ROOT/boot/vmlinux*
605
606 BuildObj ()
607 {
608         flavor=$1
609         if [ $flavor = "up" ] ; then
610                 flavext=""
611                 flavtgt=""
612         else
613                 flavext="-$flavor"
614                 flavtgt="$flavor"
615         fi
616         perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}${flavtgt}/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
617         c="$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}"
618         o="${c}-obj/%{_target_cpu}/$flavor"
619         mkdir -p $o
620         cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}${flavext}.config \
621                 $o/.config
622         for oc in oldconfig_nonint silentoldconfig oldconfig ; do
623             if grep -q "$oc" Makefile ; then
624                 OLDCONFIG="$oc"
625                 break
626             fi
627         done
628         MAKE="make -s O=$o -C ${c}"
629         if [ "$CC" ] ; then
630             MAKE_CC="CC=$CC"
631         fi
632         $MAKE "$MAKE_CC" $OLDCONFIG
633         $MAKE "$MAKE_CC" prepare-all
634         $MAKE clean
635         rm -rf $o/.config.old $o/include/config
636         # Replace the Makefile in the object directory with a version
637         # that has relative path names.
638         read VERSION PATCHLEVEL SUBLEVEL <<-EOF
639 $(set -- 2.6.5 ; echo ${*//./ })
640 EOF
641         source scripts/mkmakefile \
642             ../../../linux-%{KVERREL} \
643             ../linux-%{KVERREL}-obj/%{_target_cpu}/$flavor \
644             $VERSION \
645             $PATCHLEVEL \
646             > $o/Makefile
647         zcat "$RPM_BUILD_ROOT/boot/symvers-%{KVERREL}-%{_target_cpu}${flavor}.gz" \
648             > $o/Module.symvers
649 }
650
651 ##
652 ## do -source package cleanup/install
653 ##
654 if [ "%{buildbase}" -ne 0 ] ; then
655     pushd linux >/dev/null
656     mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
657     rm -f drivers/net/hamradio/soundmodem/gentbl scripts/mkdep
658     tar cf - . | tar xf - -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
659     ln -sf linux-%{KVERREL} $RPM_BUILD_ROOT/usr/src/linux
660     # install -m 644 %{SOURCE10}  $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
661
662     #clean up the destination
663     make -s mrproper -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
664     rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
665     mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
666     cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@*.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
667     if [ "%{linux26}" -ne 0 ] ; then
668         # this only works because CFS only builds one kernel per target/arch per kernel-source rpm
669         objdir=$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}-obj
670         mkdir -p $objdir
671         if [ "%{buildbigmem}" -ne 0 ] ; then
672             BuildObj bigmem
673         fi
674         if [ "%{buildBOOT}" -ne 0 ] ; then
675             BuildObj BOOT
676         fi
677         if [ "%{buildjensen}" -ne 0 ] ; then
678             BuildObj jensen
679         fi
680         if [ "%{buildsmp}" -ne 0 ] ; then
681             BuildObj smp
682         fi
683         if [ "%{buildbigsmp}" -ne 0 ] ; then
684             BuildObj bigsmp
685         fi
686         if [ "%{buildpseries64}" -ne 0 ] ; then
687             BuildObj pseries64
688         fi
689         if [ "%{buildup}" -ne 0 ] ; then
690             BuildObj up
691         fi
692         perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
693         # Remove $RPM_BUILD_ROOT prefix from symlinks.
694         for link in $(find $objdir -type l); do
695             target=$(readlink $link)
696             rm -f $link
697             ln -s ${target/$RPM_BUILD_ROOT/} $link
698         done
699     else # 2.4 rh-style
700         perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
701         cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config
702         for oc in oldconfig_nonint silentoldconfig oldconfig ; do
703             if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then
704                 OLDCONFIG="$oc"
705                 break
706             fi
707         done
708         if [ "$CC" ] ; then
709             MAKE_CC="CC=$CC"
710         fi
711         make "$MAKE_CC" -s $OLDCONFIG -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
712         make "$MAKE_CC" -s symlinks -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
713         make "$MAKE_CC" -s include/linux/version.h -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
714
715         #this generates modversions info which we want to include and we may as
716         #well include the depends stuff as well, after we fix the paths
717         make -s depend -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
718         find $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} -name ".*depend" | \
719         while read file ; do
720             mv $file $file.old
721             sed -e "s|[^ ]*\(/usr/src/linux\)|\1|g" < $file.old > $file
722             rm -f $file.old
723         done
724
725         # Try to put some smarter autoconf.h and version.h files in place
726         pushd $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/include/linux ; {
727         rm -rf modules modversions.h autoconf.h version.h
728         cat > modversions.h <<EOF
729 #ifndef _LINUX_MODVERSIONS_H
730 #define _LINUX_MODVERSIONS_H
731 #include <linux/rhconfig.h>
732 #include <linux/modsetver.h>
733 EOF
734         echo '#include <linux/rhconfig.h>' > autoconf.h
735         list=`find ../../savedheaders/* -name '*.ver' -exec basename '{}' \; | sort`
736         mkdir modules
737         for l in $list; do
738             sed 's,$,modules/'$l, ../../savedheaders/list | awk -f %{SOURCE17} > modules/$l
739             touch -r modules/$l modules/`basename $l .ver`.stamp
740             echo '#include <linux/modules/'$l'>' >> modversions.h
741         done
742         echo '#endif' >> modversions.h
743         sed 's,$,autoconf.h,' ../../savedheaders/list | awk -f %{SOURCE16} >> autoconf.h
744         install -m 644 %{SOURCE15} rhconfig.h
745         echo "#include <linux/rhconfig.h>" >> version.h
746         keyword=if
747         for i in smp BOOT BOOTsmp bigmem bigsmp pseries64 up ; do
748             # When we build in an i386, we don't have an bigmem header directory
749             # in savedheaders/i386/bigmem.  We also don't have a BOOT directory
750             # anywhere except in savedheaders/i386.  So, we need to use this method
751             # of determining if a kernel version string needs to be included in the
752             # version.h file
753             verh=`echo ../../savedheaders/*/$i/version.h | awk ' { print $1 } '`
754             if [ -n "$verh" -a -f "$verh" ]; then
755                 if [ "$i" = up ]; then
756                     if [ "$keyword" = if ]; then
757                         echo "#if 0" >> version.h
758                     fi
759                     echo "#else" >> version.h
760                 else
761                     echo "#$keyword defined(__module__$i)" >> version.h
762                     keyword=elif
763                 fi
764                 grep UTS_RELEASE $verh >> version.h
765             fi
766             done
767         echo "#endif" >> version.h
768         if [ -f ../../savedheaders/%{_target_cpu}/up/version.h ] ; then
769             # keep to a standard normally
770             HEADER_FILE=../../savedheaders/%{_target_cpu}/up/version.h
771         else
772             # test build not including uniprocessor, must get info from somewhere
773             HEADER_FILE=$(ls ../../savedheaders/*/*/version.h | head -n 1)
774         fi
775         grep -v UTS_RELEASE $HEADER_FILE >> version.h
776         rm -rf ../../savedheaders
777         } ; popd
778         touch $RPM_BUILD_ROOT/boot/kernel.h-%{kversion}
779         
780         # rm -f $RPM_BUILD_ROOT/usr/include/linux
781         
782         rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/savedheaders
783         
784         if [ "%{rhbuild}" -ne 0 ] ; then
785             # fix up the tmp_include_depends file wrt the buildroot
786             perl -p -i -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/tmp_include_depends
787         fi
788     fi # linux26
789     popd >/dev/null
790 fi # buildbase
791
792 popd >/dev/null
793
794 %clean
795 rm -rf $RPM_BUILD_ROOT
796
797 ###
798 ### scripts
799 ###
800
801 # do this for upgrades...in case the old modules get removed we have
802 # loopback in the kernel so that mkinitrd will work.
803 %pre -f pre.sh
804
805 %pre smp -f presmp.sh
806
807 %pre bigsmp -f prebigsmp.sh
808
809 %pre pseries64 -f prepseries64.sh
810
811 %pre bigmem -f prebigmem.sh
812
813 %post -f post.sh
814
815 %post pseries64 -f postpseries64.sh
816
817 %post smp -f postsmp.sh
818
819 %post bigsmp -f postbigsmp.sh
820
821 %post bigmem -f postbigmem.sh
822
823 %post jensen -f postjensen.sh
824
825 %ifnarch ia64
826 %post BOOT -f postBOOT.sh
827
828 %endif
829
830 %post -n lustre-lite-utils
831 if [ ! -e /dev/obd ]; then
832    mknod /dev/obd c 10 241
833 fi
834 if [ ! -e /dev/portals ]; then
835    mknod /dev/portals c 10 240
836 fi
837 if [ -f /etc/init.d/lustre ] ; then
838         /sbin/chkconfig --add lustre
839         /sbin/chkconfig --add lustrefs
840 fi
841
842 # Allow clean removal of modules directory
843 %preun -f preun.sh
844
845 %preun pseries64 -f preunpseries64.sh
846
847 %preun smp -f preunsmp.sh
848
849 %preun bigsmp -f preunbigsmp.sh
850
851 %preun bigmem -f preunbigmem.sh
852
853 %preun BOOT -f preunBOOT.sh
854
855 %preun jensen -f preunjensen.sh
856
857 # suse needs these i guess
858 %postun -f postun.sh
859
860 %postun pseries64 -f postunpseries64.sh
861
862 %postun smp -f postunsmp.sh
863
864 %postun bigsmp -f postunbigsmp.sh
865
866 %postun bigmem -f postunbigmem.sh
867
868 %postun BOOT -f postunBOOT.sh
869
870 %postun jensen -f postunjensen.sh
871
872 # We need this here because we don't prereq kudzu; it could be
873 # installed after the kernel
874 %triggerin -- kudzu
875 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
876
877 %triggerin smp -- kudzu
878 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
879
880 %triggerin bigsmp -- kudzu
881 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
882
883 %triggerin pseries64 -- kudzu
884 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
885
886 %triggerin bigmem -- kudzu
887 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
888
889 %triggerin BOOT -- kudzu
890 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
891
892 %triggerin jensen -- kudzu
893 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
894
895
896 # Old kernel-headers packages owned include symlinks; new
897 # ones just make them so that we can have multiple kernel-headers
898 # packages installed.
899
900 %triggerpostun source -- kernel-headers < 2.2.16
901 cd /usr/src
902 rm -f %{kslnk}
903 ln -snf linux-%{KVERREL} %{kslnk}
904 exit 0
905
906 %post source
907 cd /usr/src
908 rm -f %{kslnk}
909 ln -snf linux-%{KVERREL} %{kslnk}
910
911 %postun source
912 if [ -L /usr/src/%{kslnk} ]; then 
913     if [ -L /usr/src/%{kslnk} -a `ls -ld /usr/src/%{kslnk} 2>/dev/null| awk '{ print $11 }'` = "linux-%{KVERREL}" ]; then
914         [ $1 = 0 ] && rm -f /usr/src/%{kslnk}
915     fi
916 fi
917 exit 0
918
919 %preun -n lustre-lite-utils
920 if [ $1 = 0 -a -f /etc/init.d/lustre ]; then
921         /sbin/chkconfig --del lustre
922         /sbin/chkconfig --del lustrefs
923 fi
924
925 ###
926 ### file lists
927 ###
928
929 %if %{buildup}
930 %files -f kernel.files
931 %endif
932
933 %if %{buildsmp}
934 %files smp -f kernelsmp.files
935 %endif
936
937 %if %{buildbigsmp}
938 %files bigsmp -f kernelbigsmp.files
939 %endif
940
941 %if %{buildpseries64}
942 %files pseries64 -f kernelpseries64.files
943 %endif
944
945 %if %{buildbigmem}
946 %files bigmem -f kernelbigmem.files
947 %endif
948
949 %if %{buildBOOT}
950 %files BOOT -f kernelBOOT.files
951 %endif
952
953 %if %{buildbase}
954
955 %files source -f kernel-source.files
956
957 %files doc
958 %defattr(-,root,root)
959 %doc lustre/linux/Documentation/*
960
961 %files -n lustre-lite-utils
962 %defattr(-, root, root)
963 %doc lustre/COPYING lustre/lustre/BUGS lustre/ChangeLog lustre/README lustre/lustre/doc/lustre.pdf
964 /sbin/*
965 /usr/sbin/*
966 /usr/bin/*
967 /usr/lib/lustre/python
968 @ENABLE_INIT_SCRIPTS@/etc/init.d/lustre
969 @ENABLE_INIT_SCRIPTS@/etc/init.d/lustrefs
970 /usr/include/lustre/*
971 /usr/include/linux/*
972 /usr/lib/lib*.a
973 /usr/share/man/man?/*
974
975 #%files -n lustre-doc
976 #%defattr(-, root, root)
977 #/usr/share/doc/lustre/COPYING
978 #/usr/share/doc/lustre/lustre.pdf
979 #/usr/share/doc/lustre/COPYING
980
981 /usr/share/lustre/examples
982
983 %files -n lustre-ldap
984 %defattr(-, root, root)
985 /etc/openldap/slapd-lustre.conf
986 /etc/openldap/schema/lustre.schema
987 /usr/share/lustre/lustre2ldif.xsl
988 /usr/share/lustre/top.ldif
989
990 %endif # %{buildbase}