Summary: The Linux kernel (the core of the Linux operating system) # We do not want -debuginfo package %define debug_package %{nil} # normal/debug/debuginfo %define buildnormal 1 %define builddebug 1 %define builddebuginfo 0 # kernels we want to build %define buildup 1 %define buildpae 1 # versions %define kversion 2.6.20 %define krelease ovz007 %define ksubrelease 1 %define rpmversion %{kversion} %define release %{krelease}.%{ksubrelease} %define make_target bzImage %define kernel_image x86 %define KVERREL %{PACKAGE_VERSION}-%{PACKAGE_RELEASE} # groups of related archs %define all_x86 i586 i686 # Override generic defaults with per-arch defaults # Second, per-architecture exclusions (ifarch) %ifarch %{all_x86} %define all_arch_configs $RPM_SOURCE_DIR/kernel-%{kversion}-i?86*.config.ovz %define image_install_path boot %endif %ifarch x86_64 %define all_arch_configs $RPM_SOURCE_DIR/kernel-%{kversion}-x86_64*.config.ovz %define buildpae 0 %define image_install_path boot %endif %ifarch ia64 %define all_arch_configs $RPM_SOURCE_DIR/kernel-%{kversion}-ia64.config.ovz %define buildpae 0 %define builddebug 0 %define image_install_path boot/efi/EFI/redhat %define make_target compressed %define kernel_image vmlinux.gz %endif %ifarch ppc64 %define all_arch_configs $RPM_SOURCE_DIR/kernel-%{kversion}-ppc64.config.ovz %define buildpae 0 %define image_install_path boot %define make_target vmlinux %define kernel_image vmlinux %endif %define _unpackaged_files_terminate_build 0 # # Three sets of minimum package version requirements in the form of Conflicts: # to versions below the minimum # # # First the general kernel 2.6 required versions as per # Documentation/Changes # %define kernel_dot_org_conflicts ppp <= 2.3.15, pcmcia-cs <= 3.1.20, isdn4k-utils <= 3.0, mount < 2.10r-5, nfs-utils < 1.0.3, e2fsprogs < 1.29, util-linux < 2.10, jfsutils < 1.0.14, reiserfsprogs < 3.6.3, xfsprogs < 2.1.0, procps < 2.0.9, oprofile < 0.5.3 # # Then a series of requirements that are distribution specific, either # because we add patches for something, or the older versions have # problems with the newer kernel or lack certain things that make # integration in the distro harder than needed. # %define package_conflicts cipe < 1.4.5, tux < 2.1.0, kudzu <= 0.92, initscripts < 7.23, dev < 3.2-7, iptables < 1.2.5-3, bcm5820 < 1.81, nvidia-rh72 <= 1.0 # # Several packages had bugs in them that became obvious when the NPTL # threading code got integrated. # %define nptl_conflicts SysVinit < 2.84-13, pam < 0.75-48, vixie-cron < 3.0.1-73, privoxy < 3.0.0-8, spamassassin < 2.44-4.8.x, cups < 1.1.17-13 # # Packages that need to be installed before the kernel is, because the %post # scripts use them. # %define kernel_prereq fileutils, module-init-tools, initscripts >= 5.83, mkinitrd >= 3.5.5 Name: kernel Group: System Environment/Kernel License: GPLv2 Version: %{rpmversion} Release: %{release} ExclusiveArch: noarch %{all_x86} x86_64 ia64 ppc64 ExclusiveOS: Linux Provides: kernel = %{version} Provides: kernel-drm = 4.3.0 Provides: vzkernel = %{KVERREL} Provides: vzquotamod Prereq: %{kernel_prereq} Conflicts: %{kernel_dot_org_conflicts} Conflicts: %{package_conflicts} Conflicts: %{nptl_conflicts} # We can't let RPM do the dependencies automatic because it'll then pick up # a correct but undesirable perl dependency from the module headers which # isn't required for the kernel proper to function AutoReqProv: no # # List the packages used during the kernel build # BuildPreReq: module-init-tools, patch >= 2.5.4, bash >= 2.03, sh-utils, tar BuildPreReq: bzip2, findutils, gzip, m4, perl, make >= 3.78, gnupg BuildRequires: gcc >= 2.96-98, binutils >= 2.12 BuildConflicts: rhbuildsys(DiskFree) < 500Mb Source0: ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-%{kversion}.tar.bz2 Source20: kernel-%{kversion}-i686.config.ovz Source22: kernel-%{kversion}-i686-PAE.config.ovz Source23: kernel-%{kversion}-x86_64.config.ovz Source25: kernel-%{kversion}-ia64.config.ovz Source26: kernel-%{kversion}-ppc64.config.ovz Source1000: make_debug_config %if %{!?_without_source:0}%{?_without_source:1} NoSource: 0 %endif # ---------------------------------------------------------------------------- # List of patches # ---------------------------------------------------------------------------- Patch1: linux-2.6.0-nonintconfig.patch Patch100: patch-%{krelease} #---1000------ IA64 -------------------------- #---2000------ x86_64 ------------------------ #---5000------ driver patches ---------------- Patch2101: linux-2.6.8.1-drbd-0.7.19.patch Patch2102: linux-2.6.8.1-drbd-0.7.19-0.7.20.patch Patch2103: linux-2.6.9-drbd-0.7.20-0.7.22.patch Patch2104: linux-2.6.18-drbd-0.7.22-0.8.0.patch # ---------------------------------------------------------------------------- BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root %description This package contains the OpenVZ kernel. This is the Linux kernel with added virtualization functionality. %package debug Summary: The Linux kernel compiled with debug parameters Group: System Environment/Kernel Provides: kernel = %{version} Provides: kernel-drm = 4.3.0 Provides: vzkernel = %{KVERREL} Provides: vzquotamod Prereq: %{kernel_prereq} Conflicts: %{kernel_dot_org_conflicts} Conflicts: %{package_conflicts} Conflicts: %{nptl_conflicts} AutoReqProv: no %description debug Debug kernel %package PAE Summary: The Linux kernel compiled for SMP hugemem machines without 4GB split. Group: System Environment/Kernel Provides: kernel = %{version} Provides: kernel-drm = 4.3.0 Provides: vzkernel = %{KVERREL} Provides: vzquotamod Prereq: %{kernel_prereq} Conflicts: %{kernel_dot_org_conflicts} Conflicts: %{package_conflicts} Conflicts: %{nptl_conflicts} AutoReqProv: no %description PAE This package includes a SMP hugemem version of the OpenVZ kernel without 4GB split. %package PAE-debug Summary: The Linux kernel compiled with debug parameters Group: System Environment/Kernel Provides: kernel = %{version} Provides: kernel-drm = 4.3.0 Provides: vzkernel = %{KVERREL} Provides: vzquotamod Prereq: %{kernel_prereq} Conflicts: %{kernel_dot_org_conflicts} Conflicts: %{package_conflicts} Conflicts: %{nptl_conflicts} AutoReqProv: no %description PAE-debug Debug kernel # ---------------------------------------------------------------------------- # prepare # ---------------------------------------------------------------------------- %prep %setup -q -n %{name}-%{version} -c cd linux-%{kversion} # ---------------------------------------------------------------------------- # applying patches # ---------------------------------------------------------------------------- %patch1 -p1 %patch100 -p1 %patch2101 -p1 %patch2102 -p1 %patch2103 -p1 %patch2104 -p1 # ---------------------------------------------------------------------------- mkdir configs cp -fv %{all_arch_configs} . # now run oldconfig over all the config files for i in *.config* do mv $i .config arch=`echo $i | cut -d"-" -f3 | cut -d"." -f1 | sed -e s/i.86/i386/ \ -e s/s390x/s390/ -e s/ppc.*/powerpc/` make ARCH=$arch nonint_oldconfig > /dev/null cp .config configs/$i done # get rid of unwanted files resulting from patch fuzz find . -name "*.orig" -exec rm -fv {} \; find . -name "*~" -exec rm -fv {} \; # ---------------------------------------------------------------------------- # build # ---------------------------------------------------------------------------- %build cd linux-%{kversion} MakeDebugInfoConfig() { sed -i -e "s/.*\(CONFIG_DEBUG_INFO\).*/\1=y/" .config } BuildKernel() { MakeTarget=$1 KernelImage=$2 Flavour=$3 Debug=$4 SUFF="" FULLSUFF="" [ -z "$Flavour" ] || SUFF="-${Flavour}" FULLSUFF=$SUFF [ -z "$Debug" ] || FULLSUFF="${FULLSUFF}-${Debug}" # Pick the right config file for the kernel we're building Config=kernel-%{kversion}-%{_target_cpu}${SUFF}.config.ovz KernelVer=%{version}-%{release}${FULLSUFF} perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -%{release}${FULLSUFF}/" Makefile echo BUILDING A KERNEL FOR $Flavour $Debug %{_target_cpu}... # and now to start the build process make -s mrproper cp configs/$Config .config arch=`echo $Config | cut -d"-" -f3 | cut -d"." -f1 | sed -e s/i.86/i386/ \ -e s/s390x/s390/ -e s/ppc.*/powerpc/` [ -n "$Debug" ] && $RPM_SOURCE_DIR/make_debug_config %if %{builddebuginfo} MakeDebugInfoConfig %endif make ARCH=${arch} -s nonint_oldconfig > /dev/null make -s include/linux/version.h make ARCH=${arch} -s %{?_smp_mflags} $MakeTarget make ARCH=${arch} -s %{?_smp_mflags} modules || exit 1 # Start installing the results if [ "$KernelImage" = "x86" ]; then KernelImage=arch/$arch/boot/bzImage fi mkdir -p $RPM_BUILD_ROOT/usr/lib/debug/boot mkdir -p $RPM_BUILD_ROOT/%{image_install_path} install -m 644 System.map $RPM_BUILD_ROOT/usr/lib/debug/boot/System.map-$KernelVer install -m 644 System.map $RPM_BUILD_ROOT/boot/System.map-$KernelVer cp $KernelImage $RPM_BUILD_ROOT/%{image_install_path}/vmlinuz-$KernelVer # We do not want vmlinux for ppc64, since it is the same file as vmlinuz above %ifnarch ppc64 cp vmlinux $RPM_BUILD_ROOT/%{image_install_path}/vmlinux-$KernelVer %endif mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer make -s INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=$KernelVer # And save the headers/makefiles etc for building modules against # # This all looks scary, but the end result is supposed to be: # * all arch relevant include/ files # * all Makefile/Kconfig files # * all script/ files rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/source mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build (cd $RPM_BUILD_ROOT/lib/modules/$KernelVer ; ln -s build source) # first copy everything cp --parents `find -type f -name "Makefile*" -o -name "Kconfig*"` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build cp Module.symvers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build # then drop all but the needed Makefiles/Kconfig files rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Documentation rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include cp arch/%{_arch}/kernel/asm-offsets.s $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch}/kernel || : cp .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build cp -a scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build cp -a arch/%{_arch}/scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch} || : cp -a arch/%{_arch}/*lds $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch}/ || : rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*.o rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*/*.o mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include cd include cp -a acpi config linux math-emu media net pcmcia rxrpc scsi sound video asm asm-generic bc $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include # Make sure the Makefile and version.h have a matching timestamp so that # external modules can be built touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Makefile $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/linux/version.h touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/.config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/linux/autoconf.h cd .. # # save the vmlinux file for kernel debugging into the kernel-debuginfo rpm # mkdir -p $RPM_BUILD_ROOT/usr/lib/debug/lib/modules/$KernelVer cp vmlinux $RPM_BUILD_ROOT/usr/lib/debug/lib/modules/$KernelVer # mark modules executable so that strip-to-file can strip them find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name "*.ko" -type f | xargs chmod u+x # cp -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/kernel $RPM_BUILD_ROOT/usr/lib/debug/lib/modules/$KernelVer # detect missing or incorrect license tags for i in `find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name "*.ko" ` ; do echo -n "$i " ; /sbin/modinfo -l $i >> modinfo ; done cat modinfo | grep -v "^GPL" | grep -v "^Dual BSD/GPL" | grep -v "^Dual MPL/GPL" | grep -v "^GPL and additional rights" | grep -v "^GPL v2" && exit 1 rm -f modinfo # remove files that will be auto generated by depmod at rpm -i time rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/modules.* } XBuildKernel() { # build normal kernel %if %{buildnormal} BuildKernel $1 $2 $3 %endif %if %{builddebug} BuildKernel "$1" "$2" "$3" "debug" %endif } ### # DO it... ### # prepare directories rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/boot %if %{buildup} XBuildKernel %make_target %kernel_image %endif %if %{buildpae} XBuildKernel %make_target %kernel_image PAE %endif ### ### install ### %install cd linux-%{kversion} # architectures that don't get kernel-source (i586/i686/athlon) dont need # much of an install because the build phase already copied the needed files ### ### clean ### %clean rm -rf $RPM_BUILD_ROOT ### ### scripts ### # load the loop module 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 %pre debug /sbin/modprobe loop 2> /dev/null > /dev/null || : exit 0 %pre PAE /sbin/modprobe loop 2> /dev/null > /dev/null || : exit 0 %pre PAE-debug /sbin/modprobe loop 2> /dev/null > /dev/null || : exit 0 %post [ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL} %post debug [ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}-debug %post PAE [ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}-PAE %post PAE-debug [ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --mkinitrd --depmod --install %{KVERREL}-PAE-debug %preun /sbin/modprobe loop 2> /dev/null > /dev/null || : [ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL} %preun debug /sbin/modprobe loop 2> /dev/null > /dev/null || : [ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}-debug %preun PAE /sbin/modprobe loop 2> /dev/null > /dev/null || : [ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}-PAE %preun PAE-debug /sbin/modprobe loop 2> /dev/null > /dev/null || : [ -x /sbin/new-kernel-pkg ] && /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}-PAE-debug ### ### file lists ### %if %{buildup} && %{buildnormal} %files %defattr(-,root,root) /%{image_install_path}/vmlinuz-%{KVERREL} %ifnarch ppc64 /%{image_install_path}/vmlinux-%{KVERREL} %endif /boot/System.map-%{KVERREL} %dir /lib/modules/%{KVERREL} /lib/modules/%{KVERREL}/kernel %verify(not mtime) /lib/modules/%{KVERREL}/build %endif %if %{buildup} && %{builddebug} %files debug %defattr(-,root,root) /%{image_install_path}/vmlinuz-%{KVERREL}-debug %ifnarch ppc64 /%{image_install_path}/vmlinux-%{KVERREL}-debug %endif /boot/System.map-%{KVERREL}-debug %dir /lib/modules/%{KVERREL}-debug /lib/modules/%{KVERREL}-debug/kernel %verify(not mtime) /lib/modules/%{KVERREL}-debug/build %endif ### --------------- PAE --------------------- %if %{buildpae} && %{buildnormal} %files PAE %defattr(-,root,root) /%{image_install_path}/vmlinuz-%{KVERREL}-PAE /%{image_install_path}/vmlinux-%{KVERREL}-PAE /boot/System.map-%{KVERREL}-PAE %dir /lib/modules/%{KVERREL}-PAE /lib/modules/%{KVERREL}-PAE/kernel %verify(not mtime) /lib/modules/%{KVERREL}-PAE/build %endif %if %{buildpae} && %{builddebug} %files PAE-debug %defattr(-,root,root) /%{image_install_path}/vmlinuz-%{KVERREL}-PAE-debug /%{image_install_path}/vmlinux-%{KVERREL}-PAE-debug /boot/System.map-%{KVERREL}-PAE-debug %dir /lib/modules/%{KVERREL}-PAE-debug /lib/modules/%{KVERREL}-PAE-debug/kernel %verify(not mtime) /lib/modules/%{KVERREL}-PAE-debug/build %endif