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

File kernel-rt.spec of Package kernel-source (Revision 9b249f3246d1f30fcec837029aa086fe)

Currently displaying revision 9b249f3246d1f30fcec837029aa086fe, show latest

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