# vim: set syn=sh: #Maintainer: Dimitris Tzemos # Use fake-uname to match the kernel version you want to compile # based on script for livekernel of JRD KVER=$(uname -r) pkgname=kernel pkgver=$(echo $KVER|tr - .) pkgrel=1dj #arch=noarch source=(modules.conf config-$KVER) docs=("copying") slackdesc=\ ( #|-----handy-ruler------------------------------------------------------| "$pkgname (Linux kernel for Salix)" "" "This is the same kernel config as kernel-huge" ) build() { export KVEREXTRA=$(uname -r) export KVER=$(echo $KVEREXTRA|sed 's/\(.*\)-.*/\1/') export SRC=$startdir/src export DEST=$startdir/pkg export nbthreads=$(cat /proc/cpuinfo | grep ^processor | wc -l) # clone the kernel echo '########################################' echo "Cloning /usr/src/linux-$KVER..." echo '########################################' rsync --inplace --progress -a /usr/src/linux-$KVER/ $SRC/linuxsrc/ || exit 1 ( ARCH_BAK=$ARCH unset ARCH cd $SRC/linuxsrc # clean the kernel make mrproper || exit 1 # use a suitable configuration for new kernel. cp $SRC/config-$KVEREXTRA .config make oldconfig scripts prepare || exit 1 echo "about to compile..." echo "Press any key to continue..." read R echo '########################################' echo "Compiling modules..." echo '########################################' make -j $nbthreads modules || exit 1 echo '########################################' echo "Compiling kernel image..." echo '########################################' make -j $nbthreads bzImage || exit 1 export INSTALL_MOD_PATH=$DEST echo '########################################' echo "Installing modules..." echo '########################################' make modules_install || exit 1 echo '########################################' echo "Installing firmware..." echo '########################################' make firmware_install || exit 1 unset INSTALL_MOD_PATH ARCH=$ARCH_BAK ) if [ $? -ne 0 ]; then exit 1 fi echo '########################################' echo "copy the kernel..." echo '########################################' # copy the kernel cd $DEST mkdir -p boot ( cd boot cp $SRC/linuxsrc/.config config-$KVEREXTRA cp $SRC/linuxsrc/System.map System.map-$KVEREXTRA cp $SRC/linuxsrc/arch/x86/boot/bzImage vmlinuz-$KVEREXTRA ln -s config-$KVEREXTRA config ln -s System.map-$KVEREXTRA System.map ln -s vmlinuz-$KVEREXTRA vmlinuz ) echo '########################################' echo "create rc.modules..." echo '########################################' # create rc.modules mkdir -p etc/rc.d cat << EOF > etc/rc.d/rc.modules #!/bin/sh # rc.modules $(date) # # This file loads extra drivers into the Linux kernel. # As kmod and udev handle module loading, this file will be mostly # commented out, but is still useful for loading selected modules at boot time. # RELEASE=\$(uname -r) # Update kernel module dependencies: if [ -e "/lib/modules/$RELEASE/modules.dep" ]; then echo "Updating module dependency list for $RELEASE: /sbin/depmod --quick" /sbin/depmod --quick else echo "Creating module dependency list for $RELEASE: /sbin/depmod --all" /sbin/depmod --all fi # Run any rc.modules-$(uname -r) file that exists (this is used # if you have specific modules which should only be loaded for # specific kernel versions): if [ -x "/etc/rc.d/rc.modules-$RELEASE" ]; then /etc/rc.d/rc.modules-$RELEASE fi # Run a local (sysadmin-version) of rc.modules if it exists: if [ -x "/etc/rc.d/rc.modules.local" ]; then /etc/rc.d/rc.modules.local fi EOF sed -e "s@_ROOT_@$DEST@ ; s/_KVER_/${KVEREXTRA}/" $SRC/modules.conf > $DEST/modules.conf export MODULECONF=$DEST/modules.conf /sbin/depmod -a -b $DEST -F $DEST/boot/System.map $KVEREXTRA || exit 1 /bin/chmod 755 etc/rc.d/rc.modules rm -rf $DEST/modules.conf $DEST/persist unset MODULECONF echo '##############################################################################' echo "copy the kernel source outside the SLKBUILD tree to keep it...." echo '##############################################################################' # copy the kernel source outside the SLKBUILD tree to keep it. cp -r $SRC/linuxsrc $startdir/ echo '##############################################################################' echo "copy files necessary for later builds, like nvidia, ati, vbox and vmware...." echo '##############################################################################' # copy files necessary for later builds, like nvidia, ati, vbox and vmware ( cd $SRC/linuxsrc mkdir -p $DEST/usr/src/linux-$KVER/include mkdir -p $DEST/usr/src/linux-$KVER/arch for i in acpi asm-generic config drm generated linux math-emu media net pcmcia scsi sound trace video xen; do cp -rf include/$i $DEST/usr/src/linux-$KVER/include/ done cp -rf arch/x86 $DEST/usr/src/linux-$KVER/arch/ cp -rf scripts Makefile Kbuild Module.symvers .config $DEST/usr/src/linux-$KVER/ # fix permissions on scripts dir chmod 755 -R $DEST/usr/src/linux-$KVER/scripts echo '########################################' echo "copy Kconfig files...." echo '########################################' # copy Kconfig files for i in $(find . -name "Kconfig*"); do mkdir -p $DEST/usr/src/linux-$KVER/$(dirname $i) cp $i $DEST/usr/src/linux-$KVER/$i done echo '###########################################################' echo "delete the kernel binary in the sources...." echo '###########################################################' # delete the kernel binary in the sources rm -f $DEST/usr/src/linux-$KVER/arch/x86/boot/compressed/vmlinux $DEST/usr/src/linux-$KVER/arch/x86/boot/compressed/vmlinux.bin* $DEST/usr/src/linux-$KVER/arch/x86/boot/vmlinux.bin $DEST/usr/src/linux-$KVER/arch/x86/boot/bzImage echo '########################################' echo "delete all .o files...." echo '########################################' # delete all .o files for i in $(find $DEST/usr/src/linux-$KVER -name '*.o'); do rm -f $i done ) echo '###########################################################' echo "fix build and source link in /lib/modules/XXX/...." echo '###########################################################' # fix build and source link in /lib/modules/XXX/ ( cd $DEST/lib/modules/$KVEREXTRA/ rm -f build && ln -s /usr/src/linux-$KVER build rm -f source && ln -s /usr/src/linux-$KVER source ) }