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