blob: b341d5d8e7932c42225181ea4f174f74a0414e96 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#!/bin/sh
2#
Mike Marciniszyn2174d292013-07-08 13:14:06 -04003# Output a simple RPM spec file.
4# This version assumes a minimum of RPM 4.0.3.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#
6# The only gothic bit here is redefining install_post to avoid
7# stripping the symbols from files in the kernel which we want
8#
9# Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
10#
11
12# how we were called determines which rpms we build and how we build them
Masahiro Yamada5289c322017-09-30 10:10:05 +090013if [ "$1" = prebuilt ]; then
Masahiro Yamada8c5d4b62017-09-30 10:10:06 +090014 S=DEL
Linus Torvalds1da177e2005-04-16 15:20:36 -070015else
Masahiro Yamada8c5d4b62017-09-30 10:10:06 +090016 S=
Linus Torvalds1da177e2005-04-16 15:20:36 -070017fi
18
Masahiro Yamada5289c322017-09-30 10:10:05 +090019if grep -q CONFIG_DRM=y .config; then
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 PROVIDES=kernel-drm
21fi
22
23PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
Masahiro Yamada5289c322017-09-30 10:10:05 +090024__KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
25EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \
26--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
27--exclude=.config.old --exclude=.missing-syscalls.d"
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Masahiro Yamada8c5d4b62017-09-30 10:10:06 +090029# We can label the here-doc lines for conditional output to the spec file
30#
31# Labels:
32# $S: this line is enabled only when building source package
33sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
34 Name: kernel
35 Summary: The Linux Kernel
36 Version: $__KERNELRELEASE
37 Release: $(cat .version 2>/dev/null || echo 1)
38 License: GPL
39 Group: System Environment/Kernel
40 Vendor: The Linux Community
41 URL: http://www.kernel.org
42$S Source: kernel-$__KERNELRELEASE.tar.gz
43 Provides: $PROVIDES
44 %define __spec_install_post /usr/lib/rpm/brp-compress || :
45 %define debug_package %{nil}
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Masahiro Yamada8c5d4b62017-09-30 10:10:06 +090047 %description
48 The Linux Kernel, the operating system core itself
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Masahiro Yamada8c5d4b62017-09-30 10:10:06 +090050 %package headers
51 Summary: Header files for the Linux kernel for use by glibc
52 Group: Development/System
53 Obsoletes: kernel-headers
54 Provides: kernel-headers = %{version}
55 %description headers
56 Kernel-headers includes the C header files that specify the interface
57 between the Linux kernel and userspace libraries and programs. The
58 header files define structures and constants that are needed for
59 building most standard programs and are also needed for rebuilding the
60 glibc package.
Masahiro Yamada5289c322017-09-30 10:10:05 +090061
Masahiro Yamada8c5d4b62017-09-30 10:10:06 +090062$S %package devel
63$S Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel
64$S Group: System Environment/Kernel
65$S AutoReqProv: no
66$S %description -n kernel-devel
67$S This package provides kernel headers and makefiles sufficient to build modules
68$S against the $__KERNELRELEASE kernel package.
69$S
70$S %prep
71$S %setup -q
72$S
73$S %build
74$S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
75$S
76 %install
77 mkdir -p \$RPM_BUILD_ROOT/boot
78 %ifarch ia64
79 mkdir -p \$RPM_BUILD_ROOT/boot/efi
80 cp \$(make image_name) \$RPM_BUILD_ROOT/boot/efi/vmlinuz-$KERNELRELEASE
81 ln -s efi/vmlinuz-$KERNELRELEASE \$RPM_BUILD_ROOT/boot/
82 %else
83 cp \$(make image_name) \$RPM_BUILD_ROOT/boot/vmlinuz-$KERNELRELEASE
84 %endif
85 make %{?_smp_mflags} INSTALL_MOD_PATH=\$RPM_BUILD_ROOT KBUILD_SRC= modules_install
86 make %{?_smp_mflags} INSTALL_HDR_PATH=\$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install
87 cp System.map \$RPM_BUILD_ROOT/boot/System.map-$KERNELRELEASE
88 cp .config \$RPM_BUILD_ROOT/boot/config-$KERNELRELEASE
89 bzip2 -9 --keep vmlinux
90 mv vmlinux.bz2 \$RPM_BUILD_ROOT/boot/vmlinux-$KERNELRELEASE.bz2
91$S rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/build
92$S rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/source
93$S mkdir -p \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE
94$S tar cf - . $EXCLUDES | tar xf - -C \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE
95$S cd \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE
96$S ln -sf /usr/src/kernels/$KERNELRELEASE build
97$S ln -sf /usr/src/kernels/$KERNELRELEASE source
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Masahiro Yamada8c5d4b62017-09-30 10:10:06 +090099 %clean
100 rm -rf \$RPM_BUILD_ROOT
Josh Huntfc370ec2009-02-11 21:10:57 -0800101
Masahiro Yamada8c5d4b62017-09-30 10:10:06 +0900102 %post
103 if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then
104 cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm
105 cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm
106 rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE
107 /sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
108 rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
109 fi
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400110
Masahiro Yamada8c5d4b62017-09-30 10:10:06 +0900111 %preun
112 if [ -x /sbin/new-kernel-pkg ]; then
113 new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img
114 fi
115
116 %postun
117 if [ -x /sbin/update-bootloader ]; then
118 /sbin/update-bootloader --remove $KERNELRELEASE
119 fi
120
121 %files
122 %defattr (-, root, root)
123 /lib/modules/$KERNELRELEASE
124 %exclude /lib/modules/$KERNELRELEASE/build
125 %exclude /lib/modules/$KERNELRELEASE/source
126 /boot/*
127
128 %files headers
129 %defattr (-, root, root)
130 /usr/include
131$S
132$S %files devel
133$S %defattr (-, root, root)
134$S /usr/src/kernels/$KERNELRELEASE
135$S /lib/modules/$KERNELRELEASE/build
136$S /lib/modules/$KERNELRELEASE/source
137EOF