Add missing %ApplyPatch 640.
[linux-2.6.git] / kernel-2.6.spec
1 #
2 # $Id$
3 #
4 %define url $URL$
5
6 Summary: The Linux kernel (the core of the Linux operating system)
7
8 # What parts do we want to build?  We must build at least one kernel.
9 # These are the kernels that are built IF the architecture allows it.
10
11 %define buildup 1
12 %define builduml 0
13 %define buildxen 0
14 %define builddoc 0
15
16 # default is to not build this - to override, use something like
17 # kernel-SPECVARS := iwlwifi=1 
18 # rpm does not seem to have a syntax for defining overridable defaults
19 # any better solution would be more than welcome.
20 %define build_iwlwifi %{?iwlwifi:1}%{!?iwlwifi:0}
21
22 # Versions of various parts
23
24 # for module-tag.py - sublevel is used for the version (middle) part of tag names
25 %define name linux-2.6
26 %define module_version_varname sublevel
27 %define taglevel 4
28
29 #
30 # Polite request for people who spin their own kernel rpms:
31 # please modify the "release" field in a way that identifies
32 # that the kernel isn't the stock distribution kernel, for example by
33 # adding some text to the end of the version number.
34 #
35 %define sublevel 22
36 %define patchlevel 19
37 %define kversion 2.6.%{sublevel}
38 %define rpmversion 2.6.%{sublevel}%{?patchlevel:.%{patchlevel}}
39
40 %define vsversion 2.3.0.34
41
42 # Will go away when VServer supports NetNS in mainline. Currently, it must be 
43 # updated every time the PL kernel is updated.
44 %define vini_pl_patch 561
45
46 %define release vs%{vsversion}.%{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
47
48 %{!?pldistro:%global pldistro planetlab}
49
50 %define signmodules 0
51 %define make_target bzImage
52 %define KVERREL %{PACKAGE_VERSION}-%{PACKAGE_RELEASE}
53
54 # Override generic defaults with per-arch defaults
55
56 %define image_install_path boot
57
58 #
59 # Three sets of minimum package version requirements in the form of Conflicts:
60 # to versions below the minimum
61 #
62
63 #
64 # First the general kernel 2.6 required versions as per
65 # Documentation/Changes
66 #
67 %define kernel_dot_org_conflicts  ppp <= 2.3.15, pcmcia-cs <= 3.1.20, isdn4k-utils <= 3.0, mount < 2.10r-5, nfs-utils < 1.0.3, e2fsprogs < 1.29, util-linux < 2.10, jfsutils < 1.0.14, reiserfsprogs < 3.6.3, xfsprogs < 2.1.0, procps < 2.0.9, oprofile < 0.5.3
68
69
70 # Then a series of requirements that are distribution specific, either 
71 # because we add patches for something, or the older versions have 
72 # problems with the newer kernel or lack certain things that make 
73 # integration in the distro harder than needed.
74 #
75 %define package_conflicts  cipe < 1.4.5, kudzu <= 0.92, initscripts < 7.23, dev < 3.2-7, iptables < 1.2.5-3, bcm5820 < 1.81, nvidia-rh72 <= 1.0 selinux-policy-targeted < 1.23.16-1
76
77 #
78 # Several packages had bugs in them that became obvious when the NPTL
79 # threading code got integrated.
80 #
81 %define nptl_conflicts SysVinit < 2.84-13, pam < 0.75-48, vixie-cron < 3.0.1-73, privoxy < 3.0.0-8, spamassassin < 2.44-4.8.x,  cups < 1.1.17-13
82
83 #
84 # The ld.so.conf.d file we install uses syntax older ldconfig's don't grok.
85 #
86
87 # MEF commented out
88 # %define xen_conflicts glibc < 2.3.5-1
89
90 #
91 # Packages that need to be installed before the kernel is, because the %post
92 # scripts use them.
93 #
94 %define kernel_prereq  fileutils, module-init-tools, initscripts >= 5.83, mkinitrd >= 3.5.5
95
96 Vendor: PlanetLab
97 Packager: PlanetLab Central <support@planet-lab.org>
98 Distribution: PlanetLab %{plrelease}
99 URL: %(echo %{url} | cut -d ' ' -f 2)
100
101 Name: kernel
102 Group: System Environment/Kernel
103 License: GPLv2
104 Version: %{rpmversion}
105 Release: %{release}
106 ExclusiveOS: Linux
107 Provides: kernel = %{version}
108 Provides: kernel-drm = 4.3.0
109 Provides: kernel-%{_target_cpu} = %{rpmversion}-%{release}
110 Provides: kernel-smp = %{rpmversion}-%{release}
111 Provides: kernel-smp-%{_target_cpu} = %{rpmversion}-%{release}
112 Prereq: %{kernel_prereq}
113 Conflicts: %{kernel_dot_org_conflicts}
114 Conflicts: %{package_conflicts}
115 Conflicts: %{nptl_conflicts}
116 # We can't let RPM do the dependencies automatic because it'll then pick up
117 # a correct but undesirable perl dependency from the module headers which
118 # isn't required for the kernel proper to function
119 AutoReqProv: no
120
121 #
122 # List the packages used during the kernel build
123 #
124 BuildPreReq: module-init-tools, patch >= 2.5.4, bash >= 2.03, sh-utils, tar
125 BuildPreReq: bzip2, findutils, gzip, m4, perl, make >= 3.78, gnupg, diffutils
126 BuildRequires: gcc >= 3.3.3, binutils >= 2.12, redhat-rpm-config
127 BuildConflicts: rhbuildsys(DiskFree) < 500Mb
128
129
130 Source0: ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-%{kversion}.tar.bz2
131
132 Source10: %{pldistro}-%{kversion}-i586.config
133 Source11: %{pldistro}-%{kversion}-i686.config
134 Source12: %{pldistro}-%{kversion}-x86_64.config
135 %if %{builduml}
136 Source20: %{pldistro}-%{kversion}-i686-uml.config
137 %endif
138 %if %{buildxen}
139 Source30: %{pldistro}-%{kversion}-i686-xenU.config
140 %endif
141
142 # Mainline patches
143 %if "0%{patchlevel}"
144 Patch000: ftp://ftp.kernel.org/pub/linux/kernel/v2.6/patch-%{rpmversion}.bz2
145 %endif
146
147 Patch010: linux-2.6-010-e1000e.patch
148 Patch020: linux-2.6-020-build-id.patch
149 Patch030: linux-2.6-030-netns.patch
150 Patch040: linux-2.6-040-i_mutex-check.patch
151
152 # These are patches picked up from Fedora/RHEL
153 Patch100: linux-2.6-100-build-nonintconfig.patch
154
155 # Linux-VServer
156 Patch200: patch-%{rpmversion}-vs%{vsversion}.diff
157 Patch210: linux-2.6-210-vserver-cpu-sched.patch
158
159 # IP sets
160 Patch250: linux-2.6-250-ipsets.patch
161
162 # PlanetLab
163 Patch500: linux-2.6-500-vserver-filesharing.patch
164 Patch510: linux-2.6-510-ipod.patch
165 Patch520: linux-2.6-520-vnet+.patch
166 Patch530: linux-2.6-530-built-by-support.patch
167 Patch540: linux-2.6-540-oom-kill.patch
168 Patch550: linux-2.6-550-raise-default-nfile-ulimit.patch
169 Patch560: linux-2.6-560-mmconf.patch
170 Patch570: linux-2.6-570-tagxid.patch
171 Patch580: linux-2.6-580-show-proc-virt.patch
172 Patch590: linux-2.6-590-chopstix-intern.patch
173 Patch620: linux-2.6-620-kdb.patch
174 Patch630: linux-2.6-630-sched-fix.patch
175 Patch640: linux-2.6-640-netlink-audit-hack.patch
176
177 # See also the file named 'sources' here for the related checksums
178 # NOTE. iwlwifi should be in-kernel starting from 2.6.24
179 # see http://bughost.org/bugzilla/show_bug.cgi?id=1584
180 %if %{build_iwlwifi}
181 %define mac80211_version 10.0.4
182 Patch600: http://intellinuxwireless.org/mac80211/downloads/mac80211-%{mac80211_version}.tgz
183 %define iwlwifi_version 1.2.25
184 Patch601: http://intellinuxwireless.org/iwlwifi/downloads/iwlwifi-%{iwlwifi_version}.tgz
185 %endif
186
187 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
188
189 %description
190 The kernel package contains the Linux kernel (vmlinuz), the core of any
191 Linux operating system.  The kernel handles the basic functions
192 of the operating system:  memory allocation, process allocation, device
193 input and output, etc.
194
195 %package devel
196 Summary: Development package for building kernel modules to match the kernel.
197 Group: System Environment/Kernel
198 AutoReqProv: no
199 Provides: kernel-devel-%{_target_cpu} = %{rpmversion}-%{release}
200 Provides: kernel-smp-devel = %{rpmversion}-%{release}
201 Provides: kernel-smp-devel-%{_target_cpu} = %{rpmversion}-%{release}
202 Prereq: /usr/bin/find
203
204 %description devel
205 This package provides kernel headers and makefiles sufficient to build modules
206 against the kernel package.
207
208
209 %package doc
210 Summary: Various documentation bits found in the kernel source.
211 Group: Documentation
212
213 %description doc
214 This package contains documentation files from the kernel
215 source. Various bits of information about the Linux kernel and the
216 device drivers shipped with it are documented in these files.
217
218 You'll want to install this package if you need a reference to the
219 options that can be passed to Linux kernel modules at load time.
220
221 %package xenU
222 Summary: The Linux kernel compiled for unprivileged Xen guest VMs
223
224 Group: System Environment/Kernel
225 Provides: kernel = %{version}
226 Provides: kernel-%{_target_cpu} = %{rpmversion}-%{release}xenU
227 Prereq: %{kernel_prereq}
228 Conflicts: %{kernel_dot_org_conflicts}
229 Conflicts: %{package_conflicts}
230 Conflicts: %{nptl_conflicts}
231
232 # MEF commented out 
233 # Conflicts: %{xen_conflicts}
234
235 # We can't let RPM do the dependencies automatic because it'll then pick up
236 # a correct but undesirable perl dependency from the module headers which
237 # isn't required for the kernel proper to function
238 AutoReqProv: no
239
240 %description xenU
241 This package includes a version of the Linux kernel which
242 runs in Xen unprivileged guest VMs.  This should be installed
243 both inside the unprivileged guest (for the modules) and in
244 the guest0 domain.
245
246 %package xenU-devel
247 Summary: Development package for building kernel modules to match the kernel.
248 Group: System Environment/Kernel
249 AutoReqProv: no
250 Provides: kernel-xenU-devel-%{_target_cpu} = %{rpmversion}-%{release}
251 Provides: kernel-devel-%{_target_cpu} = %{rpmversion}-%{release}xenU
252 Provides: kernel-devel = %{rpmversion}-%{release}xenU
253 Prereq: /usr/sbin/hardlink, /usr/bin/find
254
255 %description xenU-devel
256 This package provides kernel headers and makefiles sufficient to build modules
257 against the kernel package.
258
259 %package uml
260 Summary: The Linux kernel compiled for use in user mode (User Mode Linux).
261
262 Group: System Environment/Kernel
263
264 %description uml
265 This package includes a user mode version of the Linux kernel.
266
267 %package uml-devel
268 Summary: Development package for building kernel modules to match the UML kernel.
269 Group: System Environment/Kernel
270 Provides: kernel-uml-devel-%{_target_cpu} = %{rpmversion}-%{release}
271 Provides: kernel-devel-%{_target_cpu} = %{rpmversion}-%{release}smp
272 Provides: kernel-devel = %{rpmversion}-%{release}smp
273 AutoReqProv: no
274 Prereq: /usr/sbin/hardlink, /usr/bin/find
275
276 %description uml-devel
277 This package provides kernel headers and makefiles sufficient to build modules
278 against the User Mode Linux kernel package.
279
280 %package uml-modules
281 Summary: The Linux kernel modules compiled for use in user mode (User Mode Linux).
282
283 Group: System Environment/Kernel
284
285 %description uml-modules
286 This package includes a user mode version of the Linux kernel modules.
287
288 %package vserver
289 Summary: A placeholder RPM that provides kernel and kernel-drm
290
291 Group: System Environment/Kernel
292 Provides: kernel = %{version}
293 Provides: kernel-drm = 4.3.0
294 Provides: kernel-%{_target_cpu} = %{rpmversion}-%{release}
295
296 %description vserver
297 VServers do not require and cannot use kernels, but some RPMs have
298 implicit or explicit dependencies on the "kernel" package
299 (e.g. tcpdump). This package installs no files but provides the
300 necessary dependencies to make rpm and yum happy.
301
302
303 %prep
304 # First we unpack the kernel tarball.
305 # If this isn't the first make prep, we use links to the existing clean tarball
306 # which speeds things up quite a bit.
307 if [ ! -d kernel-%{kversion}/vanilla ]; then
308   # Ok, first time we do a make prep.
309   rm -f pax_global_header
310 %setup -q -n %{name}-%{kversion} -c
311   mv linux-%{kversion} vanilla
312 else
313   # We already have a vanilla dir.
314   cd kernel-%{kversion}
315 fi
316
317 KERNEL_PREVIOUS=vanilla
318 # Dark RPM-magic to apply each patch to a hardlinked copy of the tree.
319 %define ApplyPatch() \
320   rm -fr linux-%{kversion}-%1                           \
321   cp -al $KERNEL_PREVIOUS linux-%{kversion}-%1          \
322   patchflag=-p1                                         \
323   test "%2" != "%%2" && patchflag="%2"                  \
324   PATCH="%{expand:%{PATCH%1}}"                          \
325   if test ! -e "$PATCH"; then                           \
326     echo "Patch %1 does not exist!"                     \
327     exit 1                                              \
328   fi                                                    \
329   case "$PATCH" in                                      \
330     *.bz2)  bzcat "$PATCH";;                            \
331     *.gz)   zcat "$PATCH";;                             \
332     *)      cat "$PATCH";;                              \
333   esac | patch -F1 -s -d linux-%{kversion}-%1 $patchflag \
334   KERNEL_PREVIOUS=linux-%{kversion}-%1
335
336 # This is where the patches get applied
337 %if 0%{?patchlevel}
338 %ApplyPatch 0
339 %endif
340
341 %ApplyPatch 10
342 %ApplyPatch 20
343
344 # NetNS patch for VINI
345 %if 0%{?with_netns}
346 %ApplyPatch 30
347 %endif
348 %ApplyPatch 40
349
350 %ApplyPatch 100
351
352 %ApplyPatch 200
353 %ApplyPatch 210
354
355 %ApplyPatch 250
356
357 %ApplyPatch 500
358 %ApplyPatch 510
359 %ApplyPatch 520
360 %ApplyPatch 530
361 %ApplyPatch 540
362 %ApplyPatch 550
363 %ApplyPatch 560
364 %ApplyPatch 570
365 %ApplyPatch 580
366 %ApplyPatch 590
367 %ApplyPatch 620
368 %ApplyPatch 630
369 %ApplyPatch 640
370
371 # NetNS conflict-resolving patch for VINI. Will work with patch vini_pl_patch-1 but may
372 # break with later patches.
373
374 %if 0%{?with_netns}
375 %ApplyPatch %vini_pl_patch
376 %endif
377
378 %if %{build_iwlwifi}
379 # Run the mac80211 stuff in the kernel tree holding the last patch
380 tar -xzf %{PATCH600}
381 pushd mac80211-%{mac80211_version}
382 mac80211_makeflags="KSRC=../$KERNEL_PREVIOUS"
383 make $mac80211_makeflags modified
384 make $mac80211_makeflags source
385 make $mac80211_makeflags patch_kernel
386 popd
387
388 # Untar iwlwifi in the same place - needs to be compiled later
389 tar -xzf %{PATCH601}
390 # the install target is broken: first it does not pass the right -b flag to depmod
391 # second we do not need to invoke depmod at this stage anyway
392 # let's add our own patch/stuff in this Makefile for manual install later on
393 pushd iwlwifi-%{iwlwifi_version}
394 cat >> Makefile <<EOF
395 module-list:
396         @echo \$(addprefix \$(DIR),\$(addsuffix .ko,\$(list-m)))
397 EOF
398 popd
399 %endif
400
401 rm -fr linux-%{kversion}
402 ln -sf $KERNEL_PREVIOUS linux-%{kversion}
403 cd linux-%{kversion}
404
405
406 # make sure the kernel has the sublevel we know it has. This looks weird
407 # but for -pre and -rc versions we need it since we only want to use
408 # the higher version when the final kernel is released.
409 perl -p -i -e "s/^SUBLEVEL.*/SUBLEVEL = %{sublevel}/" Makefile
410 perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -prep/" Makefile
411
412 # get rid of unwanted files resulting from patch fuzz
413 find . \( -name "*.orig" -o -name "*~" \) -exec rm -f {} \; >/dev/null
414
415
416 ###
417 ### build
418 ###
419 %build
420
421 BuildKernel() {
422     MakeTarget=$1
423     Arch=$2
424     Flavour=$3
425
426     rm -rf linux-%{_target_cpu}-%{kversion}$Flavour
427     cp -rl linux-%{kversion}/ linux-%{_target_cpu}-%{kversion}$Flavour
428     cd linux-%{_target_cpu}-%{kversion}$Flavour
429
430     # Pick the right config file for the kernel we're building
431     if [ -n "$Flavour" ] ; then
432       Config=%{pldistro}-%{kversion}-%{_target_cpu}-$Flavour.config
433       DevelDir=/usr/src/kernels/%{KVERREL}-$Flavour-%{_target_cpu}
434       DevelLink=/usr/src/kernels/%{KVERREL}$Flavour-%{_target_cpu}
435     else
436       Config=%{pldistro}-%{kversion}-%{_target_cpu}.config
437       DevelDir=/usr/src/kernels/%{KVERREL}-%{_target_cpu}
438       DevelLink=
439     fi
440
441     KernelVer=%{version}-%{release}$Flavour
442     echo BUILDING A KERNEL FOR $Flavour %{_target_cpu}...
443
444     # make sure EXTRAVERSION says what we want it to say
445     perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{?patchlevel:.%{patchlevel}}-%{release}$Flavour/" Makefile
446
447     # and now to start the build process
448
449     make -s mrproper
450     cp %{_sourcedir}/$Config .config
451
452     #Arch=`head -1 .config | cut -b 3-`
453     echo USING ARCH=$Arch
454
455     make -s ARCH=$Arch nonint_oldconfig > /dev/null
456     make -s ARCH=$Arch %{?_smp_mflags} $MakeTarget
457     make -s ARCH=$Arch %{?_smp_mflags} modules || exit 1
458
459 %if %{build_iwlwifi}
460     # build the iwlwifi driver
461     make -C %{_builddir}/kernel-%{kversion}/iwlwifi-%{iwlwifi_version} ARCH=$Arch \
462       KSRC=%{_builddir}/kernel-%{kversion}/linux-%{_target_cpu}-%{kversion}$Flavour
463 %endif
464
465     # Start installing the results
466
467 %if "%{_enable_debug_packages}" == "1"
468     mkdir -p $RPM_BUILD_ROOT/usr/lib/debug/boot
469 %endif
470     mkdir -p $RPM_BUILD_ROOT/%{image_install_path}
471     install -m 644 .config $RPM_BUILD_ROOT/boot/config-$KernelVer
472     install -m 644 System.map $RPM_BUILD_ROOT/boot/System.map-$KernelVer
473     if [ -f arch/$Arch/boot/bzImage ]; then
474       cp arch/$Arch/boot/bzImage $RPM_BUILD_ROOT/%{image_install_path}/vmlinuz-$KernelVer
475     fi
476     if [ -f arch/$Arch/boot/zImage.stub ]; then
477       cp arch/$Arch/boot/zImage.stub $RPM_BUILD_ROOT/%{image_install_path}/zImage.stub-$KernelVer || :
478     fi
479     if [ "$Flavour" = "uml" ] ; then
480         install -D -m 755 linux $RPM_BUILD_ROOT/%{_bindir}/linux
481     fi
482
483     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer
484     make -s ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=$KernelVer
485
486 %if %{build_iwlwifi}
487     # install iwlwifi
488 #    make -C %{_builddir}/kernel-%{kversion}/iwlwifi-%{iwlwifi_version} ARCH=$Arch \
489 #         KSRC=%{_builddir}/kernel-%{kversion}/linux-%{_target_cpu}-%{kversion}$Flavour \
490 #        KMISC=$RPM_BUILD_ROOT/lib/modules/$KernelVer/kernel/drivers/net/wireless install
491     pushd %{_builddir}/kernel-%{kversion}/iwlwifi-%{iwlwifi_version}
492     iwlwifi_dest=$RPM_BUILD_ROOT/lib/modules/$KernelVer/kernel/drivers/net/wireless
493     # get the list and location of modules to install - no need to pass KSRC nor anything, let's keep it simple
494     iwlwifi_modules=$(make --no-print-directory module-list)
495     install -d $iwlwifi_dest
496     install -m 644 -c $iwlwifi_modules $iwlwifi_dest
497     popd
498 %endif
499
500     # And save the headers/makefiles etc for building modules against
501     #
502     # This all looks scary, but the end result is supposed to be:
503     # * all arch relevant include/ files
504     # * all Makefile/Kconfig files
505     # * all script/ files
506
507     rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
508     rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/source
509     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
510     (cd $RPM_BUILD_ROOT/lib/modules/$KernelVer ; ln -s build source)
511     # dirs for additional modules per module-init-tools, kbuild/modules.txt
512     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/extra
513     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/updates
514     # first copy everything
515     cp --parents `find  -type f -name "Makefile*" -o -name "Kconfig*"` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build 
516         cp Module.symvers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
517     if [ "$Flavour" = "uml" ] ; then
518       cp --parents -a `find arch/um -name include` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
519     fi
520     # then drop all but the needed Makefiles/Kconfig files
521     rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Documentation
522     rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts
523     rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
524     cp arch/%{_arch}/kernel/asm-offsets.s $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch}/kernel || :
525     cp .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
526     cp -a scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
527     if [ -d arch/%{_arch}/scripts ]; then
528       cp -a arch/%{_arch}/scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch} || :
529     fi
530     if [ -f arch/%{_arch}/*lds ]; then
531       cp -a arch/%{_arch}/*lds $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch}/ || :
532     fi
533     rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*.o
534     rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*/*.o
535     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
536     cd include
537     cp -a acpi config keys linux math-emu media mtd net pcmcia rdma rxrpc scsi sound video asm asm-generic $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
538     cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
539     if [ "$Arch" = "x86_64" ]; then
540       cp -a asm-i386 $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
541     fi
542 %if %{buildxen}
543     if [ "$Flavour" = "xenU" ]; then
544       cp -a xen $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
545       cp -a asm-i386 $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
546     fi
547 %endif
548 %if %{builduml}
549     if [ "$Flavour" = "uml" ] ; then
550       cp -a `readlink -f asm/arch` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
551     fi
552 %endif
553     # While arch/powerpc/include/asm is still a symlink to the old
554     # include/asm-ppc{64,} directory, include that in kernel-devel too.
555     if [ "$Arch" = "powerpc" -a -r ../arch/powerpc/include/asm ]; then
556       cp -a `readlink ../arch/powerpc/include/asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
557       mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/$Arch/include
558       pushd $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/$Arch/include
559       ln -sf ../../../include/asm-ppc* asm
560       popd
561     fi
562
563     # Make sure the Makefile and version.h have a matching timestamp so that
564     # external modules can be built
565     touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Makefile $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/linux/version.h
566     touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/.config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/linux/autoconf.h
567     cd ..
568
569     #
570     # save the vmlinux file for kernel debugging into the kernel-debuginfo rpm
571     #
572 %if "%{_enable_debug_packages}" == "1"
573     mkdir -p $RPM_BUILD_ROOT/usr/lib/debug/lib/modules/$KernelVer
574     cp vmlinux $RPM_BUILD_ROOT/usr/lib/debug/lib/modules/$KernelVer
575 %endif
576 %if %{buildxen}
577     if [ -f vmlinuz ]; then
578       cp vmlinuz $RPM_BUILD_ROOT/%{image_install_path}/vmlinuz-$KernelVer
579     fi
580 %endif
581
582     find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name "*.ko" -type f >modnames
583
584     # mark modules executable so that strip-to-file can strip them
585     cat modnames | xargs chmod u+x
586
587     # remove files that will be auto generated by depmod at rpm -i time
588     rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/modules.*
589
590     # Move the devel headers out of the root file system
591     mkdir -p $RPM_BUILD_ROOT/usr/src/kernels
592     mv $RPM_BUILD_ROOT/lib/modules/$KernelVer/build $RPM_BUILD_ROOT/$DevelDir
593     ln -sf ../../..$DevelDir $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
594     [ -z "$DevelLink" ] || ln -sf `basename $DevelDir` $RPM_BUILD_ROOT/$DevelLink
595 }
596
597 ###
598 # DO it...
599 ###
600
601 # prepare directories
602 rm -rf $RPM_BUILD_ROOT
603 mkdir -p $RPM_BUILD_ROOT/boot
604
605 %if "%{_target_cpu}" == "x86_64"
606 %define kernel_arch %{_target_cpu}
607 %endif
608 %if "%{_target_cpu}" == "i586"
609 %define kernel_arch i386
610 %endif
611 %if "%{_target_cpu}" == "i686"
612 %define kernel_arch i386
613 %endif
614
615 %if %{buildup}
616 BuildKernel %make_target %kernel_arch
617 %endif
618
619 %ifarch i686
620 %if %{builduml}
621 BuildKernel linux um uml
622 %endif
623
624 %if %{buildxen}
625 BuildKernel vmlinuz %kernel_arch xenU
626 %endif
627 %endif
628
629 ###
630 ### install
631 ###
632
633 %install
634
635 cd vanilla
636
637 %if %{buildxen} && "%{_target_cpu}" == "i686"
638 mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
639 rm -f $RPM_BUILD_ROOT/etc/ld.so.conf.d/kernelcap-%{KVERREL}.conf
640 cat > $RPM_BUILD_ROOT/etc/ld.so.conf.d/kernelcap-%{KVERREL}.conf <<\EOF
641 # This directive teaches ldconfig to search in nosegneg subdirectories
642 # and cache the DSOs there with extra bit 0 set in their hwcap match
643 # fields.  In Xen guest kernels, the vDSO tells the dynamic linker to
644 # search in nosegneg subdirectories and to match this extra hwcap bit
645 # in the ld.so.cache file.
646 hwcap 0 nosegneg
647 EOF
648 chmod 444 $RPM_BUILD_ROOT/etc/ld.so.conf.d/kernelcap-%{KVERREL}.conf
649 %endif
650
651 %if %{builddoc}
652 mkdir -p $RPM_BUILD_ROOT/usr/share/doc/kernel-doc-%{kversion}/Documentation
653
654 # sometimes non-world-readable files sneak into the kernel source tree
655 chmod -R a+r *
656 # copy the source over
657 tar cf - Documentation | tar xf - -C $RPM_BUILD_ROOT/usr/share/doc/kernel-doc-%{kversion}
658 %endif
659
660 ###
661 ### clean
662 ###
663
664 %clean
665 rm -rf $RPM_BUILD_ROOT
666
667 ###
668 ### scripts
669 ###
670
671 # load the loop module for upgrades...in case the old modules get removed we have
672 # loopback in the kernel so that mkinitrd will work.
673 %pre
674 /sbin/modprobe loop 2> /dev/null > /dev/null  || :
675 exit 0
676
677 %post
678 if [ -f /etc/sysconfig/kernel ]; then
679   /bin/sed -i -e 's/^DEFAULTKERNEL=kernel-smp$/DEFAULTKERNEL=kernel/' /etc/sysconfig/kernel
680 fi
681
682 # trick mkinitrd in case the current environment does not have device mapper
683 rootdev=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' /etc/fstab)
684 if echo $rootdev |grep -q /dev/mapper 2>/dev/null ; then
685     if [ ! -f $rootdev ]; then
686         fake_root_lvm=1
687         mkdir -p $(dirname $rootdev)
688         touch $rootdev
689     fi
690 fi
691
692 [ ! -x /usr/sbin/module_upgrade ] || /usr/sbin/module_upgrade %{rpmversion}-%{release}
693 #/sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install %{KVERREL}
694 # Older modutils do not support --package option
695 /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}
696
697 # remove fake handle
698 if [ -n "$fake_root_lvm" ]; then
699     rm -f $rootdev
700 fi
701
702 # make some useful links
703 pushd /boot > /dev/null ; {
704         ln -sf config-%{KVERREL} config
705         ln -sf config-%{KVERREL} configsmp
706         ln -sf initrd-%{KVERREL}.img initrd-boot
707         ln -sf initrd-%{KVERREL}.img initrd-bootsmp
708         ln -sf vmlinuz-%{KVERREL} kernel-boot
709         ln -sf vmlinuz-%{KVERREL} kernel-bootsmp
710 }
711 popd > /dev/null
712
713 # ask for a reboot
714 mkdir -p /etc/planetlab
715 touch /etc/planetlab/update-reboot
716
717 %post devel
718 [ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel
719 if [ "$HARDLINK" != "no" -a -x /usr/sbin/hardlink ] ; then
720   pushd /usr/src/kernels/%{KVERREL}-%{_target_cpu} > /dev/null
721   /usr/bin/find . -type f | while read f; do hardlink -c /usr/src/kernels/*FC*/$f $f ; done
722   popd > /dev/null
723 fi
724
725 %post xenU
726 [ ! -x /usr/sbin/module_upgrade ] || /usr/sbin/module_upgrade
727 [ ! -x /sbin/ldconfig ] || /sbin/ldconfig -X
728
729 %post xenU-devel
730 [ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel
731 if [ "$HARDLINK" != "no" -a -x /usr/sbin/hardlink ] ; then
732   pushd /usr/src/kernels/%{KVERREL}-xenU-%{_target_cpu} > /dev/null
733   /usr/bin/find . -type f | while read f; do hardlink -c /usr/src/kernels/*FC*/$f $f ; done
734   popd > /dev/null
735 fi
736
737 %post uml-modules
738 depmod -ae %{KVERREL}uml
739
740 %preun
741 /sbin/modprobe loop 2> /dev/null > /dev/null  || :
742 /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}
743
744 %preun xenU
745 /sbin/modprobe loop 2> /dev/null > /dev/null  || :
746 /sbin/new-kernel-pkg --rmmoddep --remove %{KVERREL}xenU
747
748 %preun uml-modules
749 rm -f /lib/modules/%{KVERREL}uml/modules.*
750
751
752 ###
753 ### file lists
754 ###
755
756 %if %{buildup}
757 %files 
758 %defattr(-,root,root)
759 /%{image_install_path}/vmlinuz-%{KVERREL}
760 /boot/System.map-%{KVERREL}
761 /boot/config-%{KVERREL}
762 %dir /lib/modules/%{KVERREL}
763 /lib/modules/%{KVERREL}/kernel
764 /lib/modules/%{KVERREL}/build
765 /lib/modules/%{KVERREL}/source
766 /lib/modules/%{KVERREL}/extra
767 /lib/modules/%{KVERREL}/updates
768
769 %files devel
770 %defattr(-,root,root)
771 %verify(not mtime) /usr/src/kernels/%{KVERREL}-%{_target_cpu}
772 %endif
773
774 %if %{builduml} && "%{_target_cpu}" == "i686"
775 %files uml
776 %defattr(-,root,root)
777 %{_bindir}/linux
778
779 %files uml-devel
780 %defattr(-,root,root)
781 %verify(not mtime) /usr/src/kernels/%{KVERREL}-uml-%{_target_cpu}
782 /usr/src/kernels/%{KVERREL}uml-%{_target_cpu}
783
784 %files uml-modules
785 %defattr(-,root,root)
786 /boot/System.map-%{KVERREL}uml
787 /boot/config-%{KVERREL}uml
788 %dir /lib/modules/%{KVERREL}uml
789 /lib/modules/%{KVERREL}uml/kernel
790 /lib/modules/%{KVERREL}uml/build
791 /lib/modules/%{KVERREL}uml/source
792 /lib/modules/%{KVERREL}uml/extra
793 /lib/modules/%{KVERREL}uml/updates
794 %endif
795
796 %if %{buildxen} && "%{_target_cpu}" == "i686"
797 %files xenU
798 %defattr(-,root,root)
799 /%{image_install_path}/vmlinuz-%{KVERREL}xenU
800 /boot/System.map-%{KVERREL}xenU
801 /boot/config-%{KVERREL}xenU
802 %dir /lib/modules/%{KVERREL}xenU
803 /lib/modules/%{KVERREL}xenU/kernel
804 /lib/modules/%{KVERREL}xenU/build
805 /lib/modules/%{KVERREL}xenU/source
806 /lib/modules/%{KVERREL}xenU/extra
807 /lib/modules/%{KVERREL}xenU/updates
808 /etc/ld.so.conf.d/kernelcap-%{KVERREL}.conf
809
810 %files xenU-devel
811 %defattr(-,root,root)
812 %verify(not mtime) /usr/src/kernels/%{KVERREL}-xenU-%{_target_cpu}
813 /usr/src/kernels/%{KVERREL}xenU-%{_target_cpu}
814 %endif
815
816 %files vserver
817 %defattr(-,root,root)
818 # no files
819
820 # only some architecture builds need kernel-doc
821
822 %if %{builddoc}
823 %files doc
824 %defattr(-,root,root)
825 %{_datadir}/doc/kernel-doc-%{kversion}/Documentation/*
826 %dir %{_datadir}/doc/kernel-doc-%{kversion}/Documentation
827 %dir %{_datadir}/doc/kernel-doc-%{kversion}
828 %endif
829
830 %changelog
831 * Mon May 05 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - linux-2.6-22-4
832
833
834 * Thu Apr 24 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - linux-2.6-22-3
835 - Fix bug with looping in schedule()
836
837 * Wed Apr 23 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - linux-2.6-22-2
838 - Includes changes from Sapan/Andy regarding the scheduler and vnet bugs.
839 - Should be safe to try a second deployment.
840
841
842 * Tue Jul 11 2006 Dave Jones <davej@redhat.com> [2.6.17-1.2142_FC4]
843 - 2.6.17.4
844 - Disable split pagetable lock.
845
846 * Wed Jul  5 2006 Dave Jones <davej@redhat.com>
847 - Get rid of stack backtrace on panic, which in most
848   cases actually caused a loss of info instead of a gain.
849
850 * Fri Jun 30 2006 Dave Jones <davej@redhat.com> [2.6.17-1.2141_FC4]
851 - 2.6.17.3
852
853 * Fri Jun 30 2006 Dave Jones <davej@redhat.com> [2.6.17-1.2140_FC4]
854 - 2.6.17.2
855 - Fix up the alsa list_add bug.
856
857 * Mon Jun 26 2006 Dave Jones <davej@redhat.com>
858 - Fix up various stupidities incurred by the last big rebase.
859   - Reenable SMP x86-64 builds.
860   - Reenable SMBFS.
861 - Enable PCI fake hotplug driver.
862 - Enable gameport/joystick on i586 builds. (#196581)
863
864 * Sat Jun 24 2006 Dave Jones <davej@redhat.com>
865 - Enable profiling for 586 kernels.
866
867 * Fri Jun 23 2006 Dave Jones <davej@redhat.com> [2.6.17-1.2139_FC4]
868 - Rebuild with slab debug off.
869
870 * Tue Jun 20 2006 Dave Jones <davej@redhat.com> [2.6.17-1.2138_FC4]
871 - 2.6.17.1
872
873 * Mon Jun  5 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2115_FC4]
874 - 2.6.16.20
875
876 * Tue May 30 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2114_FC4]
877 - 2.6.16.19
878
879 * Mon May 29 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2113_FC4]
880 - Improved list_head debugging.
881
882 * Tue May 23 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2112_FC4]
883 - 2.6.16.18
884
885 * Sat May 20 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2111_FC4]
886 - 2.6.16.17
887
888 * Wed May 10 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2110_FC4]
889 - 2.6.16.16
890
891 * Tue May  9 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2109_FC4]
892 - 2.6.16.15
893 - make 16C950 UARTs work (again). (#126403)
894 - Fix exec-shield default, which should fix a few programs that
895   stopped running.
896
897 * Thu May  4 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2108_FC4]
898 - 2.6.16.14
899
900 * Tue May  2 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2107_FC4]
901 - 2.6.16.13
902
903 * Mon May  1 2006 Dave Jones <davej@redhat.com>
904 - 2.6.16.12
905
906 * Tue Apr 25 2006 Dave Jones <davej@redhat.com>
907 - Fix up SCSI errors with mymusix usb mp3 player (#186187)
908
909 * Mon Apr 24 2006 Dave Jones <davej@redhat.com>
910 - 2.6.16.11
911
912 * Wed Apr 19 2006 Dave Jones <davej@redhat.com>
913 - Enable PCI MSI support.
914
915 * Tue Apr 18 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2096_FC4]
916 - 2.6.16.9
917
918 * Tue Apr 18 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2093_FC4]
919 - 2.6.16.7
920
921 * Mon Apr 17 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2092_FC4]
922 - 2.6.16.6
923
924 * Sun Apr 16 2006 Dave Jones <davej@redhat.com>
925 - 2.6.16.5
926
927 * Fri Apr  7 2006 Dave Jones <davej@redhat.com>
928 - 2.6.16.2
929
930 * Tue Apr  4 2006 Dave Jones <davej@redhat.com>
931 - Reenable non-standard serial ports. (#187466)
932 - Reenable snd-es18xx for x86-32 (#187733)
933
934 * Thu Mar 30 2006 Dave Jones <davej@redhat.com>
935 - ship the .kernelrelease file in -devel too.
936 - Disable EDAC debug.
937
938 * Tue Mar 26 2006 Dave Jones <davej@redhat.com> [2.6.16-1.2069_FC4]
939 - 2.6.16.1
940
941 * Mon Mar 25 2006 Dave Jones <davej@redhat.com>
942 - Include patches posted for review for inclusion in 2.6.16.1
943 - Updated new audit msg types.
944 - Reenable HDLC driver (#186257)
945 - Make acpi-cpufreq 'sticky'
946 - Fix broken x86-64 32bit vDSO (#186924)
947
948 * Tue Mar 21 2006 Dave Jones <davej@redhat.com>
949 - Improve spinlock scalability on big machines.
950
951 * Mon Mar 20 2006 Dave Jones <davej@redhat.com>
952 - Sync with FC5's 2.6.16 kernel.
953 - Update Tux & Exec-shield to latest.
954