Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
Mike Marciniszyn | 2174d29 | 2013-07-08 13:14:06 -0400 | [diff] [blame] | 3 | # Output a simple RPM spec file. |
| 4 | # This version assumes a minimum of RPM 4.0.3. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | # |
| 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 Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 13 | if [ "$1" = prebuilt ]; then |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | PREBUILT=true |
| 15 | else |
| 16 | PREBUILT=false |
| 17 | fi |
| 18 | |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 19 | if grep -q CONFIG_DRM=y .config; then |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | PROVIDES=kernel-drm |
| 21 | fi |
| 22 | |
| 23 | PROVIDES="$PROVIDES kernel-$KERNELRELEASE" |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 24 | __KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g") |
| 25 | EXCLUDES="$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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
| 29 | echo "Name: kernel" |
| 30 | echo "Summary: The Linux Kernel" |
| 31 | echo "Version: $__KERNELRELEASE" |
Masahiro Yamada | 25b080b | 2017-09-20 22:01:26 +0900 | [diff] [blame] | 32 | echo "Release: $(cat .version 2>/dev/null || echo 1)" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | echo "License: GPL" |
| 34 | echo "Group: System Environment/Kernel" |
| 35 | echo "Vendor: The Linux Community" |
| 36 | echo "URL: http://www.kernel.org" |
| 37 | |
| 38 | if ! $PREBUILT; then |
| 39 | echo "Source: kernel-$__KERNELRELEASE.tar.gz" |
| 40 | fi |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | echo "Provides: $PROVIDES" |
| 43 | echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" |
| 44 | echo "%define debug_package %{nil}" |
| 45 | echo "" |
| 46 | echo "%description" |
| 47 | echo "The Linux Kernel, the operating system core itself" |
| 48 | echo "" |
Arun Sharma | 0bd41df | 2011-05-17 10:36:16 -0700 | [diff] [blame] | 49 | echo "%package headers" |
| 50 | echo "Summary: Header files for the Linux kernel for use by glibc" |
| 51 | echo "Group: Development/System" |
| 52 | echo "Obsoletes: kernel-headers" |
| 53 | echo "Provides: kernel-headers = %{version}" |
| 54 | echo "%description headers" |
| 55 | echo "Kernel-headers includes the C header files that specify the interface" |
| 56 | echo "between the Linux kernel and userspace libraries and programs. The" |
| 57 | echo "header files define structures and constants that are needed for" |
| 58 | echo "building most standard programs and are also needed for rebuilding the" |
| 59 | echo "glibc package." |
| 60 | echo "" |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 61 | |
| 62 | if ! $PREBUILT; then |
Mike Marciniszyn | 2174d29 | 2013-07-08 13:14:06 -0400 | [diff] [blame] | 63 | echo "%package devel" |
| 64 | echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel" |
| 65 | echo "Group: System Environment/Kernel" |
| 66 | echo "AutoReqProv: no" |
| 67 | echo "%description -n kernel-devel" |
| 68 | echo "This package provides kernel headers and makefiles sufficient to build modules" |
| 69 | echo "against the $__KERNELRELEASE kernel package." |
| 70 | echo "" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | echo "%prep" |
| 72 | echo "%setup -q" |
| 73 | echo "" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | echo "%build" |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 75 | echo "make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | echo "" |
| 77 | fi |
| 78 | |
| 79 | echo "%install" |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 80 | echo 'mkdir -p $RPM_BUILD_ROOT/boot' |
Greg Edwards | d2cb1a9 | 2004-07-29 13:07:32 -0500 | [diff] [blame] | 81 | echo "%ifarch ia64" |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 82 | echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi' |
| 83 | echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" |
Greg Edwards | d2cb1a9 | 2004-07-29 13:07:32 -0500 | [diff] [blame] | 84 | echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" |
| 85 | echo "%else" |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 86 | echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" |
Greg Edwards | d2cb1a9 | 2004-07-29 13:07:32 -0500 | [diff] [blame] | 87 | echo "%endif" |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 88 | echo 'make %{?_smp_mflags} INSTALL_MOD_PATH=$RPM_BUILD_ROOT KBUILD_SRC= modules_install' |
David R. Bild | e0367a6 | 2013-01-12 10:19:19 -0500 | [diff] [blame] | 89 | echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install' |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" |
Borislav Petkov | 92f43c4 | 2015-04-19 00:05:14 +0200 | [diff] [blame] | 92 | echo 'bzip2 -9 --keep vmlinux' |
Josh Hunt | fc370ec | 2009-02-11 21:10:57 -0800 | [diff] [blame] | 93 | echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" |
Josh Hunt | fc370ec | 2009-02-11 21:10:57 -0800 | [diff] [blame] | 94 | |
Jérôme Glisse | b9a5442 | 2014-12-04 10:53:13 -0500 | [diff] [blame] | 95 | if ! $PREBUILT; then |
Anton Tikhomirov | 51a5f81 | 2016-10-25 18:00:44 +0900 | [diff] [blame] | 96 | echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build" |
| 97 | echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source" |
Mike Marciniszyn | 2174d29 | 2013-07-08 13:14:06 -0400 | [diff] [blame] | 98 | echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 99 | echo "tar cf - . $EXCLUDES | tar xf - -C "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" |
Mike Marciniszyn | 2174d29 | 2013-07-08 13:14:06 -0400 | [diff] [blame] | 100 | echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE" |
| 101 | echo "ln -sf /usr/src/kernels/$KERNELRELEASE build" |
| 102 | echo "ln -sf /usr/src/kernels/$KERNELRELEASE source" |
Jérôme Glisse | b9a5442 | 2014-12-04 10:53:13 -0500 | [diff] [blame] | 103 | fi |
Mike Marciniszyn | 2174d29 | 2013-07-08 13:14:06 -0400 | [diff] [blame] | 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | echo "" |
| 106 | echo "%clean" |
Josh Hunt | a2ebcc7 | 2009-02-22 10:54:55 -0800 | [diff] [blame] | 107 | echo 'rm -rf $RPM_BUILD_ROOT' |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | echo "" |
Mike Marciniszyn | 3c9c7a1 | 2013-06-24 10:38:22 -0400 | [diff] [blame] | 109 | echo "%post" |
| 110 | echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then" |
Jiri Kosina | c8b08ca | 2016-02-26 16:15:17 +0100 | [diff] [blame] | 111 | echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm" |
| 112 | echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm" |
Mike Marciniszyn | 3c9c7a1 | 2013-06-24 10:38:22 -0400 | [diff] [blame] | 113 | echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE" |
Jiri Kosina | c8b08ca | 2016-02-26 16:15:17 +0100 | [diff] [blame] | 114 | echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" |
| 115 | echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" |
Mike Marciniszyn | 3c9c7a1 | 2013-06-24 10:38:22 -0400 | [diff] [blame] | 116 | echo "fi" |
| 117 | echo "" |
Paolo Abeni | 6ef41e2 | 2016-03-02 15:28:00 +0100 | [diff] [blame] | 118 | echo "%preun" |
| 119 | echo "if [ -x /sbin/new-kernel-pkg ]; then" |
| 120 | echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img" |
| 121 | echo "fi" |
| 122 | echo "" |
Jiri Kosina | 27c3bff | 2016-04-07 15:00:54 +0200 | [diff] [blame] | 123 | echo "%postun" |
| 124 | echo "if [ -x /sbin/update-bootloader ]; then" |
| 125 | echo "/sbin/update-bootloader --remove $KERNELRELEASE" |
| 126 | echo "fi" |
| 127 | echo "" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | echo "%files" |
| 129 | echo '%defattr (-, root, root)' |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | echo "/lib/modules/$KERNELRELEASE" |
Mike Marciniszyn | 2174d29 | 2013-07-08 13:14:06 -0400 | [diff] [blame] | 131 | echo "%exclude /lib/modules/$KERNELRELEASE/build" |
| 132 | echo "%exclude /lib/modules/$KERNELRELEASE/source" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | echo "/boot/*" |
| 134 | echo "" |
Arun Sharma | 0bd41df | 2011-05-17 10:36:16 -0700 | [diff] [blame] | 135 | echo "%files headers" |
| 136 | echo '%defattr (-, root, root)' |
| 137 | echo "/usr/include" |
Jérôme Glisse | b9a5442 | 2014-12-04 10:53:13 -0500 | [diff] [blame] | 138 | if ! $PREBUILT; then |
Masahiro Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame^] | 139 | echo "" |
Mike Marciniszyn | 2174d29 | 2013-07-08 13:14:06 -0400 | [diff] [blame] | 140 | echo "%files devel" |
| 141 | echo '%defattr (-, root, root)' |
| 142 | echo "/usr/src/kernels/$KERNELRELEASE" |
| 143 | echo "/lib/modules/$KERNELRELEASE/build" |
| 144 | echo "/lib/modules/$KERNELRELEASE/source" |
Jérôme Glisse | b9a5442 | 2014-12-04 10:53:13 -0500 | [diff] [blame] | 145 | fi |