Logoj0ke.net Open Build Service > Projects > GFS > kernel-source > kernel-vanilla.spec
Sign Up | Log In

File kernel-vanilla.spec of Package kernel-source (Revision 5a9cf47ae6f9cb587e776a1e6f51f343)

Currently displaying revision 5a9cf47ae6f9cb587e776a1e6f51f343, show latest

 
1
#
2
# spec file for package kernel-vanilla (Version 2.6.27.4)
3
#
4
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
5
# This file and all modifications and additions to the pristine
6
# package are under the same license as the package itself.
7
#
8
# Please submit bugfixes or comments via http://bugs.opensuse.org/
9
#
10
11
# norootforbuild
12
13
%if 0%{?opensuse_bs}
14
# Strip off the build number ("y") from the "x.y" release number
15
%define source_rel %(release=%release; echo ${release%.*})
16
%else
17
# We don't have build numbers internally
18
%define source_rel %release
19
%endif
20
21
# Don't use shell commands in build macros, this won't work outside of rpm
22
%define build_flavor "vanilla"
23
%define build_kdump 0
24
%define build_xen 0
25
%define build_um 0
26
%define build_vanilla 0
27
28
%if %{build_flavor} == "kdump"
29
%define build_kdump 1
30
%endif
31
%if %{build_flavor} == "xen"
32
%define build_xen 1
33
%endif
34
%if %{build_flavor} == "um"
35
%define build_um 1
36
%endif
37
%if %{build_flavor} == "vanilla"
38
%define build_vanilla 1
39
%endif
40
41
%(chmod +x %_sourcedir/{arch-symbols,guards,config-subst,check-for-config-changes,check-supported-list,built-in-where,find-provides,list-exported-symbols,split-into-symsets,modversions,kabi-checks})
42
43
%define symbols %(set -- kernel-vanilla vanilla $(case vanilla in (rt|rt_*) echo RT ;; esac) $(%_sourcedir/arch-symbols %_target_cpu) $([ -e %_sourcedir/extra-symbols ] && cat %_sourcedir/extra-symbols) ; echo $*)
44
%define subarch_flavor %(%_sourcedir/guards %symbols < %_sourcedir/config.conf | grep '/vanilla$')
45
46
# Define some CONFIG variables as rpm macros as well. (rpm cannot handle
47
# defining them all at once.)
48
%define config_vars CONFIG_MODULES
49
%{expand:%(eval "$(test -n "%subarch_flavor" && tar xfj %_sourcedir/config.tar.bz2 --to-stdout config/%subarch_flavor)"; for config in %config_vars; do echo "%%global $config ${!config:-n}"; done)}
50
51
%if %build_vanilla || %build_kdump || %CONFIG_MODULES != "y"
52
%define split_packages 0
53
%else
54
%define split_packages 1
55
%endif
56
57
Name:           kernel-vanilla
58
Summary:        Dummy summary
59
Version:        2.6.27.4
60
Release:        <RELEASE>
61
License:        GPL
62
Group:          System/Kernel
63
Url:            http://www.kernel.org/
64
AutoReqProv:    on
65
BuildRequires:  coreutils module-init-tools sparse
66
BuildRequires:  fdupes
67
%if %split_packages
68
Requires:       kernel-vanilla-base = %version-%release
69
%endif
70
Requires(pre):  coreutils awk
71
Requires(post): module-init-tools
72
# This Requires is wrong, because the post/postun scripts have a
73
# test -x update-bootloader, having perl-Bootloader is not a hard requirement.
74
# But, there is no way to tell rpm or yast to schedule the installation
75
# of perl-Bootloader before kernel-binary.rpm if both are in the list of
76
# packages to install/update. Likewise, this is true for mkinitrd.
77
# A specific version of perl-Bootloader is not required, because the post/postun
78
# scripts handle the two API versions of 10.1/SLES10 GA and 10.2/SLES10 SP1
79
Requires(post): perl-Bootloader
80
Requires(post): mkinitrd
81
Recommends: kerneloops
82
#!BuildIgnore:  perl-Bootloader mkinitrd
83
84
%if ! 0%{?opensuse_bs}
85
BuildRequires:  kernel-dummy
86
%endif
87
%if %build_um
88
BuildRequires:  libpcap xorg-x11-devel
89
%endif
90
%ifarch ia64
91
# arch/ia64/scripts/unwcheck.py
92
BuildRequires:  python
93
%endif
94
%ifarch ppc ppc64
95
# for PS3 zImage
96
BuildRequires:  dtc
97
%endif
98
%if %build_xen
99
%ifarch %ix86
100
Provides:       kernel-xenpae = 2.6.27.4
101
Obsoletes:      kernel-xenpae <= 2.6.27.4
102
%endif
103
#!BuildIgnore:  xen
104
%endif
105
106
Provides:     kernel-vanilla-nongpl
107
Obsoletes:    kernel-vanilla-nongpl
108
%if %build_vanilla
109
# force bzip2 instead of lzma compression to allow install on older dist versions
110
%define _binary_payload w9.bzdio
111
%endif
112
# dead network if installed on SLES10, otherwise it will work (mostly)
113
Conflicts:    sysfsutils < 2.0
114
%if ! %build_vanilla
115
Conflicts:    apparmor-profiles <= 2.1
116
Conflicts:    apparmor-parser < 2.3
117
# root-lvm only works with newer udevs
118
Conflicts:      udev < 118
119
Conflicts:      lvm2 < 2.02.33
120
%endif
121
%ifarch %ix86
122
Conflicts:  libc.so.6()(64bit)
123
%endif
124
%if %build_um
125
#Conflicts:    kernel
126
%else
127
Provides:     kernel = 2.6.27.4-%source_rel
128
%endif
129
%ifarch %ix86
130
%else
131
%ifarch ia64
132
%else
133
%ifarch ppc
134
%else
135
%ifarch ppc64
136
%else
137
%ifarch s390
138
Provides:     kernel-32bit k_deflt
139
Obsoletes:    kernel-32bit k_deflt
140
%else
141
%ifarch s390x
142
Provides:     kernel-64bit k_deflt
143
Obsoletes:    kernel-64bit k_deflt
144
%else
145
%ifarch x86_64
146
%endif
147
%endif
148
%endif
149
%endif
150
%endif
151
%endif
152
%endif
153
154
Source0:      http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.tar.bz2
155
Source10:     preun.sh
156
Source11:     postun.sh
157
Source12:     pre.sh
158
Source13:     post.sh
159
Source20:     series.conf
160
Source21:     config.conf
161
Source22:     supported.conf
162
Source30:     arch-symbols
163
Source31:     guards
164
Source32:     config-subst
165
Source33:     check-for-config-changes
166
Source34:     check-supported-list
167
Source38:     kabi-checks
168
Source40:     build-source-timestamp
169
Source41:     built-in-where
170
Source42:     list-exported-symbols
171
Source43:     split-into-symsets
172
Source44:     find-provides
173
Source45:     module-renames
174
Source46:     modversions
175
Source100:    config.tar.bz2
176
Source101:    patches.arch.tar.bz2
177
Source102:    patches.drivers.tar.bz2
178
Source103:    patches.fixes.tar.bz2
179
Source104:    patches.rpmify.tar.bz2
180
Source105:    patches.suse.tar.bz2
181
Source107:    patches.xen.tar.bz2
182
Source108:    patches.addon.tar.bz2
183
Source109:    patches.kernel.org.tar.bz2
184
Source110:    patches.apparmor.tar.bz2
185
Source111:    patches.rt.tar.bz2
186
Source112:    patches.trace.tar.bz2
187
Source120:    kabi.tar.bz2
188
%define my_builddir %_builddir/%{name}-%{version}
189
BuildRoot:    %{_tmppath}/%{name}-%{version}-build
190
ExclusiveArch: %ix86 ia64 ppc ppc64 s390 s390x x86_64
191
192
# These files are found in the kernel-source package:
193
NoSource:     0
194
NoSource:     100
195
NoSource:     101
196
NoSource:     102
197
NoSource:     103
198
NoSource:     104
199
NoSource:     105
200
NoSource:     107
201
NoSource:     108
202
NoSource:     109
203
NoSource:     110
204
NoSource:     111
205
NoSource:     120
206
207
# The following KMPs have been integrated into the kernel package.
208
Obsoletes: iwlwifi-kmp
209
Obsoletes: ipw3945-kmp
210
Obsoletes: adm8211-kmp
211
Obsoletes: rt2x00-kmp
212
Obsoletes: rfswitch-kmp
213
Obsoletes: uvcvideo-kmp
214
Obsoletes: atl2-kmp
215
Obsoletes: wlan-ng-kmp
216
Obsoletes: et131x-kmp
217
Obsoletes: ivtv-kmp
218
Obsoletes: at76_usb-kmp
219
Obsoletes: pcc-acpi-kmp
220
Obsoletes: uvcvideo-kmp
221
Obsoletes: ralink-rt2860-kmp
222
223
# Build with bash instead of sh as the shell: this turns on bash
224
# extensions like <(...).
225
%define _buildshell /bin/bash
226
227
# Provide the exported symbols as "ksym(symbol) = hash"
228
%define __find_provides %_sourcedir/find-provides %name
229
230
# Will modules not listed in supported.conf abort the kernel build (0/1)?
231
%define supported_modules_check 0
232
233
%define tolerate_unknown_new_config_options 1
234
235
# kABI change tolerance (default in maintenance should be 4, 6, 8 or 15,
236
# 31 is the maximum; see scripts/kabi-checks)
237
%define tolerate_kabi_changes 31
238
239
%description
240
Dummy description.
241
242
%prep
243
if ! [ -e %_sourcedir/linux-2.6.27.tar.bz2 ]; then
244
    echo "The kernel-vanilla-2.6.27.4.nosrc.rpm package does not contain the" \
245
     "complete sources. Please install kernel-source-2.6.27.4.src.rpm."
246
    exit 1
247
fi
248
249
echo "Architecture symbol(s):" %symbols
250
251
# Unpack all sources and patches
252
%setup -q -c -T -a 0 -a 100 -a 101 -a 102 -a 103 -a 104 -a 105 -a 107 -a 108 -a 109 -a 110 -a 111 -a 112 -a 120
253
254
supported_conf() {
255
    %_sourcedir/guards %symbols $* < %_sourcedir/supported.conf | sort -u
256
}
257
258
# Generate the list of modules to be marked as supported
259
{   supported_conf base
260
    for how in external; do
261
    comm -2 -3 <(supported_conf base $how) <(supported_conf base) \
262
        | sed -e 's:$: '"$how"':'
263
    done
264
} | sed -e 's,.*/,,' -e 's,\.ko$,,' > linux-2.6.27/Module.supported
265
266
# Create grep pattern file for the modules to end up in the base package
267
comm -2 -3 <(supported_conf base) <(supported_conf) \
268
    | sed -e 's:.*/::' -e 's:^:\\/:' -e 's:$:\.ko$:' \
269
    > %my_builddir/grep-for-base-modules
270
271
cd linux-2.6.27
272
273
# Find out for which architecture to build. We do this here, and use the
274
# result in the %build and %install sections.
275
#
276
# On architectures with a bi-arch or cross compiler, we can compile for
277
# an architecture different from %arch. The location of the config file
278
# tells us for which architecture to compile.
279
set -- %subarch_flavor
280
if [ $# -ne 1 ]; then
281
    echo "$# config files found for this spec file (but one needed)" >&2
282
    exit 1
283
fi
284
subarch=${1%/*}
285
286
# Apply the patches needed for this architecture.
287
%if ! %build_vanilla
288
for patch in $(%_sourcedir/guards %symbols < %_sourcedir/series.conf); do
289
    if ! patch -s -F0 -E -p1 --no-backup-if-mismatch -i ../$patch; then
290
    echo "*** Patch $patch failed ***"
291
    exit 1
292
    fi
293
done
294
%else
295
for patch in $(%_sourcedir/guards %symbols < %_sourcedir/series.conf | egrep kernel.org\|rpmify); do
296
    if ! patch -s -F0 -E -p1 --no-backup-if-mismatch -i ../$patch; then
297
    echo "*** Patch $patch failed ***"
298
    exit 1
299
    fi
300
done
301
%endif
302
303
# Release number without the EXTRAVERSION
304
RELEASE=%source_rel
305
while [ "$RELEASE" != "${RELEASE#[^0-9]*.}" ]; do
306
    RELEASE=${RELEASE#[^0-9]*.}
307
done
308
309
if [ -f %_sourcedir/localversion ] ; then
310
    cat %_sourcedir/localversion > localversion
311
fi
312
313
cat ../config/%subarch_flavor \
314
| %_sourcedir/config-subst CONFIG_LOCALVERSION '"'-$RELEASE-vanilla'"' \
315
| %_sourcedir/config-subst CONFIG_SUSE_KERNEL y \
316
%if 0%{?__debug_package:1}
317
    | %_sourcedir/config-subst CONFIG_DEBUG_INFO y \
318
%endif
319
    > .config
320
321
# We compile for this sub-architecture (i.e., machine architecture):
322
%if %build_um
323
cat > ../.rpm-defs <<EOF
324
ARCH=vanilla
325
SUBARCH=$subarch
326
MAKE_ARGS="ARCH=vanilla SUBARCH=$subarch"
327
EOF
328
%else
329
cat > ../.rpm-defs <<EOF
330
ARCH=$subarch
331
SUBARCH=$subarch
332
MAKE_ARGS="ARCH=$subarch"
333
EOF
334
%endif
335
336
cat >> ../.rpm-defs <<EOF
337
KERNELRELEASE=2.6.27.4-$RELEASE-vanilla
338
EOF
339
340
%if 0%{?__debug_package:1}
341
cat >> ../.rpm-defs <<EOF
342
MAKE_ARGS="\$MAKE_ARGS CONFIG_DEBUG_INFO=y"
343
EOF
344
%endif
345
346
echo CONFIG_MODULES=%CONFIG_MODULES >> ../.rpm-defs
347
348
%build
349
source .rpm-defs
350
351
cd linux-2.6.27
352
cp .config .config.orig
353
%if %{tolerate_unknown_new_config_options}
354
MAKE_ARGS="$MAKE_ARGS -k"
355
yes '' | make oldconfig $MAKE_ARGS
356
%else
357
make silentoldconfig $MAKE_ARGS < /dev/null
358
%_sourcedir/check-for-config-changes .config.orig .config
359
rm .config.orig
360
%endif
361
362
make prepare $MAKE_ARGS
363
krel=$(make -s kernelrelease $MAKE_ARGS)
364
365
if [ "$krel" != "$KERNELRELEASE" ]; then
366
    echo "Kernel release mismatch: $krel != $KERNELRELEASE" >&2
367
    exit 1
368
fi
369
370
371
cat > .kernel-binary.spec.buildenv <<EOF
372
# Override the timestamp 'uname -v' reports with the build
373
# timestamp.
374
export KBUILD_BUILD_VERSION="$(grep SHA1_ID %_sourcedir/build-source-timestamp | awk '{ print $2 }')"
375
export KBUILD_BUILD_TIMESTAMP="$(head -n 1 %_sourcedir/build-source-timestamp)"
376
377
# The following branch/timestamp will end up in Oopses.
378
export OOPS_TIMESTAMP="$(
379
    echo -n $(sed -ne 's/^CVS Branch: \(.*\)/\1-/p' \
380
          %_sourcedir/build-source-timestamp)
381
    head -n 1 %_sourcedir/build-source-timestamp \
382
    | tr -dc 0-9)"
383
384
export KBUILD_VERBOSE=0
385
export KBUILD_SYMTYPES=1
386
EOF
387
source .kernel-binary.spec.buildenv
388
make %{?jobs:-j%jobs} all $MAKE_ARGS CONFIG_DEBUG_SECTION_MISMATCH=y
389
390
%install
391
source .rpm-defs
392
393
# get rid of /usr/lib/rpm/brp-strip-debug
394
# strip removes too much from the vmlinux ELF binary
395
export NO_BRP_STRIP_DEBUG=true
396
397
# /lib/modules/$KERNELRELEASE/build will be a stale symlink until the
398
# kernel-source package is installed. Don't check for stale symlinks
399
# in the brp-symlink check:
400
export NO_BRP_STALE_LINK_ERROR=yes
401
402
cd linux-2.6.27
403
404
mkdir %buildroot/boot
405
# (Could strip out non-public symbols.)
406
cp -p System.map %buildroot/boot/System.map-$KERNELRELEASE
407
408
add_vmlinux()
409
{
410
    local vmlinux=boot/vmlinux-$KERNELRELEASE
411
%if 0%{?__debug_package:1}
412
    local vmlinux_debug=usr/lib/debug/$vmlinux.debug
413
    mkdir -p $(dirname %buildroot/$vmlinux_debug)
414
    cp vmlinux %buildroot/$vmlinux
415
    /usr/lib/rpm/debugedit -b $RPM_BUILD_DIR -d /usr/src/debug \
416
               -l vmlinux.sourcefiles %buildroot/$vmlinux
417
    objcopy --only-keep-debug \
418
        %buildroot/$vmlinux \
419
        %buildroot/$vmlinux_debug || :
420
    objcopy --add-gnu-debuglink=%buildroot/$vmlinux_debug \
421
        --strip-debug \
422
        %buildroot/$vmlinux || :
423
    mkdir -p %buildroot/usr/src/debug
424
    LANG=C sort -z -u vmlinux.sourcefiles | grep -z -v "<built-in>" \
425
    | ( cd %_builddir && cpio -pd0m %buildroot/usr/src/debug )
426
    find %buildroot/usr/src/debug -type d -print0 | xargs -0 -r chmod 0755
427
    find %buildroot/usr/src/debug -type f -print0 | xargs -0 -r chmod 0644
428
%else
429
    cp vmlinux %buildroot/$vmlinux
430
%endif
431
    if [ "$1" = --compressed ]; then
432
    gzip -9 %buildroot/$vmlinux
433
        chmod a-x %buildroot/$vmlinux.gz
434
    fi
435
}
436
437
%if %build_kdump
438
    add_vmlinux
439
    chmod 644 %buildroot/boot/vmlinux-$KERNELRELEASE
440
    image=vmlinux
441
%else
442
%if %build_um
443
    add_vmlinux
444
    chmod 755 %buildroot/boot/vmlinux-$KERNELRELEASE
445
    image=linux
446
%else
447
448
# architecture specifics
449
%ifarch %ix86 x86_64
450
    add_vmlinux --compressed
451
%if %build_xen
452
    image=vmlinuz
453
%else
454
    image=bzImage
455
%endif
456
    cp -p arch/x86/boot/$image %buildroot/boot/vmlinuz-$KERNELRELEASE
457
    image=vmlinuz
458
%endif
459
%ifarch alpha
460
    add_vmlinux --compressed
461
    cp -p arch/alpha/boot/vmlinux.gz %buildroot/boot/vmlinuz-$KERNELRELEASE
462
    image=vmlinuz
463
%endif
464
%ifarch ppc ppc64
465
    add_vmlinux
466
    chmod 644 %buildroot/boot/vmlinux-$KERNELRELEASE
467
    image=vmlinux
468
%endif
469
%ifarch ia64
470
    add_vmlinux --compressed
471
    mv %buildroot/boot/vmlinux-$KERNELRELEASE.gz \
472
       %buildroot/boot/vmlinuz-$KERNELRELEASE
473
    image=vmlinuz
474
%endif
475
%ifarch s390 s390x
476
    add_vmlinux --compressed
477
    cp -p arch/s390/boot/image %buildroot/boot/image-$KERNELRELEASE
478
    image=image
479
%endif
480
    if [ -e init/kerntypes.o ]; then
481
    cp init/kerntypes.o %buildroot/boot/Kerntypes-$KERNELRELEASE
482
    fi
483
484
# end of build_um
485
%endif
486
# end of build_kdump
487
%endif
488
489
for sub in '-base' '' '-extra'; do
490
%if %split_packages
491
    if [ "x$sub" = "x-base" ]; then
492
        base_package=1
493
    else
494
        base_package=0
495
    fi
496
%else
497
    base_package=1
498
%endif
499
    for script in preun postun pre post; do
500
        sed -e "s:@KERNELRELEASE@:$KERNELRELEASE:g" \
501
            -e "s:@IMAGE@:$image:g" \
502
            -e "s:@FLAVOR""@:vanilla:g" \
503
            -e "s:@SUBPACKAGE@:kernel-vanilla$sub:g" \
504
            -e "s:@BASE_PACKAGE@:$base_package:g" \
505
            -e "s:@RPM_VERSION_RELEASE@:%version-%release:g" \
506
            %_sourcedir/$script.sh > ../$script$sub.sh
507
    done
508
done
509
510
511
%if %build_kdump || %build_um || %build_xen || %build_vanilla
512
suffix=-vanilla
513
%endif
514
ln -s $image$suffix %buildroot/boot/$image$suffix
515
ln -s initrd$suffix %buildroot/boot/initrd$suffix
516
517
cp .config %buildroot/boot/config-$KERNELRELEASE
518
519
# Figure out where the symbols that vmlinux exports are defined.
520
# (We need this information below as well as in find-provides; we "annotate"
521
#  the original Module.symvers here to make sure that we are consistent in
522
#  both places.)
523
%_sourcedir/built-in-where < Module.symvers > Module.symvers.split
524
mv Module.symvers.split Module.symvers
525
526
gzip -c9 < Module.symvers > %buildroot/boot/symvers-$KERNELRELEASE.gz
527
528
if [ $CONFIG_MODULES = y ]; then
529
    make modules_install $MAKE_ARGS INSTALL_MOD_PATH=%buildroot
530
531
    if ! %_sourcedir/check-supported-list \
532
        %_sourcedir %buildroot/lib/modules/$KERNELRELEASE; then
533
%if %supported_modules_check
534
    exit 1
535
%endif
536
    echo "Consistency check error: please update supported.conf."
537
    fi
538
539
    # Also put the resulting file in $obj_dir/$SUBARCH/vanilla
540
    # so that kernel-source + kernel-vanilla is sufficient for building
541
    # modules that have modversions as well.
542
    obj_dir=usr/src/linux-${KERNELRELEASE%%-vanilla}-obj
543
    mkdir -p %buildroot/$obj_dir/$SUBARCH/vanilla
544
    cp Module.symvers %buildroot/$obj_dir/$SUBARCH/vanilla
545
546
    # Table of types used in exported symbols (for modversion debugging).
547
    %_sourcedir/modversions --pack . > %buildroot/boot/symtypes-$KERNELRELEASE
548
    if [ -s %buildroot/boot/symtypes-$KERNELRELEASE ]; then
549
    gzip -9 %buildroot/boot/symtypes-$KERNELRELEASE
550
    else
551
    rm -f %buildroot/boot/symtypes-$KERNELRELEASE
552
    fi
553
554
    # Some architecture's $(uname -m) output is different from the ARCH
555
    # parameter that needs to be passed to kbuild. Create symlinks from
556
    # $(uname -m) to the ARCH directory.
557
    [ -e %buildroot/$obj_dir/%_target_cpu ] \
558
    || ln -sf $SUBARCH %buildroot/$obj_dir/%_target_cpu
559
%ifarch ppc ppc64
560
    [ -e %buildroot/$obj_dir/ppc ] \
561
    || ln -s $SUBARCH %buildroot/$obj_dir/ppc
562
    [ -e %buildroot/$obj_dir/ppc64 ] \
563
    || ln -s $SUBARCH %buildroot/$obj_dir/ppc64
564
%endif
565
566
    # Check for kABI changes
567
    KABI=0
568
    if [ -e %my_builddir/kabi/$SUBARCH/symvers-vanilla ]; then
569
    %_sourcedir/kabi-checks \
570
        %my_builddir/kabi/$SUBARCH/symvers-vanilla \
571
        Module.symvers \
572
        %my_builddir/kabi/commonsyms \
573
        %my_builddir/kabi/usedsyms \
574
    || KABI=$?
575
    fi
576
    if [ $KABI -gt %tolerate_kabi_changes ]; then
577
    echo "kABI changes of badness $KABI exceed the maximum allowed badness" \
578
         "of %tolerate_kabi_changes. Please try to avoid the kABI changes."
579
    if [ ! -e %my_builddir/kabi/$SUBARCH/ignore-vanilla -a \
580
         ! -e %_sourcedir/IGNORE-KABI-BADNESS ]; then
581
        echo "Create a file IGNORE-KABI-BADNESS in the kernel-source" \
582
         "directory to build this kernel even though its badness is" \
583
         "higher than allowed for an official kernel."
584
       exit 1
585
    fi
586
587
    # Indicate the ABI badness in build result emails.
588
    echo "KABI BADNESS $KABI" > %_rpmdir/%_arch/mbuild_subject.tag
589
    fi
590
    if [ $KABI -ge 8 ]; then
591
    echo "To find out which types have changed relative to the reference" \
592
         "symbols, diff the symtypes.gz files of the reference kernel" \
593
         "against the symtypes.gz file from this build."
594
    fi
595
596
    # We were building in %my_builddir/linux-2.6.27, but the sources will
597
    # later be installed in /usr/src/linux-2.6.27-%source_rel. Fix up the
598
    # build symlink.
599
    rm -f %buildroot/lib/modules/$KERNELRELEASE/{source,build}
600
    ln -s /usr/src/linux-${KERNELRELEASE%%-vanilla} \
601
    %buildroot/lib/modules/$KERNELRELEASE/source
602
    ln -s /$obj_dir/$SUBARCH/vanilla \
603
    %buildroot/lib/modules/$KERNELRELEASE/build
604
605
    # Abort if there are any undefined symbols
606
    msg="$(/sbin/depmod -F %buildroot/boot/System.map-$KERNELRELEASE \
607
            -b %buildroot -ae $KERNELRELEASE 2>&1)"
608
    if [ $? -ne 0 ] || echo "$msg" | grep  'needs unknown symbol'; then
609
    exit 1
610
    fi
611
612
    # Create a dummy initrd with roughly the size the real one will have.
613
    # That way, YaST will know that this package requires some additional
614
    # space in /boot.
615
    dd if=/dev/zero of=%buildroot/boot/initrd-$KERNELRELEASE \
616
    bs=1024 seek=2047 count=1
617
618
%if %split_packages
619
    # Generate the lists of supported and unsupported modules.
620
    (   cd %buildroot
621
    : > %my_builddir/supported-modules
622
    : > %my_builddir/unsupported-modules
623
    for module in $(find lib/modules/$KERNELRELEASE -type f -name '*.ko'); do
624
        case "$(/sbin/modinfo -F supported $module)" in
625
        (yes|external)
626
        modname=$(basename $module .ko)
627
        deps=$(/sbin/modinfo -F depends $module|tr ',' ' ')
628
        echo "$modname: $deps" >> %my_builddir/Makefile.supported
629
        echo "/$module" >> %my_builddir/supported-modules
630
        ;;
631
        (*)
632
        echo "/$module" >> %my_builddir/unsupported-modules
633
        ;;
634
        esac
635
    done
636
    )
637
638
    add_dependent_modules() {
639
    local modules_dep=$1
640
641
    xargs make -rRs -f <(echo -e '%:\n\t@echo $@' ; cat $modules_dep)
642
    }
643
644
    modules_dep=%buildroot/lib/modules/$KERNELRELEASE/modules.dep
645
646
    # Make sure that no supported modules depend on any unsupported modules.
647
    dependent_unsupported_modules=$(
648
    OUT=$(mktemp)
649
    sed -e 's/:.*//g' < %my_builddir/Makefile.supported | \
650
            xargs make -rRsk -f %my_builddir/Makefile.supported > $OUT
651
    sed -ne '/No rule/s/^.*No rule to make target//p' < $OUT | tr -d "\`'"
652
    )
653
    if [ -n "$dependent_unsupported_modules" ]; then
654
    echo "The following unsupported modules are used by supported modules:"
655
    echo "$dependent_unsupported_modules"
656
    echo "Please fix supported.conf."
657
    if [ ! -e %_sourcedir/IGNORE-UNSUPPORTED-DEPS ]; then
658
        exit 1
659
    fi
660
    fi
661
662
    # Compute the list of base modules: modules that core modules depend on
663
    # implicitly are also core modules.
664
    grep -f %my_builddir/grep-for-base-modules %my_builddir/supported-modules \
665
    | add_dependent_modules $modules_dep > %my_builddir/base-modules
666
667
    # All supported modules which are not core modules belong in kernel-vanilla.
668
    comm -3 <(sort %my_builddir/supported-modules) \
669
        <(sort %my_builddir/base-modules) \
670
    > %my_builddir/main-modules
671
%else
672
    (   cd %buildroot
673
    find lib/modules/$KERNELRELEASE -type f -name '*.ko' -printf '/%%p\n'
674
    ) > %my_builddir/base-modules
675
%endif
676
677
    exported_by_modules() {
678
    local module
679
680
    while read module; do
681
        %_sourcedir/list-exported-symbols $RPM_BUILD_ROOT$module
682
    done
683
    }
684
685
    mkdir %my_builddir/{base,main,extra}
686
    (   awk '$3 == "vmlinux" || $3 ~ /\/built-in$/ { print }' Module.symvers
687
    exported_by_modules < %my_builddir/base-modules
688
    ) | %_sourcedir/split-into-symsets %my_builddir/base
689
%if %split_packages
690
    exported_by_modules < %my_builddir/main-modules \
691
    | %_sourcedir/split-into-symsets %my_builddir/main
692
    exported_by_modules < %my_builddir/unsupported-modules \
693
    | %_sourcedir/split-into-symsets %my_builddir/extra
694
%endif
695
696
    # Notes:
697
    # - We rely on list-exported-symbols to correctly extract all exported
698
    #   symbols from modules; Module.symvers is disregarded for that.
699
    # - We recompute the symsets in find-provides. Take care to keep the
700
    #   algorithm the same in both places.
701
702
    ## Preserve exports from previous kernels when possible.
703
    #old_symsets=%my_builddir/kabi/$SUBARCH/symsets-vanilla.tar.gz
704
    #[ -e $old_symsets ] || old_symsets=
705
    # FIXME: implement
706
707
    symsets=%my_builddir/symsets-$KERNELRELEASE
708
    mkdir $symsets
709
    find %my_builddir/{base,main,extra} -type f \
710
    | xargs --replace='{}' cp '{}' $symsets/
711
    tar c -C ${symsets%/*} ${symsets##*/} \
712
    | gzip -9 \
713
    > %buildroot/boot/symsets-$KERNELRELEASE.tar.gz
714
715
    # FIXME: check for abi changes
716
717
    # Set up some module aliases
718
    install -d -m 755 %buildroot/etc/modprobe.d/
719
    install -m 644 %_sourcedir/module-renames %buildroot/etc/modprobe.d/
720
fi
721
722
add_dirs_to_filelist() {
723
    local filelist
724
725
    filelist=$(cat "$@")
726
    echo "$filelist"
727
728
    # Below, we do this:
729
    # - remove filelist macros
730
    # - remove last pathname component
731
    # - generate all parents and make the list unique
732
    # - skip directories owned be other packages
733
    # - add the %dir prefix (double-escaped for find and rpm)
734
735
    echo "$filelist" \
736
    | sed -re 's:%%%%[a-z]+(\([^)]+\))? ?::g' \
737
    | sed -re 's:/[^/]+$::' \
738
    | sed -nre ':a; p; s:/[^/]+$::; ta' \
739
    | sort -u \
740
    | sed -r -e '\:^(|/boot|/etc|/lib(/modules|/firmware)?|/usr(/src)?)$:d' \
741
    | sed -e 's:^:%%%%dir :'
742
}
743
744
# Collect the file lists.
745
{   cd %buildroot
746
    find boot \
747
    \( -type l -o -name 'initrd-*' \) -printf '%%%%%%%%ghost /%%p\n' -o \
748
    -type f -printf '/%%p\n'
749
750
    # Add the auto-generated (by mkdumprd) kdump initrd to %ghost so that
751
    # the file gets removed when uninstalling the kernel.
752
    echo '%%%%ghost /boot/initrd-'${KERNELRELEASE}'-kdump'
753
    touch $RPM_BUILD_ROOT/boot/initrd-${KERNELRELEASE}-kdump
754
755
    if [ $CONFIG_MODULES = y ]; then
756
    find lib/modules/$KERNELRELEASE \
757
        -type d -o \
758
        -path '*/modules.*' -printf '%%%%%%%%ghost /%%p\n' -o \
759
        -name '*.ko' -prune -o \
760
        -printf '/%%p\n'
761
    cat %my_builddir/base-modules
762
    echo '%%%%config /etc/modprobe.d/module-renames'
763
    find $obj_dir \
764
        -type d -o \
765
        -printf '/%%p\n'
766
    fi
767
    test -d lib/firmware/$KERNELRELEASE && \
768
    find lib/firmware/$KERNELRELEASE \
769
    -type d -o \
770
    -printf '/%%p\n'
771
    if [ -e .%_docdir/%name ]; then
772
    echo "%%%%doc %_docdir/%name"
773
    fi
774
} | add_dirs_to_filelist > %my_builddir/kernel-base.files
775
776
%if %split_packages
777
    add_dirs_to_filelist %my_builddir/main-modules > %my_builddir/kernel-main.files
778
    add_dirs_to_filelist %my_builddir/unsupported-modules > %my_builddir/kernel-extra.files
779
%endif
780
781
# Hardlink duplicate files automatically (from package fdupes): It doesn't save
782
# much, but it keeps rpmlint from breaking the package build.
783
%fdupes $RPM_BUILD_ROOT
784
785
%preun -f preun.sh
786
%postun -f postun.sh
787
%pre -f pre.sh
788
%post -f post.sh
789
790
791
%if %split_packages
792
%files -f kernel-main.files
793
%else
794
%files -f kernel-base.files
795
%endif
796
%defattr(-, root, root)
797
798
%package -n kernel-vanilla-base
799
Summary: Base kernel package
800
License:        GPL
801
Group:          System/Kernel
802
Url:            http://www.kernel.org/
803
AutoReqProv:    on
804
Requires(pre):  coreutils awk
805
Requires(post): module-init-tools
806
Requires(post): perl-Bootloader
807
Requires(post): mkinitrd
808
809
%description -n kernel-vanilla-base
810
Dummy description.
811
812
%preun base -f preun-base.sh
813
%postun base -f postun-base.sh
814
%pre base -f pre-base.sh
815
%post base -f post-base.sh
816
817
%if %split_packages
818
%files -n kernel-vanilla-base -f kernel-base.files
819
%defattr(-, root, root)
820
%endif
821
822
%package -n kernel-vanilla-extra
823
Summary: Unsupported kernel modules
824
License:        GPL
825
Group:          System/Kernel
826
Url:            http://www.kernel.org/
827
AutoReqProv:    on
828
Requires:       kernel-vanilla = %version-%release
829
Requires(pre):  coreutils awk
830
Requires(post): module-init-tools
831
Requires(post): perl-Bootloader
832
Requires(post): mkinitrd
833
Supplements:    packageand(product(SUSE_SLED):kernel-vanilla)
834
Supplements:    packageand(product(openSUSE):kernel-vanilla)
835
836
%description -n kernel-vanilla-extra
837
Dummy description.
838
839
%preun extra -f preun-extra.sh
840
%postun extra -f postun-extra.sh
841
%pre extra -f pre-extra.sh
842
%post extra -f post-extra.sh
843
844
%if %split_packages
845
%files -n kernel-vanilla-extra -f kernel-extra.files
846
%defattr(-, root, root)
847
%endif
848