summaryrefslogtreecommitdiffstats
path: root/scripts/package/mkspec
blob: b341d5d8e7932c42225181ea4f174f74a0414e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh
#
#	Output a simple RPM spec file.
#	This version assumes a minimum of RPM 4.0.3.
#
#	The only gothic bit here is redefining install_post to avoid
#	stripping the symbols from files in the kernel which we want
#
#	Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
#

# how we were called determines which rpms we build and how we build them
if [ "$1" = prebuilt ]; then
	S=DEL
else
	S=
fi

if grep -q CONFIG_DRM=y .config; then
	PROVIDES=kernel-drm
fi

PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
__KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \
--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
--exclude=.config.old --exclude=.missing-syscalls.d"

# We can label the here-doc lines for conditional output to the spec file
#
# Labels:
#  $S: this line is enabled only when building source package
sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
	Name: kernel
	Summary: The Linux Kernel
	Version: $__KERNELRELEASE
	Release: $(cat .version 2>/dev/null || echo 1)
	License: GPL
	Group: System Environment/Kernel
	Vendor: The Linux Community
	URL: http://www.kernel.org
$S	Source: kernel-$__KERNELRELEASE.tar.gz
	Provides: $PROVIDES
	%define __spec_install_post /usr/lib/rpm/brp-compress || :
	%define debug_package %{nil}

	%description
	The Linux Kernel, the operating system core itself

	%package headers
	Summary: Header files for the Linux kernel for use by glibc
	Group: Development/System
	Obsoletes: kernel-headers
	Provides: kernel-headers = %{version}
	%description headers
	Kernel-headers includes the C header files that specify the interface
	between the Linux kernel and userspace libraries and programs.  The
	header files define structures and constants that are needed for
	building most standard programs and are also needed for rebuilding the
	glibc package.

$S	%package devel
$S	Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel
$S	Group: System Environment/Kernel
$S	AutoReqProv: no
$S	%description -n kernel-devel
$S	This package provides kernel headers and makefiles sufficient to build modules
$S	against the $__KERNELRELEASE kernel package.
$S
$S	%prep
$S	%setup -q
$S
$S	%build
$S	make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
$S
	%install
	mkdir -p \$RPM_BUILD_ROOT/boot
	%ifarch ia64
	mkdir -p \$RPM_BUILD_ROOT/boot/efi
	cp \$(make image_name) \$RPM_BUILD_ROOT/boot/efi/vmlinuz-$KERNELRELEASE
	ln -s efi/vmlinuz-$KERNELRELEASE \$RPM_BUILD_ROOT/boot/
	%else
	cp \$(make image_name) \$RPM_BUILD_ROOT/boot/vmlinuz-$KERNELRELEASE
	%endif
	make %{?_smp_mflags} INSTALL_MOD_PATH=\$RPM_BUILD_ROOT KBUILD_SRC= modules_install
	make %{?_smp_mflags} INSTALL_HDR_PATH=\$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install
	cp System.map \$RPM_BUILD_ROOT/boot/System.map-$KERNELRELEASE
	cp .config \$RPM_BUILD_ROOT/boot/config-$KERNELRELEASE
	bzip2 -9 --keep vmlinux
	mv vmlinux.bz2 \$RPM_BUILD_ROOT/boot/vmlinux-$KERNELRELEASE.bz2
$S	rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/build
$S	rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/source
$S	mkdir -p \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE
$S	tar cf - . $EXCLUDES | tar xf - -C \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE
$S	cd \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE
$S	ln -sf /usr/src/kernels/$KERNELRELEASE build
$S	ln -sf /usr/src/kernels/$KERNELRELEASE source

	%clean
	rm -rf \$RPM_BUILD_ROOT

	%post
	if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then
	cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm
	cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm
	rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE
	/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
	rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
	fi

	%preun
	if [ -x /sbin/new-kernel-pkg ]; then
	new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img
	fi

	%postun
	if [ -x /sbin/update-bootloader ]; then
	/sbin/update-bootloader --remove $KERNELRELEASE
	fi

	%files
	%defattr (-, root, root)
	/lib/modules/$KERNELRELEASE
	%exclude /lib/modules/$KERNELRELEASE/build
	%exclude /lib/modules/$KERNELRELEASE/source
	/boot/*

	%files headers
	%defattr (-, root, root)
	/usr/include
$S
$S	%files devel
$S	%defattr (-, root, root)
$S	/usr/src/kernels/$KERNELRELEASE
$S	/lib/modules/$KERNELRELEASE/build
$S	/lib/modules/$KERNELRELEASE/source
EOF