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