cat /var/tmp/rpm-tmp.82283 #!/bin/sh RPM_SOURCE_DIR="/usr/src/redhat/SOURCES" RPM_BUILD_DIR="/usr/src/redhat/BUILD" RPM_OPT_FLAGS="-O2 -g -march=i686" RPM_ARCH="i386" RPM_OS="linux" export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_DOC_DIR="/usr/share/doc" export RPM_DOC_DIR RPM_PACKAGE_NAME="ovzkernel" RPM_PACKAGE_VERSION="2.6.16" RPM_PACKAGE_RELEASE="026test009.1.20060424" export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE RPM_BUILD_ROOT="/var/tmp/kernel-2.6.16-026test009.1.20060424-root" export RPM_BUILD_ROOT set -x umask 022 cd /usr/src/redhat/BUILD cd ovzkernel-2.6.16 cd linux-2.6.16 MakeDebugInfoConfig() { sed -e "s/.*\(CONFIG_DEBUG_INFO\).*/\1=y/" .config > .config.xxx mv -f .config.xxx .config } MakeDebugConfig() { sed \ -e "s/.*\(CONFIG_DEBUG_KERNEL\>\).*/\1=y/" \ -e "s/.*\(CONFIG_DEBUG_STACKOVERFLOW\>\).*/\1=y/" \ -e "s/.*\(CONFIG_DEBUG_SLAB\>\).*/\1=y/" \ -e "s/.*\(CONFIG_MAGIC_SYSRQ\>\).*/\1=y/" \ -e "s/.*\(CONFIG_DEBUG_SPINLOCK\>\).*/\1=y/" \ -e "s/.*\(CONFIG_DEBUG_PAGEALLOC\>\).*/\1=y/" \ -e "s/.*\(CONFIG_DEBUG_SPINLOCK_SLEEP\>\).*/\1=y/" \ -e "s/.*\(CONFIG_FRAME_POINTER\>\).*/\1=y/" \ .config > .config.xxx mv -f .config.xxx .config } BuildKernel() { VER=$1 DBG=$2 [ -z "$VER" ] && SUFF="" || SUFF=-$VER if [ -z "$VER" ]; then VER=$DBG; else [ -n "$DBG" ] && VER=$VER-$DBG fi [ -z "$VER" ] && FULLSUFF="" || FULLSUFF=-$VER # Pick the right config file for the kernel we're building Config=kernel-2.6.16-026test009-i686${SUFF}.config.ovz KernelVer=2.6.16-026test009.1.20060424${FULLSUFF} perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = -026test009.1.20060424${FULLSUFF}/" Makefile echo BUILDING A KERNEL FOR $VER i686... # and now to start the build process make -s mrproper cp configs/$Config .config arch=`echo $Config | cut -d"-" -f4 | cut -d"." -f1 | sed -e s/i.86/i386/ \ -e s/s390x/s390/ -e s/ppc64.series/ppc64/ -e s/ppc8.../ppc/ -e s/ppc32dy4/ppc/ ` [ "$DBG" == "debug" ] && MakeDebugConfig make ARCH=${arch} -s nonint_oldconfig > /dev/null make -s include/linux/version.h make ARCH=${arch} -s bzImage make ARCH=${arch} -s modules || exit 1 make ARCH=${arch} buildcheck # Start installing the results mkdir -p $RPM_BUILD_ROOT/usr/lib/debug/boot mkdir -p $RPM_BUILD_ROOT/boot 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 arch/*/boot/bzImage $RPM_BUILD_ROOT/boot/vmlinuz-$KernelVer cp vmlinux $RPM_BUILD_ROOT/boot/vmlinux-$KernelVer 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/i386/kernel/asm-offsets.s $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/i386/kernel || : cp .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build cp -a scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build cp -a arch/i386/scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/i386 || : cp -a arch/i386/*lds $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/i386/ || : 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 ub $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 BuildKernel $1 } ### # DO it... ### # prepare directories rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/boot XBuildKernel XBuildKernel smp XBuildKernel enterprise ### ### install ### exit 0