blob: f47f17aae135188eae37db2178db6c9911a80023 [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
13if [ "$1" = "prebuilt" ]; then
14 PREBUILT=true
15else
16 PREBUILT=false
17fi
18
19# starting to output the spec
20if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then
21 PROVIDES=kernel-drm
22fi
23
24PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
Arun Sharmae1287eb2011-05-04 13:48:11 -070025__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"`
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27echo "Name: kernel"
28echo "Summary: The Linux Kernel"
29echo "Version: $__KERNELRELEASE"
Masahiro Yamada25b080b2017-09-20 22:01:26 +090030echo "Release: $(cat .version 2>/dev/null || echo 1)"
Linus Torvalds1da177e2005-04-16 15:20:36 -070031echo "License: GPL"
32echo "Group: System Environment/Kernel"
33echo "Vendor: The Linux Community"
34echo "URL: http://www.kernel.org"
35
36if ! $PREBUILT; then
37echo "Source: kernel-$__KERNELRELEASE.tar.gz"
38fi
39
John Saalwaechter880df922010-01-31 16:18:58 -080040echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
Linus Torvalds1da177e2005-04-16 15:20:36 -070041echo "Provides: $PROVIDES"
42echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
43echo "%define debug_package %{nil}"
44echo ""
45echo "%description"
46echo "The Linux Kernel, the operating system core itself"
47echo ""
Arun Sharma0bd41df2011-05-17 10:36:16 -070048echo "%package headers"
49echo "Summary: Header files for the Linux kernel for use by glibc"
50echo "Group: Development/System"
51echo "Obsoletes: kernel-headers"
52echo "Provides: kernel-headers = %{version}"
53echo "%description headers"
54echo "Kernel-headers includes the C header files that specify the interface"
55echo "between the Linux kernel and userspace libraries and programs. The"
56echo "header files define structures and constants that are needed for"
57echo "building most standard programs and are also needed for rebuilding the"
58echo "glibc package."
59echo ""
Mike Marciniszyn2174d292013-07-08 13:14:06 -040060echo "%package devel"
61echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
62echo "Group: System Environment/Kernel"
63echo "AutoReqProv: no"
64echo "%description -n kernel-devel"
65echo "This package provides kernel headers and makefiles sufficient to build modules"
66echo "against the $__KERNELRELEASE kernel package."
67echo ""
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69if ! $PREBUILT; then
70echo "%prep"
71echo "%setup -q"
72echo ""
73fi
74
75echo "%build"
76
77if ! $PREBUILT; then
Masahiro Yamada25b080b2017-09-20 22:01:26 +090078echo "make clean && make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}"
Linus Torvalds1da177e2005-04-16 15:20:36 -070079echo ""
80fi
81
82echo "%install"
Mike Marciniszync398ff02013-06-24 08:48:37 -040083echo 'KBUILD_IMAGE=$(make image_name)'
Greg Edwardsd2cb1a92004-07-29 13:07:32 -050084echo "%ifarch ia64"
Rolf Eike Beera5fa3932006-08-14 08:16:47 +020085echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules'
Greg Edwardsd2cb1a92004-07-29 13:07:32 -050086echo "%else"
Rolf Eike Beera5fa3932006-08-14 08:16:47 +020087echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
Greg Edwardsd2cb1a92004-07-29 13:07:32 -050088echo "%endif"
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Masahiro Yamada9e090072017-09-18 18:12:36 +090090echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install'
Greg Edwardsd2cb1a92004-07-29 13:07:32 -050091echo "%ifarch ia64"
92echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
93echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
94echo "%else"
Mike Wolf1a0f3d42006-06-02 09:53:42 -050095echo "%ifarch ppc64"
96echo "cp vmlinux arch/powerpc/boot"
97echo "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
98echo "%else"
Linus Torvalds1da177e2005-04-16 15:20:36 -070099echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
Greg Edwardsd2cb1a92004-07-29 13:07:32 -0500100echo "%endif"
Mike Wolf1a0f3d42006-06-02 09:53:42 -0500101echo "%endif"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
David R. Bilde0367a62013-01-12 10:19:19 -0500103echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
105
106echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
Josh Huntfc370ec2009-02-11 21:10:57 -0800107
108echo "%ifnarch ppc64"
Borislav Petkov92f43c42015-04-19 00:05:14 +0200109echo 'bzip2 -9 --keep vmlinux'
Josh Huntfc370ec2009-02-11 21:10:57 -0800110echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
Josh Huntfc370ec2009-02-11 21:10:57 -0800111echo "%endif"
112
Jérôme Glisseb9a54422014-12-04 10:53:13 -0500113if ! $PREBUILT; then
Anton Tikhomirov51a5f812016-10-25 18:00:44 +0900114echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build"
115echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source"
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400116echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
Masahiro Yamada9e090072017-09-18 18:12:36 +0900117echo "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude .config.old --exclude .missing-syscalls.d\""
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400118echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"
119echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"
120echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
121echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
Jérôme Glisseb9a54422014-12-04 10:53:13 -0500122fi
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124echo ""
125echo "%clean"
Josh Hunta2ebcc72009-02-22 10:54:55 -0800126echo 'rm -rf $RPM_BUILD_ROOT'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127echo ""
Mike Marciniszyn3c9c7a12013-06-24 10:38:22 -0400128echo "%post"
129echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then"
Jiri Kosinac8b08ca2016-02-26 16:15:17 +0100130echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm"
131echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm"
Mike Marciniszyn3c9c7a12013-06-24 10:38:22 -0400132echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE"
Jiri Kosinac8b08ca2016-02-26 16:15:17 +0100133echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
134echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
Mike Marciniszyn3c9c7a12013-06-24 10:38:22 -0400135echo "fi"
136echo ""
Paolo Abeni6ef41e22016-03-02 15:28:00 +0100137echo "%preun"
138echo "if [ -x /sbin/new-kernel-pkg ]; then"
139echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img"
140echo "fi"
141echo ""
Jiri Kosina27c3bff2016-04-07 15:00:54 +0200142echo "%postun"
143echo "if [ -x /sbin/update-bootloader ]; then"
144echo "/sbin/update-bootloader --remove $KERNELRELEASE"
145echo "fi"
146echo ""
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147echo "%files"
148echo '%defattr (-, root, root)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149echo "/lib/modules/$KERNELRELEASE"
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400150echo "%exclude /lib/modules/$KERNELRELEASE/build"
151echo "%exclude /lib/modules/$KERNELRELEASE/source"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152echo "/boot/*"
153echo ""
Arun Sharma0bd41df2011-05-17 10:36:16 -0700154echo "%files headers"
155echo '%defattr (-, root, root)'
156echo "/usr/include"
157echo ""
Jérôme Glisseb9a54422014-12-04 10:53:13 -0500158if ! $PREBUILT; then
Mike Marciniszyn2174d292013-07-08 13:14:06 -0400159echo "%files devel"
160echo '%defattr (-, root, root)'
161echo "/usr/src/kernels/$KERNELRELEASE"
162echo "/lib/modules/$KERNELRELEASE/build"
163echo "/lib/modules/$KERNELRELEASE/source"
164echo ""
Jérôme Glisseb9a54422014-12-04 10:53:13 -0500165fi