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