Whamcloud - gitweb
d03e614edb403c187ac6aa290d1cee6d3d80f2ba
[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 Source29: sles8-post.sh
189 Source30: sles8-postun.sh
190 Source31: sles8-pre.sh
191 Source32: sles8-update_INITRD_MODULES.sh
192 Source33: sles8-update_rcfile_setting.sh
193
194 %package source
195 Summary: The source code for the Linux kernel.
196 Group: Development/System
197 Prereq: fileutils
198 Requires: gawk
199 Requires: gcc >= 2.96-98
200 Autoreqprov: 0
201
202 %package doc
203 Summary: Various documentation bits found in the kernel source.
204 Group: Documentation
205
206 %description
207 The kernel package contains the Linux kernel (vmlinuz), the core of a
208 Linux operating system.  The kernel handles the basic functions of the
209 operating system: memory allocation, process allocation, device input
210 and output, etc.
211
212 %description source
213 The kernel-source package contains the source code files for the Linux
214 kernel. These source files are needed to build custom/third party device
215 drivers. The source files can also be used to build a custom kernel that is
216 better tuned to your particular hardware, if you are so inclined (and you
217 know what you're doing).
218
219 %description doc
220 This package contains documentation files form the kernel
221 source. Various bits of information about the Linux kernel and the
222 device drivers shipped with it are documented in these files. 
223
224 You'll want to install this package if you need a reference to the
225 options that can be passed to Linux kernel modules at load time.
226
227 %package smp
228 Summary: The Linux kernel compiled for SMP machines.
229 Group: System Environment/Kernel
230 Provides: module-info, kernel = %{version}
231 %ifarch %{all_x86} ia64 x86_64
232 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
233 %endif
234 %if %{rhbuild}
235 Prereq: %{kernel_prereq}
236 Conflicts: %{kernel_conflicts}
237 %endif
238
239 %description smp
240 This package includes a SMP version of the Linux kernel. It is
241 required only on machines with two or more CPUs, although it should
242 work fine on single-CPU boxes.
243
244 Install the kernel-smp package if your machine uses two or more CPUs.
245
246 %package bigsmp
247 Summary: The Linux kernel compiled for SMP machines.
248 Group: System/Kernel
249 Provides: module-info, kernel = %{version}, k_smp4G
250 Obsoletes: k_smp4G
251 %ifarch %{all_x86} ia64 x86_64
252 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
253 %endif
254 %if %{rhbuild}
255 Prereq: %{kernel_prereq}
256 Conflicts: %{kernel_conflicts}
257 %endif
258
259 %description bigsmp
260 This package includes a SMP version of the Linux kernel. It is
261 required only on machines with two or more CPUs, although it should
262 work fine on single-CPU boxes.
263
264 Install the kernel-bigsmp package if your machine uses two or more CPUs.
265
266 %package pseries64
267 Summary: Standard Kernel for 64-bit Power based SMP and LPAR Machines
268 Group: System/Kernel
269 Provides: module-info, kernel = %{version}, k_smp4G
270 %ifarch %{all_x86} ia64 x86_64
271 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
272 %endif
273 %if %{rhbuild}
274 Prereq: %{kernel_prereq}
275 Conflicts: %{kernel_conflicts}
276 %endif
277
278 %description pseries64
279 The standard kernel for Power3, Power4 and PowerPC 970 64-bit SMP
280 machines.
281
282 This kernel can be used for all 64bit RS/6000, pSeries and JS20
283 machines.
284
285 %package bigmem
286 Summary: The Linux Kernel for machines with more than 4 Gigabyte of memory.
287 Group: System Environment/Kernel
288 Provides: module-info, kernel = %{version}
289 %ifarch %{all_x86} ia64 x86_64
290 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
291 %endif
292 %if %{rhbuild}
293 Prereq: %{kernel_prereq}
294 Conflicts: %{kernel_conflicts}
295 Obsoletes: kernel-enterprise <= 2.4.10
296 %endif
297
298 %description bigmem
299 This package includes a kernel that has appropriate configuration options
300 enabled for Pentium III machines with 4 Gigabyte of memory or more.
301
302 %package BOOT
303 Summary: The version of the Linux kernel used on installation boot disks.
304 Group: System Environment/Kernel
305 Provides: kernel = %{version}
306 %if %{rhbuild}
307 Prereq: %{BOOT_kernel_prereq}
308 Conflicts: %{kernel_conflicts}
309 %endif
310
311 %description BOOT
312 This package includes a trimmed down version of the Linux kernel.
313 This kernel is used on the installation boot disks only and should not
314 be used for an installed system, as many features in this kernel are
315 turned off because of the size constraints.
316
317 %package BOOTsmp
318 Summary: The Linux kernel used on installation boot disks for SMP machines.
319 Group: System Environment/Kernel
320 Provides: kernel = %{version}
321 %if %{rhbuild}
322 Prereq: %{BOOT_kernel_prereq}
323 Conflicts: %{kernel_conflicts}
324 %endif
325
326 %description BOOTsmp
327 This package includes a trimmed down version of the Linux kernel. This
328 kernel is used on the installation boot disks only and should not be used
329 for an installed system, as many features in this kernel are turned off
330 because of the size constraints. This kernel is used when booting SMP
331 machines that have trouble coming up to life with the uniprocessor kernel.
332
333 %package jensen
334 Summary: The Linux Kernel compiled for the Alpha Jensen platform.
335 Group: System Environment/Kernel
336 Provides: kernel = %{version}
337 %if %{rhbuild}
338 Prereq: %{kernel_prereq}
339 Conflicts: %{kernel_conflicts}
340 %endif
341
342 %description jensen
343 This package includes a kernel that has appropriate configuration
344 options enabled for use on the Alpha Jensen platform.  The Jensen
345 platform is not supported in the normal generic alpha kernel support.
346
347 %package -n lustre-lite-utils
348 Summary: Lustre utils for Linux
349 Group: Applications/System
350
351 %description -n lustre-lite-utils
352 The Lustre Lite file system utilities.  This includes the tools needed
353 to configure, mount, and administer a Lustre filesystem.  This package
354 is necessary if you want to access a Lustre filesystem.
355
356 # the lustre-doc files are just included as %doc wiht
357 # lustre-lite-utils
358
359 #%package -n lustre-doc
360 #Summary: Sample Lustre configurations and documentation
361 #Group: Documentation
362
363 #%description -n lustre-doc
364 #The Lustre book, sample configurations, and other documentation for
365 #Lustre.
366
367 %package -n lustre-ldap
368 Summary: LDAP schema files for Lustre
369 Group: System Environment/Daemons
370
371 %description -n lustre-ldap
372 LDAP schema files for Lustre.  These are needed if you plan to store
373 your Lustre configuration in LDAP, rather than on disk.
374
375 %prep
376 %setup -n lustre-kernel-%{version} -q -c
377 if [ ! -d lustre ] ; then
378     ln -sf lustre* lustre
379 fi
380 pushd lustre >/dev/null
381 if [ -s "%{SOURCE2}" ] ; then
382        tar zxf "%{SOURCE2}" -C lustre/kernel_patches
383 fi
384 sh -x ./build/lmake \
385         --unpack-kernel \
386         --target @LUSTRE_TARGET@ \
387         --target-arch %{_target_cpu} \
388         --kerneldir $RPM_SOURCE_DIR
389 popd >/dev/null
390
391 # handle both SuSE and Red Hat's new-kernel-pkg bits
392 for flavor in "" smp bigmem bigsmp pseries64 BOOT jensen ; do
393         for when in pre preun post postun ; do
394                 script="${when}${flavor}.sh"
395                 cat %{SOURCE25} %{SOURCE32} %{SOURCE33} > ${script}
396                 echo "if [ -d /etc/susehelp.d ] ; then" >> ${script}
397                 sed -e "s/@when@/$when/g" -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE28} >> ${script}
398                 case $when in
399                         pre)
400                                 echo "if [ ! -f /etc/modprobe.conf ] ; then" >> ${script}
401                                 cat %{SOURCE31} >> ${script}
402                                 echo "fi" >> ${script}
403                                 ;;
404                         post)
405                                 echo "if [ -f /etc/modprobe.conf ] ; then" >> ${script}                 
406                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE26} >> ${script}
407
408                                 echo "else" >> ${script}
409                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" -e "s^%%{cfg_name}^${flavor}^g" %{SOURCE29} >> ${script}
410                                 echo "fi" >> ${script}
411                                 ;;
412                         postun)
413                                 echo "if [ -f /etc/modprobe.conf ] ; then" >> ${script}                 
414                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE27} >> ${script}
415
416                                 echo "else" >> ${script}                        
417                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE30} >> ${script}
418                                 echo "fi" >> ${script}
419                                 ;;
420                 esac
421                 echo "exit 0; fi" >> ${script}
422                 case $when in
423                         post)
424                                 if [ -z "${flavor}" ] ; then
425                                         cat >> ${script} <<EOF
426 cd /boot
427 %ifnarch ia64 
428 ln -sf vmlinuz-%{KVERREL} vmlinuz
429 %endif
430 ln -sf System.map-%{KVERREL} System.map
431 ln -sf module-info-%{KVERREL} module-info
432 EOF
433                                 fi
434                                 cat >> ${script} <<EOF
435 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
436 [ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
437 if [ -x /sbin/new-kernel-pkg ] ; then
438         /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}${flavor}
439 fi
440 EOF
441                                 ;;
442                         postun)
443                                 ;;
444                         pre)
445                                 cat >> ${script} <<EOF
446 /sbin/modprobe loop 2>/dev/null >/dev/null || :
447 exit 0
448 EOF
449                                 ;;
450                         preun)
451                                 cat >> ${script} <<EOF
452 /sbin/modprobe loop 2> /dev/null > /dev/null  || :
453 rm -f /lib/modules/%{KVERREL}${flavor}/modules.*
454 if [ -x /sbin/new-kernel-pkg ] ; then
455  /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}${flavor}
456 fi
457 EOF
458                                 ;;
459                 esac
460         done
461
462         cat > "kernel$flavor.files" <<EOF
463 %%defattr(-, root, root)
464 /boot/%{kernel_glob}${flavor}
465 /boot/System.map-%{KVERREL}${flavor}
466 /boot/config-%{KVERREL}${flavor}
467 %%dir /lib/modules
468 %%dir /dev/shm
469 /lib/modules/%{KVERREL}${flavor}
470 %ifarch ia64
471 /boot/efi/redhat/%{kernel_glob}${flavor}
472 %endif
473 %if %{linux26}
474 %if %{susebuild}
475 /boot/Kerntypes-%{KVERREL}${flavor}
476 %endif
477 /boot/symvers-%{KVERREL}-%{_target_cpu}${flavor}.gz
478 %endif
479 EOF
480
481 done
482
483 cat > kernel-source.files <<EOF
484 %%defattr(-,root,root)
485 %%dir /usr/src/linux-%{KVERREL}
486 /usr/src/linux-%{KVERREL}/*
487 %if %{linux26}
488 %%dir /usr/src/linux-%{KVERREL}-obj
489 /usr/src/linux-%{KVERREL}-obj/*
490 %endif
491 EOF
492
493 %build
494 # if RPM_BUILD_NCPUS unset, set it
495 if [ -z "$RPM_BUILD_NCPUS" ] ; then
496     RPM_BUILD_NCPUS=$(egrep -c "^cpu[0-9]+" /proc/stat || :)
497     if [ $RPM_BUILD_NCPUS -eq 0 ] ; then
498         RPM_BUILD_NCPUS=1
499     fi
500     if [ $RPM_BUILD_NCPUS -gt 8 ] ; then
501         RPM_BUILD_NCPUS=8
502     fi
503 fi
504
505 rm -rf $RPM_BUILD_ROOT
506 mkdir -p $RPM_BUILD_ROOT
507
508 DependKernel()
509 {
510   target_config=${1:+--target-config $1}
511   sh -x ./build/lmake \
512         --depend-kernel \
513         --target @LUSTRE_TARGET@ \
514         --target-arch %{_target_cpu} \
515         ${target_config} \
516         --extraversion %{kextraver} \
517         -j $RPM_BUILD_NCPUS
518 }
519
520 BuildKernel()
521 {
522   target_config=${1:+--target-config $1}
523   sh -x ./build/lmake \
524         --build-kernel --build-lustre \
525         --install \
526         --save-headers \
527         --target @LUSTRE_TARGET@ \
528         --target-arch %{_target_cpu} \
529         ${target_config} \
530         --extraversion %{kextraver} \
531         --kerneldir $RPM_SOURCE_DIR \
532         -j $RPM_BUILD_NCPUS \
533         --destdir $RPM_BUILD_ROOT \
534         -- --enable-modules \
535         --disable-doc --disable-tests \
536         --disable-utils --disable-liblustre \
537         --sysconfdir=%{_sysconfdir} \
538         --mandir=%{_mandir} \
539         @CONFIGURE_FLAGS@
540 }
541
542 BuildLustre()
543 {
544   target_config=${1:+--target-config $1}
545   sh -x ./build/lmake \
546         --build-lustre \
547         --install-lustre \
548         --target @LUSTRE_TARGET@ \
549         --target-arch %{_target_cpu} \
550         ${target_config} \
551         --extraversion %{kextraver} \
552         --kerneldir $RPM_SOURCE_DIR \
553         -j $RPM_BUILD_NCPUS \
554         --destdir $RPM_BUILD_ROOT \
555         -- --enable-utils \
556         --disable-doc --disable-tests \
557         --disable-modules --disable-liblustre \
558         --sysconfdir=%{_sysconfdir} \
559         --mandir=%{_mandir} \
560         @CONFIGURE_FLAGS@
561 }
562
563 SaveHeaders()
564 {
565   sh -x ./build/lmake \
566         --save-headers \
567         --target @LUSTRE_TARGET@ \
568         --target-arch %{_target_cpu} \
569         --extraversion %{kextraver} \
570         --destdir $RPM_BUILD_ROOT
571 }
572
573 pushd lustre >/dev/null
574
575 %if %{buildbigmem}
576 BuildKernel bigmem
577 %endif
578
579 %if %{buildBOOT}
580 BuildKernel BOOT
581 %endif
582
583 %if %{buildjensen}
584 BuildKernel jensen
585 %endif
586
587 %if %{buildsmp}
588 BuildKernel smp
589 %endif
590
591 %if %{buildbigsmp}
592 BuildKernel bigsmp
593 %endif
594
595 %if %{buildpseries64}
596 BuildKernel pseries64
597 %endif
598
599 %if %{buildup}
600 BuildKernel
601 %endif
602
603 %if %{buildbase}
604 BuildLustre
605 %endif
606
607 popd >/dev/null
608
609 %install
610 pushd lustre >/dev/null
611 # it's already installed, so just clean up some things that are rpm
612 # specific
613 for i in $RPM_BUILD_ROOT/lib/modules/* ; do
614   rm -f $i/modules.*
615   rm -f $i/build
616   ln -sf ../../../usr/src/linux-%{KVERREL} $i/build
617 %ifarch %{ntplarchs}
618   # remove legacy pcmcia symlink that's no longer useful
619   rm -rf $i/pcmcia
620 %endif
621 done
622
623 # mark the vmlinux* non-executable to fool strip-to-file
624 chmod a-x $RPM_BUILD_ROOT/boot/vmlinux*
625
626 BuildObj ()
627 {
628         flavor=$1
629         if [ $flavor = "up" ] ; then
630                 flavext=""
631                 flavtgt=""
632         else
633                 flavext="-$flavor"
634                 flavtgt="$flavor"
635         fi
636         perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}${flavtgt}/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
637         c="$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}"
638         o="${c}-obj/%{_target_cpu}/$flavor"
639         mkdir -p $o
640         cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}${flavext}.config \
641                 $o/.config
642         for oc in oldconfig_nonint silentoldconfig oldconfig ; do
643             if grep -q "$oc" Makefile ; then
644                 OLDCONFIG="$oc"
645                 break
646             fi
647         done
648         MAKE="make -s O=$o -C ${c}"
649         if [ "$CC" ] ; then
650             MAKE_CC="CC=$CC"
651         fi
652         $MAKE "$MAKE_CC" $OLDCONFIG
653         $MAKE "$MAKE_CC" prepare-all
654         $MAKE clean
655         rm -rf $o/.config.old $o/include/config
656         # Replace the Makefile in the object directory with a version
657         # that has relative path names.
658         read VERSION PATCHLEVEL SUBLEVEL <<-EOF
659 $(set -- 2.6.5 ; echo ${*//./ })
660 EOF
661         source scripts/mkmakefile \
662             ../../../linux-%{KVERREL} \
663             ../linux-%{KVERREL}-obj/%{_target_cpu}/$flavor \
664             $VERSION \
665             $PATCHLEVEL \
666             > $o/Makefile
667         zcat "$RPM_BUILD_ROOT/boot/symvers-%{KVERREL}-%{_target_cpu}${flavor}.gz" \
668             > $o/Module.symvers
669 }
670
671 ##
672 ## do -source package cleanup/install
673 ##
674 if [ "%{buildbase}" -ne 0 ] ; then
675     pushd linux >/dev/null
676     mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
677     rm -f drivers/net/hamradio/soundmodem/gentbl scripts/mkdep
678     tar cf - . | tar xf - -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
679     ln -sf linux-%{KVERREL} $RPM_BUILD_ROOT/usr/src/linux
680     # install -m 644 %{SOURCE10}  $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
681
682     #clean up the destination
683     make -s mrproper -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
684     rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
685     mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
686     cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@*.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
687     if [ "%{linux26}" -ne 0 ] ; then
688         # this only works because CFS only builds one kernel per target/arch per kernel-source rpm
689         objdir=$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}-obj
690         mkdir -p $objdir
691         if [ "%{buildbigmem}" -ne 0 ] ; then
692             BuildObj bigmem
693         fi
694         if [ "%{buildBOOT}" -ne 0 ] ; then
695             BuildObj BOOT
696         fi
697         if [ "%{buildjensen}" -ne 0 ] ; then
698             BuildObj jensen
699         fi
700         if [ "%{buildsmp}" -ne 0 ] ; then
701             BuildObj smp
702         fi
703         if [ "%{buildbigsmp}" -ne 0 ] ; then
704             BuildObj bigsmp
705         fi
706         if [ "%{buildpseries64}" -ne 0 ] ; then
707             BuildObj pseries64
708         fi
709         if [ "%{buildup}" -ne 0 ] ; then
710             BuildObj up
711         fi
712         perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
713         # Remove $RPM_BUILD_ROOT prefix from symlinks.
714         for link in $(find $objdir -type l); do
715             target=$(readlink $link)
716             rm -f $link
717             ln -s ${target/$RPM_BUILD_ROOT/} $link
718         done
719     else # 2.4 rh-style
720         perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
721         cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config
722         for oc in oldconfig_nonint silentoldconfig oldconfig ; do
723             if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then
724                 OLDCONFIG="$oc"
725                 break
726             fi
727         done
728         if [ "$CC" ] ; then
729             MAKE_CC="CC=$CC"
730         fi
731         make "$MAKE_CC" -s $OLDCONFIG -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
732         make "$MAKE_CC" -s symlinks -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
733         make "$MAKE_CC" -s include/linux/version.h -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
734
735         #this generates modversions info which we want to include and we may as
736         #well include the depends stuff as well, after we fix the paths
737         make -s depend -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
738         find $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} -name ".*depend" | \
739         while read file ; do
740             mv $file $file.old
741             sed -e "s|[^ ]*\(/usr/src/linux\)|\1|g" < $file.old > $file
742             rm -f $file.old
743         done
744
745         # Try to put some smarter autoconf.h and version.h files in place
746         pushd $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/include/linux ; {
747         rm -rf modules modversions.h autoconf.h version.h
748         cat > modversions.h <<EOF
749 #ifndef _LINUX_MODVERSIONS_H
750 #define _LINUX_MODVERSIONS_H
751 #include <linux/rhconfig.h>
752 #include <linux/modsetver.h>
753 EOF
754         echo '#include <linux/rhconfig.h>' > autoconf.h
755         list=`find ../../savedheaders/* -name '*.ver' -exec basename '{}' \; | sort`
756         mkdir modules
757         for l in $list; do
758             sed 's,$,modules/'$l, ../../savedheaders/list | awk -f %{SOURCE17} > modules/$l
759             touch -r modules/$l modules/`basename $l .ver`.stamp
760             echo '#include <linux/modules/'$l'>' >> modversions.h
761         done
762         echo '#endif' >> modversions.h
763         sed 's,$,autoconf.h,' ../../savedheaders/list | awk -f %{SOURCE16} >> autoconf.h
764         install -m 644 %{SOURCE15} rhconfig.h
765         echo "#include <linux/rhconfig.h>" >> version.h
766         keyword=if
767         for i in smp BOOT BOOTsmp bigmem bigsmp pseries64 up ; do
768             # When we build in an i386, we don't have an bigmem header directory
769             # in savedheaders/i386/bigmem.  We also don't have a BOOT directory
770             # anywhere except in savedheaders/i386.  So, we need to use this method
771             # of determining if a kernel version string needs to be included in the
772             # version.h file
773             verh=`echo ../../savedheaders/*/$i/version.h | awk ' { print $1 } '`
774             if [ -n "$verh" -a -f "$verh" ]; then
775                 if [ "$i" = up ]; then
776                     if [ "$keyword" = if ]; then
777                         echo "#if 0" >> version.h
778                     fi
779                     echo "#else" >> version.h
780                 else
781                     echo "#$keyword defined(__module__$i)" >> version.h
782                     keyword=elif
783                 fi
784                 grep UTS_RELEASE $verh >> version.h
785             fi
786             done
787         echo "#endif" >> version.h
788         if [ -f ../../savedheaders/%{_target_cpu}/up/version.h ] ; then
789             # keep to a standard normally
790             HEADER_FILE=../../savedheaders/%{_target_cpu}/up/version.h
791         else
792             # test build not including uniprocessor, must get info from somewhere
793             HEADER_FILE=$(ls ../../savedheaders/*/*/version.h | head -n 1)
794         fi
795         grep -v UTS_RELEASE $HEADER_FILE >> version.h
796         rm -rf ../../savedheaders
797         } ; popd
798         touch $RPM_BUILD_ROOT/boot/kernel.h-%{kversion}
799         
800         # rm -f $RPM_BUILD_ROOT/usr/include/linux
801         
802         rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/savedheaders
803         
804         if [ "%{rhbuild}" -ne 0 ] ; then
805             # fix up the tmp_include_depends file wrt the buildroot
806             perl -p -i -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/tmp_include_depends
807         fi
808     fi # linux26
809     popd >/dev/null
810 fi # buildbase
811
812 popd >/dev/null
813
814 %clean
815 rm -rf $RPM_BUILD_ROOT
816
817 ###
818 ### scripts
819 ###
820
821 # do this for upgrades...in case the old modules get removed we have
822 # loopback in the kernel so that mkinitrd will work.
823 %pre -f pre.sh
824
825 %pre smp -f presmp.sh
826
827 %pre bigsmp -f prebigsmp.sh
828
829 %pre pseries64 -f prepseries64.sh
830
831 %pre bigmem -f prebigmem.sh
832
833 %post -f post.sh
834
835 %post pseries64 -f postpseries64.sh
836
837 %post smp -f postsmp.sh
838
839 %post bigsmp -f postbigsmp.sh
840
841 %post bigmem -f postbigmem.sh
842
843 %post jensen -f postjensen.sh
844
845 %ifnarch ia64
846 %post BOOT -f postBOOT.sh
847
848 %endif
849
850 %post -n lustre-lite-utils
851 if [ ! -e /dev/obd ]; then
852    mknod /dev/obd c 10 241
853 fi
854 if [ ! -e /dev/portals ]; then
855    mknod /dev/portals c 10 240
856 fi
857 if [ -f /etc/init.d/lustre ] ; then
858         /sbin/chkconfig --add lustre
859         /sbin/chkconfig --add lustrefs
860 fi
861
862 # Allow clean removal of modules directory
863 %preun -f preun.sh
864
865 %preun pseries64 -f preunpseries64.sh
866
867 %preun smp -f preunsmp.sh
868
869 %preun bigsmp -f preunbigsmp.sh
870
871 %preun bigmem -f preunbigmem.sh
872
873 %preun BOOT -f preunBOOT.sh
874
875 %preun jensen -f preunjensen.sh
876
877 # suse needs these i guess
878 %postun -f postun.sh
879
880 %postun pseries64 -f postunpseries64.sh
881
882 %postun smp -f postunsmp.sh
883
884 %postun bigsmp -f postunbigsmp.sh
885
886 %postun bigmem -f postunbigmem.sh
887
888 %postun BOOT -f postunBOOT.sh
889
890 %postun jensen -f postunjensen.sh
891
892 # We need this here because we don't prereq kudzu; it could be
893 # installed after the kernel
894 %triggerin -- kudzu
895 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
896
897 %triggerin smp -- kudzu
898 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
899
900 %triggerin bigsmp -- kudzu
901 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
902
903 %triggerin pseries64 -- kudzu
904 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
905
906 %triggerin bigmem -- kudzu
907 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
908
909 %triggerin BOOT -- kudzu
910 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
911
912 %triggerin jensen -- kudzu
913 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
914
915
916 # Old kernel-headers packages owned include symlinks; new
917 # ones just make them so that we can have multiple kernel-headers
918 # packages installed.
919
920 %triggerpostun source -- kernel-headers < 2.2.16
921 cd /usr/src
922 rm -f %{kslnk}
923 ln -snf linux-%{KVERREL} %{kslnk}
924 exit 0
925
926 %post source
927 cd /usr/src
928 rm -f %{kslnk}
929 ln -snf linux-%{KVERREL} %{kslnk}
930
931 %postun source
932 if [ -L /usr/src/%{kslnk} ]; then 
933     if [ -L /usr/src/%{kslnk} -a `ls -ld /usr/src/%{kslnk} 2>/dev/null| awk '{ print $11 }'` = "linux-%{KVERREL}" ]; then
934         [ $1 = 0 ] && rm -f /usr/src/%{kslnk}
935     fi
936 fi
937 exit 0
938
939 %preun -n lustre-lite-utils
940 if [ $1 = 0 -a -f /etc/init.d/lustre ]; then
941         /sbin/chkconfig --del lustre
942         /sbin/chkconfig --del lustrefs
943 fi
944
945 ###
946 ### file lists
947 ###
948
949 %if %{buildup}
950 %files -f kernel.files
951 %endif
952
953 %if %{buildsmp}
954 %files smp -f kernelsmp.files
955 %endif
956
957 %if %{buildbigsmp}
958 %files bigsmp -f kernelbigsmp.files
959 %endif
960
961 %if %{buildpseries64}
962 %files pseries64 -f kernelpseries64.files
963 %endif
964
965 %if %{buildbigmem}
966 %files bigmem -f kernelbigmem.files
967 %endif
968
969 %if %{buildBOOT}
970 %files BOOT -f kernelBOOT.files
971 %endif
972
973 %if %{buildbase}
974
975 %files source -f kernel-source.files
976
977 %files doc
978 %defattr(-,root,root)
979 %doc lustre/linux/Documentation/*
980
981 %files -n lustre-lite-utils
982 %defattr(-, root, root)
983 %doc lustre/COPYING lustre/lustre/BUGS lustre/ChangeLog lustre/README
984 /sbin/*
985 /usr/sbin/*
986 /usr/bin/*
987 /usr/lib/lustre/python
988 @ENABLE_INIT_SCRIPTS@/etc/init.d/lustre
989 @ENABLE_INIT_SCRIPTS@/etc/init.d/lustrefs
990 /usr/include/lustre/*
991 /usr/include/linux/*
992 /usr/lib/lib*.a
993 /usr/share/man/man?/*
994
995 #%files -n lustre-doc
996 #%defattr(-, root, root)
997 #/usr/share/doc/lustre/COPYING
998 #/usr/share/doc/lustre/lustre.pdf
999 #/usr/share/doc/lustre/COPYING
1000
1001 /usr/share/lustre/examples
1002
1003 %files -n lustre-ldap
1004 %defattr(-, root, root)
1005 /etc/openldap/slapd-lustre.conf
1006 /etc/openldap/schema/lustre.schema
1007 /usr/share/lustre/lustre2ldif.xsl
1008 /usr/share/lustre/top.ldif
1009
1010 %endif # %{buildbase}