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