Whamcloud - gitweb
strace that update_oldconfig to see why make oldconfig is timing out the expect script.
[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: %{_tmppath}/%{name}-%{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                                 # /sbin/update-modules.dep compares when the modules were built, rather
406                                 # than installed, so force modules.dep to be recreated
407                                 echo "rm -f /lib/modules/%{KVERREL}${flavor}/modules.dep" >> ${script}
408                                 echo "if [ -f /etc/modprobe.conf ] ; then" >> ${script}                 
409                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE26} >> ${script}
410
411                                 echo "else" >> ${script}
412                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" -e "s^%%{cfg_name}^${flavor}^g" %{SOURCE29} >> ${script}
413                                 echo "fi" >> ${script}
414                                 ;;
415                         postun)
416                                 echo "if [ -f /etc/modprobe.conf ] ; then" >> ${script}                 
417                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE27} >> ${script}
418
419                                 echo "else" >> ${script}                        
420                                 sed -e "s^%ver_str^%{KVERREL}${flavor}^g" %{SOURCE30} >> ${script}
421                                 echo "fi" >> ${script}
422                                 ;;
423                 esac
424                 echo "exit 0; fi" >> ${script}
425                 case $when in
426                         post)
427                                 if [ -z "${flavor}" ] ; then
428                                         cat >> ${script} <<EOF
429 cd /boot
430 %ifnarch ia64 
431 ln -sf vmlinuz-%{KVERREL} vmlinuz
432 %endif
433 ln -sf System.map-%{KVERREL} System.map
434 ln -sf module-info-%{KVERREL} module-info
435 EOF
436                                 fi
437                                 cat >> ${script} <<EOF
438 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade
439 [ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth
440 if [ -x /sbin/new-kernel-pkg ] ; then
441         if /sbin/new-kernel-pkg 2>&1 | grep package >/dev/null ; then
442                 PACKAGE_ARG="--package kernel-${flavor}"
443         fi
444         /sbin/new-kernel-pkg $PACKAGE_ARG --mkinitrd --depmod \
445                 --install %{KVERREL}${flavor}
446 fi
447 EOF
448                                 ;;
449                         postun)
450                                 ;;
451                         pre)
452                                 cat >> ${script} <<EOF
453 /sbin/modprobe loop 2>/dev/null >/dev/null || :
454 exit 0
455 EOF
456                                 ;;
457                         preun)
458                                 cat >> ${script} <<EOF
459 /sbin/modprobe loop 2> /dev/null > /dev/null  || :
460 rm -f /lib/modules/%{KVERREL}${flavor}/modules.*
461 if [ -x /sbin/new-kernel-pkg ] ; then
462  /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}${flavor}
463 fi
464 EOF
465                                 ;;
466                 esac
467         done
468
469         cat > "kernel$flavor.files" <<EOF
470 %%defattr(-, root, root)
471 /boot/%{kernel_glob}${flavor}
472 /boot/System.map-%{KVERREL}${flavor}
473 /boot/config-%{KVERREL}${flavor}
474 %%dir /lib/modules
475 %%dir /dev/shm
476 /lib/modules/%{KVERREL}${flavor}
477 %ifarch ia64
478 /boot/efi/redhat/%{kernel_glob}${flavor}
479 %endif
480 %if %{linux26}
481 %if %{susebuild}
482 /boot/Kerntypes-%{KVERREL}${flavor}
483 %endif
484 /boot/symvers-%{KVERREL}-%{_target_cpu}${flavor}.gz
485 %endif
486 EOF
487
488 done
489
490 cat > kernel-source.files <<EOF
491 %%defattr(-,root,root)
492 %%dir /usr/src/linux-%{KVERREL}
493 /usr/src/linux-%{KVERREL}/*
494 %if %{linux26}
495 %%dir /usr/src/linux-%{KVERREL}-obj
496 /usr/src/linux-%{KVERREL}-obj/*
497 %endif
498 EOF
499
500 %build
501 # if RPM_BUILD_NCPUS unset, set it
502 if [ -z "$RPM_BUILD_NCPUS" ] ; then
503     RPM_BUILD_NCPUS=$(egrep -c "^cpu[0-9]+" /proc/stat || :)
504     if [ $RPM_BUILD_NCPUS -eq 0 ] ; then
505         RPM_BUILD_NCPUS=1
506     fi
507     if [ $RPM_BUILD_NCPUS -gt 8 ] ; then
508         RPM_BUILD_NCPUS=8
509     fi
510 fi
511
512 rm -rf $RPM_BUILD_ROOT
513 mkdir -p $RPM_BUILD_ROOT
514
515 DependKernel()
516 {
517   target_config=${1:+--target-config $1}
518   sh -x ./build/lmake \
519         --depend-kernel \
520         --target @LUSTRE_TARGET@ \
521         --target-arch %{_target_cpu} \
522         ${target_config} \
523         --extraversion %{kextraver} \
524         -j $RPM_BUILD_NCPUS
525 }
526
527 BuildKernel()
528 {
529   target_config=${1:+--target-config $1}
530   sh -x ./build/lmake \
531         --build-kernel --build-lustre \
532         --install \
533         --save-headers \
534         --target @LUSTRE_TARGET@ \
535         --target-arch %{_target_cpu} \
536         ${target_config} \
537         --extraversion %{kextraver} \
538         --kerneldir $RPM_SOURCE_DIR \
539         -j $RPM_BUILD_NCPUS \
540         --destdir $RPM_BUILD_ROOT \
541         -- --disable-tests \
542         @CONFIGURE_FLAGS@
543 }
544
545 BuildLustre()
546 {
547   target_config=${1:+--target-config $1}
548   sh -x ./build/lmake \
549         --build-lustre \
550         --install-lustre \
551         --target @LUSTRE_TARGET@ \
552         --target-arch %{_target_cpu} \
553         ${target_config} \
554         --extraversion %{kextraver} \
555         --kerneldir $RPM_SOURCE_DIR \
556         -j $RPM_BUILD_NCPUS \
557         --destdir $RPM_BUILD_ROOT \
558         -- --enable-utils \
559         --disable-doc --disable-tests \
560         --disable-modules --disable-liblustre \
561         --sysconfdir=%{_sysconfdir} \
562         --mandir=%{_mandir} \
563         @CONFIGURE_FLAGS@
564 }
565
566 SaveHeaders()
567 {
568   sh -x ./build/lmake \
569         --save-headers \
570         --target @LUSTRE_TARGET@ \
571         --target-arch %{_target_cpu} \
572         --extraversion %{kextraver} \
573         --destdir $RPM_BUILD_ROOT
574 }
575
576 pushd lustre >/dev/null
577
578 %if %{buildbigmem}
579 BuildKernel bigmem
580 %endif
581
582 %if %{buildBOOT}
583 BuildKernel BOOT
584 %endif
585
586 %if %{buildjensen}
587 BuildKernel jensen
588 %endif
589
590 %if %{buildsmp}
591 BuildKernel smp
592 %endif
593
594 %if %{buildbigsmp}
595 BuildKernel bigsmp
596 %endif
597
598 %if %{buildpseries64}
599 BuildKernel pseries64
600 %endif
601
602 %if %{buildup}
603 BuildKernel
604 %endif
605
606 %if %{buildbase}
607 # BuildLustre
608 %endif
609
610 popd >/dev/null
611
612 %install
613 pushd lustre >/dev/null
614 # it's already installed, so just clean up some things that are rpm
615 # specific
616 for i in $RPM_BUILD_ROOT/lib/modules/* ; do
617   rm -f $i/modules.*
618 %ifarch %{ntplarchs}
619   # remove legacy pcmcia symlink that's no longer useful
620   rm -rf $i/pcmcia
621 %endif
622 done
623
624 # mark the vmlinux* non-executable to fool strip-to-file
625 chmod a-x $RPM_BUILD_ROOT/boot/vmlinux*
626
627 BuildObj ()
628 {
629         flavor=$1
630         if [ $flavor = "up" ] ; then
631                 flavext=""
632                 flavtgt=""
633         else
634                 flavext="-$flavor"
635                 flavtgt="$flavor"
636         fi
637         perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}${flavtgt}/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
638         c="$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}"
639         o="${c}-obj/%{_target_cpu}/$flavor"
640         mkdir -p $o
641         # use the one we just built
642         #cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}${flavext}.config \
643         cp .config $o/.config
644         for oc in oldconfig_nonint silentoldconfig oldconfig ; do
645             if grep -q "$oc" Makefile ; then
646                 OLDCONFIG="$oc"
647                 break
648             fi
649         done
650         MAKE="make -s O=$o -C ${c}"
651         if [ "$CC" ] ; then
652             MAKE_CC="CC=$CC"
653         fi
654         $MAKE "$MAKE_CC" $OLDCONFIG
655         $MAKE "$MAKE_CC" prepare-all
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.
660         read VERSION PATCHLEVEL SUBLEVEL <<-EOF
661 $(set -- 2.6.5 ; echo ${*//./ })
662 EOF
663         source scripts/mkmakefile \
664             ../../../linux-%{KVERREL} \
665             ../linux-%{KVERREL}-obj/%{_target_cpu}/$flavor \
666             $VERSION \
667             $PATCHLEVEL \
668             > $o/Makefile
669         zcat "$RPM_BUILD_ROOT/boot/symvers-%{KVERREL}-%{_target_cpu}${flavor}.gz" \
670             > $o/Module.symvers
671 }
672
673 ##
674 ## do -source package cleanup/install
675 ##
676 if [ "%{buildbase}" -ne 0 ] ; then
677     pushd linux >/dev/null
678     mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
679     rm -f drivers/net/hamradio/soundmodem/gentbl scripts/mkdep
680     tar cf - . | tar xf - -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
681     ln -sf linux-%{KVERREL} $RPM_BUILD_ROOT/usr/src/linux
682     # install -m 644 %{SOURCE10}  $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
683
684     #clean up the destination
685     make -s mrproper -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
686     rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
687     mkdir -p $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
688     cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@*.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/configs
689     if [ "%{linux26}" -ne 0 ] ; then
690         # this only works because CFS only builds one kernel per target/arch per kernel-source rpm
691         objdir=$RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}-obj
692         mkdir -p $objdir
693         if [ "%{buildbigmem}" -ne 0 ] ; then
694             BuildObj bigmem
695         fi
696         if [ "%{buildBOOT}" -ne 0 ] ; then
697             BuildObj BOOT
698         fi
699         if [ "%{buildjensen}" -ne 0 ] ; then
700             BuildObj jensen
701         fi
702         if [ "%{buildsmp}" -ne 0 ] ; then
703             BuildObj smp
704         fi
705         if [ "%{buildbigsmp}" -ne 0 ] ; then
706             BuildObj bigsmp
707         fi
708         if [ "%{buildpseries64}" -ne 0 ] ; then
709             BuildObj pseries64
710         fi
711         if [ "%{buildup}" -ne 0 ] ; then
712             BuildObj up
713         fi
714         perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
715         # Remove $RPM_BUILD_ROOT prefix from symlinks.
716         for link in $(find $objdir -type l); do
717             target=$(readlink $link)
718             rm -f $link
719             ln -s ${target/$RPM_BUILD_ROOT/} $link
720         done
721     else # 2.4 rh-style
722         perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{kextraver}custom/" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile
723         # get the one from the build we just completed as it might have picked
724         # up new options
725         #cp ../lustre/kernel_patches/kernel_configs/kernel-%{kversion}-@LUSTRE_TARGET@-%{_target_cpu}%{dashtargetboard}.config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config
726         cp .config $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/.config
727         for oc in oldconfig_nonint silentoldconfig oldconfig ; do
728             if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then
729                 OLDCONFIG="$oc"
730                 break
731             fi
732         done
733         if [ "$CC" ] ; then
734             MAKE_CC="CC=$CC"
735         fi
736         make "$MAKE_CC" -s $OLDCONFIG -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
737         make "$MAKE_CC" -s symlinks -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
738         make "$MAKE_CC" -s include/linux/version.h -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
739
740         #this generates modversions info which we want to include and we may as
741         #well include the depends stuff as well, after we fix the paths
742         make -s depend -C $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}
743         find $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL} -name ".*depend" | \
744         while read file ; do
745             mv $file $file.old
746             sed -e "s|[^ ]*\(/usr/src/linux\)|\1|g" < $file.old > $file
747             rm -f $file.old
748         done
749
750         # Try to put some smarter autoconf.h and version.h files in place
751         pushd $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/include/linux ; {
752         rm -rf modules modversions.h autoconf.h version.h
753         cat > modversions.h <<EOF
754 #ifndef _LINUX_MODVERSIONS_H
755 #define _LINUX_MODVERSIONS_H
756 #include <linux/rhconfig.h>
757 #include <linux/modsetver.h>
758 EOF
759         echo '#include <linux/rhconfig.h>' > autoconf.h
760         list=`find ../../savedheaders/* -name '*.ver' -exec basename '{}' \; | sort`
761         mkdir modules
762         for l in $list; do
763             sed 's,$,modules/'$l, ../../savedheaders/list | awk -f %{SOURCE17} > modules/$l
764             touch -r modules/$l modules/`basename $l .ver`.stamp
765             echo '#include <linux/modules/'$l'>' >> modversions.h
766         done
767         echo '#endif' >> modversions.h
768         sed 's,$,autoconf.h,' ../../savedheaders/list | awk -f %{SOURCE16} >> autoconf.h
769         install -m 644 %{SOURCE15} rhconfig.h
770         echo "#include <linux/rhconfig.h>" >> version.h
771         keyword=if
772         for i in smp BOOT BOOTsmp bigmem bigsmp pseries64 up ; do
773             # When we build in an i386, we don't have an bigmem header directory
774             # in savedheaders/i386/bigmem.  We also don't have a BOOT directory
775             # anywhere except in savedheaders/i386.  So, we need to use this method
776             # of determining if a kernel version string needs to be included in the
777             # version.h file
778             verh=`echo ../../savedheaders/*/$i/version.h | awk ' { print $1 } '`
779             if [ -n "$verh" -a -f "$verh" ]; then
780                 if [ "$i" = up ]; then
781                     if [ "$keyword" = if ]; then
782                         echo "#if 0" >> version.h
783                     fi
784                     echo "#else" >> version.h
785                 else
786                     echo "#$keyword defined(__module__$i)" >> version.h
787                     keyword=elif
788                 fi
789                 grep UTS_RELEASE $verh >> version.h
790             fi
791             done
792         echo "#endif" >> version.h
793         if [ -f ../../savedheaders/%{_target_cpu}/up/version.h ] ; then
794             # keep to a standard normally
795             HEADER_FILE=../../savedheaders/%{_target_cpu}/up/version.h
796         else
797             # test build not including uniprocessor, must get info from somewhere
798             HEADER_FILE=$(ls ../../savedheaders/*/*/version.h | head -n 1)
799         fi
800         grep -v UTS_RELEASE $HEADER_FILE >> version.h
801         rm -rf ../../savedheaders
802         } ; popd
803         touch $RPM_BUILD_ROOT/boot/kernel.h-%{kversion}
804         
805         # rm -f $RPM_BUILD_ROOT/usr/include/linux
806         
807         rm -rf $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/savedheaders
808         
809         if [ "%{rhbuild}" -ne 0 ] ; then
810             # fix up the tmp_include_depends file wrt the buildroot
811             perl -p -i -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/tmp_include_depends
812         fi
813     fi # linux26
814     popd >/dev/null
815 fi # buildbase
816
817 popd >/dev/null
818
819 %clean
820 rm -rf $RPM_BUILD_ROOT
821
822 ###
823 ### scripts
824 ###
825
826 # do this for upgrades...in case the old modules get removed we have
827 # loopback in the kernel so that mkinitrd will work.
828 %pre -f pre.sh
829
830 %pre smp -f presmp.sh
831
832 %pre bigsmp -f prebigsmp.sh
833
834 %pre pseries64 -f prepseries64.sh
835
836 %pre bigmem -f prebigmem.sh
837
838 %post -f post.sh
839
840 %post pseries64 -f postpseries64.sh
841
842 %post smp -f postsmp.sh
843
844 %post bigsmp -f postbigsmp.sh
845
846 %post bigmem -f postbigmem.sh
847
848 %post jensen -f postjensen.sh
849
850 %ifnarch ia64
851 %post BOOT -f postBOOT.sh
852
853 %endif
854
855 %post -n lustre-lite-utils
856 if [ -f /etc/init.d/lustre ] ; then
857         /sbin/chkconfig --add lustre
858         /sbin/chkconfig --add lustrefs
859 fi
860
861 # Allow clean removal of modules directory
862 %preun -f preun.sh
863
864 %preun pseries64 -f preunpseries64.sh
865
866 %preun smp -f preunsmp.sh
867
868 %preun bigsmp -f preunbigsmp.sh
869
870 %preun bigmem -f preunbigmem.sh
871
872 %preun BOOT -f preunBOOT.sh
873
874 %preun jensen -f preunjensen.sh
875
876 # suse needs these i guess
877 %postun -f postun.sh
878
879 %postun pseries64 -f postunpseries64.sh
880
881 %postun smp -f postunsmp.sh
882
883 %postun bigsmp -f postunbigsmp.sh
884
885 %postun bigmem -f postunbigmem.sh
886
887 %postun BOOT -f postunBOOT.sh
888
889 %postun jensen -f postunjensen.sh
890
891 # We need this here because we don't prereq kudzu; it could be
892 # installed after the kernel
893 %triggerin -- kudzu
894 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
895
896 %triggerin smp -- kudzu
897 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
898
899 %triggerin bigsmp -- kudzu
900 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
901
902 %triggerin pseries64 -- kudzu
903 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
904
905 %triggerin bigmem -- kudzu
906 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
907
908 %triggerin BOOT -- kudzu
909 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
910
911 %triggerin jensen -- kudzu
912 [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || :
913
914
915 # Old kernel-headers packages owned include symlinks; new
916 # ones just make them so that we can have multiple kernel-headers
917 # packages installed.
918
919 %triggerpostun source -- kernel-headers < 2.2.16
920 cd /usr/src
921 rm -f %{kslnk}
922 ln -snf linux-%{KVERREL} %{kslnk}
923 exit 0
924
925 %post source
926 cd /usr/src
927 rm -f %{kslnk}
928 ln -snf linux-%{KVERREL} %{kslnk}
929
930 %postun source
931 if [ -L /usr/src/%{kslnk} ]; then 
932     if [ -L /usr/src/%{kslnk} -a `ls -ld /usr/src/%{kslnk} 2>/dev/null| awk '{ print $11 }'` = "linux-%{KVERREL}" ]; then
933         [ $1 = 0 ] && rm -f /usr/src/%{kslnk}
934     fi
935 fi
936 exit 0
937
938 %preun -n lustre-lite-utils
939 if [ $1 = 0 -a -f /etc/init.d/lustre ]; then
940         /sbin/chkconfig --del lustre
941         /sbin/chkconfig --del lustrefs
942 fi
943
944 ###
945 ### file lists
946 ###
947
948 %if %{buildup}
949 %files -f kernel.files
950 %endif
951
952 %if %{buildsmp}
953 %files smp -f kernelsmp.files
954 %endif
955
956 %if %{buildbigsmp}
957 %files bigsmp -f kernelbigsmp.files
958 %endif
959
960 %if %{buildpseries64}
961 %files pseries64 -f kernelpseries64.files
962 %endif
963
964 %if %{buildbigmem}
965 %files bigmem -f kernelbigmem.files
966 %endif
967
968 %if %{buildBOOT}
969 %files BOOT -f kernelBOOT.files
970 %endif
971
972 %if %{buildbase}
973 %files source -f kernel-source.files
974 %endif