################################################################# # Kernel RPM spec file by Tim Jackson # includes support for RML's preemptive kernel patch # # Based very loosely on the Red Hat kernel spec file; # considerably less generic (but MUCH simpler) # # My understanding of kernel installation is limited; if you spot # anything blatently broken please let me know. # # NOTE: This is slightly naughty in that it builds the kernel in # /usr/src/linux-x.y.z-rel NOT /usr/src/redhat/BUILD although it # moves it back to /usr/src/redhat/BUILD afterwards. This isn't # entirely proper but makes things much simpler and works. # Include kernel preemptive patch? %define preemptivepatch 0 # Versions of various parts %define release 1 %define sublevel 18 %define kversion 2.4.%{sublevel} # first XFree86 ver that requires the drm in this kernel %define drmver 4.1.0 # disable build root strip policy # tim: WTF? %define __spec_install_post /usr/lib/rpm/brp-compress || : %define KVERREL %{PACKAGE_VERSION}-%{PACKAGE_RELEASE} Name: kernel Summary: The Linux kernel (the core of the Linux operating system) Version: %{kversion} Release: %{release} License: GPL Group: System Environment/Kernel ExclusiveOS: Linux Obsoletes: kernel-modules Provides: kernel = %{version}, kernel-drm = %{drmver} Autoreqprov: no Prereq: fileutils, initscripts >= 5.83, mkinitrd >= 3.2.2 Conflicts: ppp <= 2.3.15, e2fsprogs <= 1.18, pcmcia-cs <= 3.1.20, isdn4k-utils <= 3.0, mount < 2.10r-5, nfs-utils < 0.3.1, cipe < 1.4.5, kudzu <= 0.92, e2fsprogs < 1.22 BuildPreReq: modutils >= 2.4.2, bash >= 2.03, sh-utils Source0: ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-%{kversion}.tar.gz Source1: kernel-%{kversion}.config %if %{preemptivepatch} Patch0: http://www.kernel.org/pub/linux/kernel/people/rml/preempt-kernel/v2.4/preempt-kernel-rml-2.4.18-2.patch %endif BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root ###################################################################### # package information %package source Summary: The source code for the Linux kernel. Group: Development/System Prereq: fileutils Requires: gawk Requires: gcc %package headers Summary: Header files for the Linux kernel. Group: Development/System Prereq: fileutils initscripts >= 5.83 Requires: gawk %description The kernel package contains the Linux kernel (vmlinuz), the core of your Red Hat Linux operating system. The kernel handles the basic functions of the operating system: memory allocation, process allocation, device input and output, etc. %description source The kernel-source package contains the source code files for the Linux kernel. These source files are needed to build most C programs, since they depend on the constants defined in the source code. The source files can also be used to build a custom kernel that is better tuned to your particular hardware, if you are so inclined (and you know what you're doing). %description headers Kernel-headers includes the C header files for the Linux kernel. The header files define structures and constants that are needed for building most standard programs and are also needed for rebuilding the kernel. ##################################################################### # prep %prep %setup -q -n %{name}-%{version} -c mv linux linux-%{kversion} %if %{preemptivepatch} %patch0 -p0 %endif # Minor hack: move the source into /usr/src ready for building rm -rf /usr/src/linux-%{KVERREL} mv linux-%{kversion} /usr/src/linux-%{KVERREL} ##################################################################### # build %build cd /usr/src/linux-%{KVERREL} make mrproper cp -fv $RPM_SOURCE_DIR/kernel-%{kversion}.config .config # Add the RPM release number to EXTRAVERSION in Makefile perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}/" Makefile #echo CONFIGURING KERNEL FOR BUILD... make -s oldconfig #echo MAKING DEPENDENCIES... make -s dep #echo BUILDING THE KERNEL IMAGE... make bzImage #echo BUILDING THE KERNEL MODULES... make modules ################################################################## # install %install cd /usr/src/linux-%{KVERREL} rm -rf $RPM_BUILD_ROOT ### install the stuff in /boot mkdir -p $RPM_BUILD_ROOT/boot install -m 644 System.map $RPM_BUILD_ROOT/boot/System.map-%{KVERREL} cp arch/i386/boot/bzImage $RPM_BUILD_ROOT/boot/vmlinuz-%{KVERREL} # create /boot/kernel.h-x.y.z (filled at boot time) touch $RPM_BUILD_ROOT/boot/kernel.h-%{kversion} ### install modules stuff mkdir -p $RPM_BUILD_ROOT/lib/modules/%{KVERREL} make INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=%{KVERREL} # these files seem to be regenerated on bootup rm -f $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/modules.* # don't know why we have to mess around with */build but presumably we need to # (it was in the original Red Hat spec) for i in $RPM_BUILD_ROOT/lib/modules/*; do rm -f $i/build ln -sf ../../../usr/src/linux-%{KVERREL} $i/build done ### install the source # put the current source we've been working on into /usr/src/linux-x.y.z mkdir -p $RPM_BUILD_ROOT/usr/src cp -pr /usr/src/linux-%{KVERREL} $RPM_BUILD_ROOT/usr/src/ ### install include files mkdir -p $RPM_BUILD_ROOT/usr/include/linux cp -a $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/include/linux/* $RPM_BUILD_ROOT/usr/include/linux/ # Stop people using headers from /usr/include/linux/modules* (when compiling modules only??) rm -rf $RPM_BUILD_ROOT/usr/include/linux/modules echo "#error Modules should never use kernel-headers system headers," > $RPM_BUILD_ROOT/usr/include/linux/modversions.h echo "#error but rather headers from an appropriate kernel-source package." >> $RPM_BUILD_ROOT/usr/include/linux/modversions.h echo "#error Change -I/usr/src/linux/include (or similar) to" >> $RPM_BUILD_ROOT/usr/include/linux/modversions.h echo "#error -I/lib/modules/\$(uname -r)/build/include" >> $RPM_BUILD_ROOT/usr/include/linux/modversions.h echo "#error to build against the currently-running kernel." >> $RPM_BUILD_ROOT/usr/include/linux/modversions.h mkdir -p $RPM_BUILD_ROOT/usr/include/asm cp -a $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/include/asm/* $RPM_BUILD_ROOT/usr/include/asm/ # remove /lib/modules/*/modules.* from BuildRoot (not entirely sure why) for i in $RPM_BUILD_ROOT/lib/modules/*; do rm -f $i/modules.* done # move the kernel sources we've been using back out of the way cd /usr/src mv linux-%{KVERREL} /usr/src/redhat/BUILD/kernel-%{kversion}/linux ############################################################################# # clean %clean rm -rf $RPM_BUILD_ROOT ############################################################################# # scripts # do this for upgrades...in case the old modules get removed we have # loopback in the kernel so that mkinitrd will work. %pre /sbin/modprobe loop 2> /dev/null > /dev/null || : exit 0 %post cd /boot ln -sf vmlinuz-%{KVERREL} vmlinuz ln -sf System.map-%{KVERREL} System.map [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade depmod -ae -F /boot/System.map-%{KVERREL} %{KVERREL} [ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth if [ -x /sbin/new-kernel-pkg ] ; then /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL} fi # Allow clean removal of modules directory %preun /sbin/modprobe loop 2> /dev/null > /dev/null || : #rm -f /lib/modules/%{KVERREL}/modules.* if [ -x /sbin/new-kernel-pkg ] ; then /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL} fi %pre headers [ -L /usr/include/linux ] && rm -f /usr/include/linux || : [ -L /usr/include/asm ] && rm -f /usr/include/asm || : exit 0 %post headers cd /boot rm -f kernel.h ln -snf kernel.h-%{kversion} kernel.h [ -x /sbin/mkkerneldoth ] && /sbin/mkkerneldoth exit 0 # We need this here because we don't prereq kudzu; it could be # installed after the kernel %triggerin -- kudzu [ -x /usr/sbin/module_upgrade ] && /usr/sbin/module_upgrade || : # Old kernel-headers packages owned include symlinks; new # ones just make them so that we can have multiple kernel-headers # packages installed. %triggerpostun headers -- kernel-headers < 2.2.16 cd /boot rm -f kernel.h ln -snf kernel.h-%{kversion} kernel.h exit 0 %postun headers if [ $1 = 0 ]; then if [ -L /boot/kernel.h -a `ls -l /boot/kernel.h 2>/dev/null| awk '{ print $11 }'` = "kernel.h-%{kversion}" ]; then rm -f /boot/kernel.h fi fi exit 0 %postun source if [ -L /usr/src/%{kslnk} ]; then if [ -L /usr/src/%{kslnk} -a `ls -l /usr/src/%{kslnk} 2>/dev/null| awk '{ print $11 }'` = "linux-%{KVERREL}" ]; then [ $1 = 0 ] && rm -f /usr/src/%{kslnk} fi fi exit 0 ######################################################################### ### file lists ### %files %defattr(-,root,root) /boot/vmlinuz-%{KVERREL} /boot/System.map-%{KVERREL} /lib/modules/%{KVERREL} %files source %defattr(-,root,root) /usr/src/linux-%{KVERREL} %files headers %defattr(-,root,root) /usr/include/linux /usr/include/asm /boot/kernel.h-%{kversion} %changelog * Tue Feb 19 2002 Tim Jackson - Added option to include RML's kernel preemptive patch * Sun Feb 10 2002 Tim Jackson - First version of TJ's new, simplified spec file