1#!/bin/sh 2# 3# Output a simple RPM spec file. 4# This version assumes a minimum of RPM 4.0.3. 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 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" 25__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"` 26 27echo "Name: kernel" 28echo "Summary: The Linux Kernel" 29echo "Version: $__KERNELRELEASE" 30echo "Release: $(cat .version 2>/dev/null || echo 1)" 31echo "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 40echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root" 41echo "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 "" 48echo "%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 "" 60echo "%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 "" 68 69if ! $PREBUILT; then 70echo "%prep" 71echo "%setup -q" 72echo "" 73fi 74 75echo "%build" 76 77if ! $PREBUILT; then 78echo "make clean && make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}" 79echo "" 80fi 81 82echo "%install" 83echo 'KBUILD_IMAGE=$(make image_name)' 84echo "%ifarch ia64" 85echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' 86echo "%else" 87echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules' 88echo "%endif" 89 90echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install' 91echo "%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" 95echo "%ifarch ppc64" 96echo "cp vmlinux arch/powerpc/boot" 97echo "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" 98echo "%else" 99echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" 100echo "%endif" 101echo "%endif" 102 103echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install' 104echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" 105 106echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" 107 108echo "%ifnarch ppc64" 109echo 'bzip2 -9 --keep vmlinux' 110echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" 111echo "%endif" 112 113if ! $PREBUILT; then 114echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build" 115echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source" 116echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" 117echo "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude .config.old --exclude .missing-syscalls.d\"" 118echo "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" 122fi 123 124echo "" 125echo "%clean" 126echo 'rm -rf $RPM_BUILD_ROOT' 127echo "" 128echo "%post" 129echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then" 130echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm" 131echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm" 132echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE" 133echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" 134echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" 135echo "fi" 136echo "" 137echo "%preun" 138echo "if [ -x /sbin/new-kernel-pkg ]; then" 139echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img" 140echo "fi" 141echo "" 142echo "%postun" 143echo "if [ -x /sbin/update-bootloader ]; then" 144echo "/sbin/update-bootloader --remove $KERNELRELEASE" 145echo "fi" 146echo "" 147echo "%files" 148echo '%defattr (-, root, root)' 149echo "/lib/modules/$KERNELRELEASE" 150echo "%exclude /lib/modules/$KERNELRELEASE/build" 151echo "%exclude /lib/modules/$KERNELRELEASE/source" 152echo "/boot/*" 153echo "" 154echo "%files headers" 155echo '%defattr (-, root, root)' 156echo "/usr/include" 157echo "" 158if ! $PREBUILT; then 159echo "%files devel" 160echo '%defattr (-, root, root)' 161echo "/usr/src/kernels/$KERNELRELEASE" 162echo "/lib/modules/$KERNELRELEASE/build" 163echo "/lib/modules/$KERNELRELEASE/source" 164echo "" 165fi 166