#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=i486 source=(config-$KVER.live config-$KVER.live.patch aufs2-standalone.tar.gz squashfs3.4.tgz lzma457.tgz sqlzma2k-3.4.patch sqlzma.h sqmagic.h modules.conf Makefile) sourcetemplate=http://enialis.net/~jrd/salix/$pkgname/$pkgver-$pkgrel/ docs=("readme" "copying" "sqlzma.txt") slackdesc=\ ( #|-----handy-ruler------------------------------------------------------| "$pkgname (Linux kernel for Salix Live)" "Linux kernel for Salix Live is compiled with support for" "squashfs, lzma & aufs as well as for most hardware, " "including SCSI, USB booting devices, etc.. " "" "Drivers (such as for CD-ROM drives on proprietary interfaces," "or ethernet cards) may be loaded as modules." "See /etc/rc.d/rc.modules for examples" ) build() { export KVEREXTRA=$(uname -r) export KVER=$(echo $KVEREXTRA|sed 's/\(.*\)-.*/\1/') export SRC=$startdir/src export DEST=$startdir/pkg # clone the kernel echo '########################################' echo "Cloning /usr/src/linux-$KVER..." echo '########################################' cp -a /usr/src/linux-$KVER $SRC/linuxsrc || exit 1 cd $SRC/linuxsrc # clean the kernel make mrproper || exit 1 echo '* Applying aufs2-standalone.patch... *' # patch the kernel to use a new FS : aufs (an unionfs like filesystem) patch -p1 < $SRC/aufs2-standalone/aufs2-standalone.patch || exit 1 if [ -e $SRC/aufs2-standalone/aufs2-base.patch ]; then echo '* Applying aufs2-base.patch... *' patch -p1 < $SRC/aufs2-standalone/aufs2-base.patch || exit 1 fi # patch the kernel to use a specific squashfs FS : this one could use a compression algorithm # We must first remove the squashfs 4.0 code without LZMA and then use the squashfs 3.4 which # has patches for LZMA sed 's/4\.0/3.4/' fs/squashfs/Kconfig > squashfs-Kconfig rm -r fs/squashfs/* mv squashfs-Kconfig fs/squashfs/Kconfig echo '* Applying squashfs3.4-patch... *' patch -p1 < $SRC/squashfs3.4/kernel-patches/linux-2.6.30/squashfs3.4-patch || exit 1 echo '* Applying sqlzma2k-3.4.patch...*' # patch for squashfs 3.4 patch -p1 < $SRC/sqlzma2k-3.4.patch || exit 1 cp $SRC/sqlzma.h $SRC/sqmagic.h fs/squashfs/ # squashfs-tools is already patched to be aware of LZMA # LZMA is already patched to build a kernel module # install the AUFS code in the kernel cp -r $SRC/aufs2-standalone/fs/aufs $SRC/linuxsrc/fs/ cp $SRC/aufs2-standalone/include/linux/aufs_type.h $SRC/linuxsrc/include/linux/ echo '* Applying aufs2-kbuild.patch... *' patch -p1 < $SRC/aufs2-standalone/aufs2-kbuild.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 3 modules || exit 1 echo '########################################' echo "Compiling kernel image..." echo '########################################' make -j 3 bzImage || exit 1 export INSTALL_MOD_PATH=$DEST echo '########################################' echo "Installing modules..." echo '########################################' make modules_install || exit 1 # now compile the squashfs+lzma modules cd $SRC echo '########################################' echo "Compiling/installing squashfs + LZMA..." echo '########################################' make || exit 1 unset INSTALL_MOD_PATH # create the good structure for the modules cd $DEST/lib/modules/$KVEREXTRA-live rm -f modules.* mkdir -p kernel/fs/squashfs cp $SRC/lzma457/C/Compress/Lzma/kmod/{sq,un}lzma.ko kernel/fs/squashfs/ cp $SRC/linuxsrc/fs/squashfs/squashfs.ko kernel/fs/squashfs/ # copy the kernel cd $DEST mkdir -p boot cd boot cp $SRC/linuxsrc/.config config-$KVEREXTRA-live cp $SRC/linuxsrc/System.map System.map-$KVEREXTRA-live cp $SRC/linuxsrc/arch/x86/boot/bzImage vmlinuz-$KVEREXTRA-live ln -s config-$KVEREXTRA-live config ln -s System.map-$KVEREXTRA-live System.map ln -s vmlinuz-$KVEREXTRA-live vmlinuz cd .. # 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}-live/" $SRC/modules.conf > $DEST/modules.conf export MODULECONF=$DEST/modules.conf depmod -a -b $DEST -F $DEST/boot/System.map $KVEREXTRA-live || 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 files necessary for later builds, like nvidia and vmware cd $SRC/linuxsrc/include mkdir -p $DEST/usr/src/linux-$KVER/include for i in acpi asm-generic asm-x86 linux math-emu media net pcmcia scsi sound video; do cp -rf $i $DEST/usr/src/linux-$KVER/include/ done ( cd $DEST/usr/src/linux-$KVER/include; ln -sf asm-x86 asm ) ( cd $DEST/usr/src/linux-$KVER/include/linux; ln -sf autoconf.h config.h ) cd $SRC/linuxsrc cp .config $DEST/usr/src/linux-$KVER cp Makefile ${dest}/usr/src/linux-$KVER cp Module.symvers $DEST/usr/src/linux-$KVER cp -a scripts $DEST/usr/src/linux-$KVER # fix permissions on scripts dir chmod 755 -R $DEST/usr/src/linux-$KVER/scripts mkdir -p $DEST/usr/src/linux-$KVER/.tmp_versions mkdir -p $DEST/usr/src/linux-$KVER/arch/x86/kernel cp arch/x86/Makefile* $DEST/usr/src/linux-$KVER/arch/x86/ cp arch/x86/kernel/asm-offsets.s $DEST/usr/src/linux-$KVER/arch/x86/kernel/ # add headers for lirc package mkdir -p $DEST/usr/src/linux-$KVER/drivers/media/video cp drivers/media/video/*.h $DEST/usr/src/linux-$KVER/drivers/media/video/ for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo zc0301; do mkdir -p $DEST/usr/src/linux-$KVER/drivers/media/video/$i cp -a drivers/media/video/$i/*.h $DEST/usr/src/linux-$KVER/drivers/media/video/$i done # add dm headers mkdir -p $DEST/usr/src/linux-$KVER/drivers/md cp drivers/md/*.h $DEST/usr/src/linux-$KVER/drivers/md # add inotify.h mkdir -p $DEST/usr/src/linux-$KVER/include/linux cp include/linux/inotify.h $DEST/usr/src/linux-$KVER/include/linux/ # 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/ # add xfs and shmem for aufs building mkdir -p $DEST/usr/src/linux-$KVER/fs/xfs mkdir -p $DEST/usr/src/linux-$KVER/mm cp fs/xfs/xfs_sb.h $DEST/usr/src/linux-$KVER/fs/xfs/xfs_sb.h cp mm/shmem.c $DEST/usr/src/linux-$KVER/mm/shmem.c # add vmlinux cp vmlinux $DEST/usr/src/linux-$KVER # copy in Kconfig files for i in `find . -name "Kconfig*"`; do mkdir -p $DEST/usr/src/linux-$KVER/`echo $i | sed 's|/Kconfig.*||'` cp $i $DEST/usr/src/linux-$KVER/$i done # fix build and source link in /lib/modules/XXX/ cd $DEST/lib/modules/$KVEREXTRA-live/ rm -f build && ln -s /usr/src/linux-$KVER build rm -f source && ln -s /usr/src/linux-$KVER source }