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 |
Masahiro Yamada | 8c5d4b6 | 2017-09-30 10:10:06 +0900 | [diff] [blame^] | 14 | S=DEL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | else |
Masahiro Yamada | 8c5d4b6 | 2017-09-30 10:10:06 +0900 | [diff] [blame^] | 16 | S= |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Masahiro Yamada | 8c5d4b6 | 2017-09-30 10:10:06 +0900 | [diff] [blame^] | 29 | # 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 |
| 33 | sed -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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
Masahiro Yamada | 8c5d4b6 | 2017-09-30 10:10:06 +0900 | [diff] [blame^] | 47 | %description |
| 48 | The Linux Kernel, the operating system core itself |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Masahiro Yamada | 8c5d4b6 | 2017-09-30 10:10:06 +0900 | [diff] [blame^] | 50 | %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 Yamada | 5289c32 | 2017-09-30 10:10:05 +0900 | [diff] [blame] | 61 | |
Masahiro Yamada | 8c5d4b6 | 2017-09-30 10:10:06 +0900 | [diff] [blame^] | 62 | $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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
Masahiro Yamada | 8c5d4b6 | 2017-09-30 10:10:06 +0900 | [diff] [blame^] | 99 | %clean |
| 100 | rm -rf \$RPM_BUILD_ROOT |
Josh Hunt | fc370ec | 2009-02-11 21:10:57 -0800 | [diff] [blame] | 101 | |
Masahiro Yamada | 8c5d4b6 | 2017-09-30 10:10:06 +0900 | [diff] [blame^] | 102 | %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 Marciniszyn | 2174d29 | 2013-07-08 13:14:06 -0400 | [diff] [blame] | 110 | |
Masahiro Yamada | 8c5d4b6 | 2017-09-30 10:10:06 +0900 | [diff] [blame^] | 111 | %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 |
| 137 | EOF |