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