blob: 97feb60e6482e3f8d6bdd060b0678a90701a1f30 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 PREBUILT=true
15else
16 PREBUILT=false
17fi
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
29echo "Name: kernel"
30echo "Summary: The Linux Kernel"
31echo "Version: $__KERNELRELEASE"
Masahiro Yamada25b080b2017-09-20 22:01:26 +090032echo "Release: $(cat .version 2>/dev/null || echo 1)"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033echo "License: GPL"
34echo "Group: System Environment/Kernel"
35echo "Vendor: The Linux Community"
36echo "URL: http://www.kernel.org"
37
38if ! $PREBUILT; then
39echo "Source: kernel-$__KERNELRELEASE.tar.gz"
40fi
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042echo "Provides: $PROVIDES"
43echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
44echo "%define debug_package %{nil}"
45echo ""
46echo "%description"
47echo "The Linux Kernel, the operating system core itself"
48echo ""
Arun Sharma0bd41df2011-05-17 10:36:16 -070049echo "%package headers"
50echo "Summary: Header files for the Linux kernel for use by glibc"
51echo "Group: Development/System"
52echo "Obsoletes: kernel-headers"
53echo "Provides: kernel-headers = %{version}"
54echo "%description headers"
55echo "Kernel-headers includes the C header files that specify the interface"
56echo "between the Linux kernel and userspace libraries and programs. The"
57echo "header files define structures and constants that are needed for"
58echo "building most standard programs and are also needed for rebuilding the"
59echo "glibc package."
60echo ""
Masahiro Yamada5289c322017-09-30 10:10:05 +090061
62if ! $PREBUILT; then
Mike Marciniszyn2174d292013-07-08 13:14:06 -040063echo "%package devel"
64echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
65echo "Group: System Environment/Kernel"
66echo "AutoReqProv: no"
67echo "%description -n kernel-devel"
68echo "This package provides kernel headers and makefiles sufficient to build modules"
69echo "against the $__KERNELRELEASE kernel package."
70echo ""
Linus Torvalds1da177e2005-04-16 15:20:36 -070071echo "%prep"
72echo "%setup -q"
73echo ""
Linus Torvalds1da177e2005-04-16 15:20:36 -070074echo "%build"
Masahiro Yamada5289c322017-09-30 10:10:05 +090075echo "make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}"
Linus Torvalds1da177e2005-04-16 15:20:36 -070076echo ""
77fi
78
79echo "%install"
Masahiro Yamada5289c322017-09-30 10:10:05 +090080echo 'mkdir -p $RPM_BUILD_ROOT/boot'
Greg Edwardsd2cb1a92004-07-29 13:07:32 -050081echo "%ifarch ia64"
Masahiro Yamada5289c322017-09-30 10:10:05 +090082echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi'
83echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
Greg Edwardsd2cb1a92004-07-29 13:07:32 -050084echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
85echo "%else"
Masahiro Yamada5289c322017-09-30 10:10:05 +090086echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
Greg Edwardsd2cb1a92004-07-29 13:07:32 -050087echo "%endif"
Masahiro Yamada5289c322017-09-30 10:10:05 +090088echo 'make %{?_smp_mflags} INSTALL_MOD_PATH=$RPM_BUILD_ROOT KBUILD_SRC= modules_install'
David R. Bilde0367a62013-01-12 10:19:19 -050089echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install'
Linus Torvalds1da177e2005-04-16 15:20:36 -070090echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
Linus Torvalds1da177e2005-04-16 15:20:36 -070091echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
Borislav Petkov92f43c42015-04-19 00:05:14 +020092echo 'bzip2 -9 --keep vmlinux'
Josh Huntfc370ec2009-02-11 21:10:57 -080093echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
Josh Huntfc370ec2009-02-11 21:10:57 -080094
Jérôme Glisseb9a54422014-12-04 10:53:13 -050095if ! $PREBUILT; then
Anton Tikhomirov51a5f812016-10-25 18:00:44 +090096echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build"
97echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source"
Mike Marciniszyn2174d292013-07-08 13:14:06 -040098echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
Masahiro Yamada5289c322017-09-30 10:10:05 +090099echo "tar cf - . $EXCLUDES | tar xf - -C "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400100echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"
101echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
102echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
Jérôme Glisseb9a54422014-12-04 10:53:13 -0500103fi
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105echo ""
106echo "%clean"
Josh Hunta2ebcc72009-02-22 10:54:55 -0800107echo 'rm -rf $RPM_BUILD_ROOT'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108echo ""
Mike Marciniszyn3c9c7a12013-06-24 10:38:22 -0400109echo "%post"
110echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then"
Jiri Kosinac8b08ca2016-02-26 16:15:17 +0100111echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm"
112echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm"
Mike Marciniszyn3c9c7a12013-06-24 10:38:22 -0400113echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE"
Jiri Kosinac8b08ca2016-02-26 16:15:17 +0100114echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
115echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
Mike Marciniszyn3c9c7a12013-06-24 10:38:22 -0400116echo "fi"
117echo ""
Paolo Abeni6ef41e22016-03-02 15:28:00 +0100118echo "%preun"
119echo "if [ -x /sbin/new-kernel-pkg ]; then"
120echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img"
121echo "fi"
122echo ""
Jiri Kosina27c3bff2016-04-07 15:00:54 +0200123echo "%postun"
124echo "if [ -x /sbin/update-bootloader ]; then"
125echo "/sbin/update-bootloader --remove $KERNELRELEASE"
126echo "fi"
127echo ""
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128echo "%files"
129echo '%defattr (-, root, root)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130echo "/lib/modules/$KERNELRELEASE"
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400131echo "%exclude /lib/modules/$KERNELRELEASE/build"
132echo "%exclude /lib/modules/$KERNELRELEASE/source"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133echo "/boot/*"
134echo ""
Arun Sharma0bd41df2011-05-17 10:36:16 -0700135echo "%files headers"
136echo '%defattr (-, root, root)'
137echo "/usr/include"
Jérôme Glisseb9a54422014-12-04 10:53:13 -0500138if ! $PREBUILT; then
Masahiro Yamada5289c322017-09-30 10:10:05 +0900139echo ""
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400140echo "%files devel"
141echo '%defattr (-, root, root)'
142echo "/usr/src/kernels/$KERNELRELEASE"
143echo "/lib/modules/$KERNELRELEASE/build"
144echo "/lib/modules/$KERNELRELEASE/source"
Jérôme Glisseb9a54422014-12-04 10:53:13 -0500145fi