# vim: set syn=sh: #Maintainer: JRD # Use fake-uname to match the kernel version you want to compile KVER=$(uname -r) pkgname=kernelive pkgver=$(echo $KVER|tr - .) pkgrel=1cp #arch=noarch source=(config-$KVER.live config-$KVER.live.patch aufs2-standalone-$(echo $KVER|sed 's/\([^.]*\.[^.]*\.[^.]*\)\..*/\1/').tar.gz modules.conf 01-Squashfs-Move_zlib_decompression_wrapper_code_into_a_separate_file.patch 02-Squashfs-Factor_out_remaining_zlib_dependencies_into_separate_wrapper_file.patch 03-Squashfs-Add_a_decompressor_framework.patch 04-Squashfs-Add_decompressor_entries_for_lzma_and_lzo.patch 05-Squashfs-Add_support_for_LZMA_compressed_filesystems.patch 06-lzma-Make_lzma_available_to_non_initramfs_initrd_code.patch 07-Squashfs-Select_DECOMPRESS_LZMA_NEEDED_when_including_support_for_lzma.patch 08-lzma-Make_lzma_reentrant.patch) sourcetemplate=http://enialis.net/~jrd/salix/$pkgname/$pkgver-\$arch-$pkgrel/ docs=("INFOS" "readme" "copying") slackdesc=\ ( #|-----handy-ruler------------------------------------------------------| "$pkgname (Linux kernel for Salix Live)" "Linux kernel for Salix Live is compiled with support for" "squashfs, lzma & aufs2 as well as for most hardware, " "including SCSI, USB booting devices, etc.. " "" "This is the same kernel config as kernel-huge but with aufs2 FS and" "squashfs+lzma FS patches." ) 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 '########################################' cp -a /usr/src/linux-$KVER $SRC/linuxsrc || exit 1 ( ARCH_BAK=$ARCH [ "$ARCH" = "i486" ] && ARCH=x86 cd $SRC/linuxsrc # clean the kernel make mrproper || exit 1 # patch the kernel to use a new FS : aufs (an unionfs like filesystem) echo '* Applying aufs2-kbuild.patch... *' patch -p1 < $SRC/aufs2-standalone/aufs2-kbuild.patch || exit 1 echo '* Applying aufs2-base.patch... *' patch -p1 < $SRC/aufs2-standalone/aufs2-base.patch || exit 1 cp -r $SRC/aufs2-standalone/{Documentation,fs,include} . || exit 1 # patch the squashfs to use a decompressor wrapper and in particular lzma. # patch for lzma to be used outside initrd/initramfs. echo '* Applying squashfs-lzam patches... *' patch -p1 < $SRC/01-Squashfs-Move_zlib_decompression_wrapper_code_into_a_separate_file.patch || exit 1 patch -p1 < $SRC/02-Squashfs-Factor_out_remaining_zlib_dependencies_into_separate_wrapper_file.patch || exit 1 patch -p1 < $SRC/03-Squashfs-Add_a_decompressor_framework.patch || exit 1 patch -p1 < $SRC/04-Squashfs-Add_decompressor_entries_for_lzma_and_lzo.patch || exit 1 patch -p1 < $SRC/05-Squashfs-Add_support_for_LZMA_compressed_filesystems.patch || exit 1 patch -p1 < $SRC/06-lzma-Make_lzma_available_to_non_initramfs_initrd_code.patch || exit 1 patch -p1 < $SRC/07-Squashfs-Select_DECOMPRESS_LZMA_NEEDED_when_including_support_for_lzma.patch || exit 1 patch -p1 < $SRC/08-lzma-Make_lzma_reentrant.patch || exit 1 # use a suitable configuration for live environnement. cp $SRC/config-$KVEREXTRA.live .config make oldconfig scripts prepare || exit 1 # compile the kernel (without squashfs for now) 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 unset INSTALL_MOD_PATH ARCH=$ARCH_BAK ) # 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 ) # 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) echo "Updating module dependencies for Linux \$RELEASE" /sbin/depmod -A EOF sed -e "s@_ROOT_@$DEST@ ; s/_KVER_/${KVEREXTRA}/" $SRC/modules.conf > $DEST/modules.conf export MODULECONF=$DEST/modules.conf depmod -a -b $DEST -F $DEST/boot/System.map $KVEREXTRA || exit 1 modprobe -l | sed -e "s/^.*\/\(.*\)\.ko$/# \/sbin\/modprobe \1/m ; s/# \(.* ac$\)/\1/ ; s/# \(.* battery$\)/\1/ ; s/# \(.* button$\)/\1/ ; s/# \(.* fan$\)/\1/ ; s/# \(.* fuse$\)/\1/ ; s/# \(.* processor$\)/\1/ ; s/# \(.* thermal$\)/\1/ ; s/# \(.* video$\)/\1/ ; s/# \(.* lp$\)/\1/ ; s/# \(.* parport$\)/\1/ ; s/# \(.* parport_pc$\)/\1/ " | sort >> etc/rc.d/rc.modules chmod 755 etc/rc.d/rc.modules rm -rf $DEST/modules.conf $DEST/persist unset MODULECONF # copy the kernel source outside the SLKBUILD tree to keep it. cp -r $SRC/linuxsrc $startdir/ # copy files necessary for later builds, like nvidia 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; 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 # add media/video headers mkdir -p $DEST/usr/src/linux-$KVER/drivers/media/video for i in $(find drivers/media/video -name "*.h"); do mkdir -p $DEST/usr/src/linux-$KVER/$(dirname $i) cp $i $DEST/usr/src/linux-$KVER/$i done # add md headers mkdir -p $DEST/usr/src/linux-$KVER/drivers/md cp drivers/md/*.h $DEST/usr/src/linux-$KVER/drivers/md # add wireless headers mkdir -p $DEST/usr/src/linux-$KVER/net/mac80211/ cp net/mac80211/*.h $DEST/usr/src/linux-$KVER/net/mac80211/ # add CLUSTERIP file for iptables mkdir -p $DEST/usr/src/linux-$KVER/net/ipv4/netfilter/ cp net/ipv4/netfilter/ipt_CLUSTERIP.c $DEST/usr/src/linux-$KVER/net/ipv4/netfilter/ # 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 # 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 # delete all .o files for i in $(find $DEST/usr/src/linux-$KVER -name '*.o'); do rm -f $i done ) # 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 ) }