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