2005-04-17 02:20:36 +04:00
#!/bin/sh
#
2013-07-08 21:14:06 +04:00
# Output a simple RPM spec file.
# This version assumes a minimum of RPM 4.0.3.
2005-04-17 02:20:36 +04:00
#
# The only gothic bit here is redefining install_post to avoid
# stripping the symbols from files in the kernel which we want
#
# Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
#
# how we were called determines which rpms we build and how we build them
2017-09-30 04:10:05 +03:00
if [ "$1" = prebuilt ]; then
2017-09-30 04:10:06 +03:00
S=DEL
2005-04-17 02:20:36 +04:00
else
2017-09-30 04:10:06 +03:00
S=
2005-04-17 02:20:36 +04:00
fi
2017-09-30 04:10:07 +03:00
if grep -q CONFIG_MODULES=y .config; then
M=
else
M=DEL
fi
2017-09-30 04:10:05 +03:00
if grep -q CONFIG_DRM=y .config; then
2005-04-17 02:20:36 +04:00
PROVIDES=kernel-drm
fi
PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
2017-09-30 04:10:05 +03:00
__KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \
--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
--exclude=.config.old --exclude=.missing-syscalls.d"
2005-04-17 02:20:36 +04:00
2017-09-30 04:10:06 +03:00
# We can label the here-doc lines for conditional output to the spec file
#
# Labels:
# $S: this line is enabled only when building source package
2017-09-30 04:10:07 +03:00
# $M: this line is enabled only when CONFIG_MODULES is enabled
2017-09-30 04:10:06 +03:00
sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
Name: kernel
Summary: The Linux Kernel
Version: $__KERNELRELEASE
Release: $(cat .version 2>/dev/null || echo 1)
License: GPL
Group: System Environment/Kernel
Vendor: The Linux Community
URL: http://www.kernel.org
$S Source: kernel-$__KERNELRELEASE.tar.gz
Provides: $PROVIDES
%define __spec_install_post /usr/lib/rpm/brp-compress || :
%define debug_package %{nil}
2005-04-17 02:20:36 +04:00
2017-09-30 04:10:06 +03:00
%description
The Linux Kernel, the operating system core itself
2005-04-17 02:20:36 +04:00
2017-09-30 04:10:06 +03:00
%package headers
Summary: Header files for the Linux kernel for use by glibc
Group: Development/System
Obsoletes: kernel-headers
Provides: kernel-headers = %{version}
%description headers
Kernel-headers includes the C header files that specify the interface
between the Linux kernel and userspace libraries and programs. The
header files define structures and constants that are needed for
building most standard programs and are also needed for rebuilding the
glibc package.
2017-09-30 04:10:05 +03:00
2017-09-30 04:10:07 +03:00
$S$M %package devel
$S$M Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel
$S$M Group: System Environment/Kernel
$S$M AutoReqProv: no
$S$M %description -n kernel-devel
$S$M This package provides kernel headers and makefiles sufficient to build modules
$S$M against the $__KERNELRELEASE kernel package.
$S$M
2017-09-30 04:10:06 +03:00
$S %prep
$S %setup -q
$S
$S %build
$S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
$S
%install
mkdir -p \$RPM_BUILD_ROOT/boot
%ifarch ia64
mkdir -p \$RPM_BUILD_ROOT/boot/efi
cp \$(make image_name) \$RPM_BUILD_ROOT/boot/efi/vmlinuz-$KERNELRELEASE
ln -s efi/vmlinuz-$KERNELRELEASE \$RPM_BUILD_ROOT/boot/
%else
cp \$(make image_name) \$RPM_BUILD_ROOT/boot/vmlinuz-$KERNELRELEASE
%endif
2017-09-30 04:10:07 +03:00
$M make %{?_smp_mflags} INSTALL_MOD_PATH=\$RPM_BUILD_ROOT KBUILD_SRC= modules_install
2017-09-30 04:10:06 +03:00
make %{?_smp_mflags} INSTALL_HDR_PATH=\$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install
cp System.map \$RPM_BUILD_ROOT/boot/System.map-$KERNELRELEASE
cp .config \$RPM_BUILD_ROOT/boot/config-$KERNELRELEASE
bzip2 -9 --keep vmlinux
mv vmlinux.bz2 \$RPM_BUILD_ROOT/boot/vmlinux-$KERNELRELEASE.bz2
2017-09-30 04:10:07 +03:00
$S$M rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/build
$S$M rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/source
$S$M mkdir -p \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE
$S$M tar cf - . $EXCLUDES | tar xf - -C \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE
$S$M cd \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE
$S$M ln -sf /usr/src/kernels/$KERNELRELEASE build
$S$M ln -sf /usr/src/kernels/$KERNELRELEASE source
2005-04-17 02:20:36 +04:00
2017-09-30 04:10:06 +03:00
%clean
rm -rf \$RPM_BUILD_ROOT
2009-02-12 08:10:57 +03:00
2017-09-30 04:10:06 +03:00
%post
if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then
cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm
cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm
rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE
/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
fi
2013-07-08 21:14:06 +04:00
2017-09-30 04:10:06 +03:00
%preun
if [ -x /sbin/new-kernel-pkg ]; then
new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img
fi
%postun
if [ -x /sbin/update-bootloader ]; then
/sbin/update-bootloader --remove $KERNELRELEASE
fi
%files
%defattr (-, root, root)
2017-09-30 04:10:07 +03:00
$M /lib/modules/$KERNELRELEASE
$M %exclude /lib/modules/$KERNELRELEASE/build
$M %exclude /lib/modules/$KERNELRELEASE/source
2017-09-30 04:10:06 +03:00
/boot/*
%files headers
%defattr (-, root, root)
/usr/include
2017-09-30 04:10:07 +03:00
$S$M
$S$M %files devel
$S$M %defattr (-, root, root)
$S$M /usr/src/kernels/$KERNELRELEASE
$S$M /lib/modules/$KERNELRELEASE/build
$S$M /lib/modules/$KERNELRELEASE/source
2017-09-30 04:10:06 +03:00
EOF