#!/bin/sh # kernel_raspi.SlackBuild # Build the kernel for Raspberry Pi # # Copyright 2012 David Spencer, Baildon, West Yorkshire, U.K. # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #------------------------------------------------------------------------------ # # Before running this SlackBuild you must get a tarball of the kernel # source from the 3.6.y branch of the raspberrypi's repository: a script # is here to help that # # sh get_kernel_source.sh # #------------------------------------------------------------------------------ FLAVOUR=raspi PRGNAM=kernel_$FLAVOUR # If not set in the environment, MYVER will be set from today's date MYVER=${VERSION:-$(date '+%Y%m%d')} BUILD=${BUILD:-1} TAG=${TAG:-_dbs} KNLARCH=${ARCH:-arm} unset ARCH CONFIG=${CONFIG:-config-$FLAVOUR} CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} set -e rm -rf $PKG mkdir -p $PKG GITREV=${GITREV:-$(echo raspberrypi-linux-*.tar.gz | sed -e "s|raspberrypi-linux-||" -e "s|\.tar\.gz||")} rm -fr linux echo "Uncompressing the kernel silently to avoid spamming the console too much." echo "It can take a while..." echo "tar xf $CWD/raspberrypi-linux-$GITREV.tar.gz" tar xf $CWD/raspberrypi-linux-$GITREV.tar.gz mv raspberrypi-linux-$GITREV linux # Uncompress also aufs3 sources tar xf $CWD/aufs3-3.6.tar.gz cd $CWD/linux if [ -d $CWD/patches/ ]; then git checkout -f for pf in $CWD/patches/*; do patch --verbose -p1 <$pf done fi cat $CWD/$CONFIG > .config # Add the bfq patches patch -p1 < $CWD/0001-block-cgroups-kconfig-build-bits-for-BFQ-v6r1-3.6.patch patch -p1 < $CWD/0002-block-introduce-the-BFQ-v6r1-I-O-sched-for-3.6.patch patch -p1 < $CWD/0003-block-bfq-add-Early-Queue-Merge-EQM-to-BFQ-v6r1-for-3.6.0.patch # Add aufs3 stuff cp -a $CWD/aufs3-3.6/Documentation/ABI/testing/* Documentation/ABI/testing/ cp -a $CWD/aufs3-3.6/Documentation/filesystems/aufs Documentation/filesystems/ cp -a $CWD/aufs3-3.6/fs/aufs fs/ cp -a $CWD/aufs3-3.6/include/linux/aufs_type.h include/linux/ patch -p1 < $CWD/aufs3-3.6/aufs3-kbuild.patch patch -p1 < $CWD/aufs3-3.6/aufs3-base.patch patch -p1 < $CWD/aufs3-3.6/aufs3-proc_map.patch make silentoldconfig LOCALVERSION="-$MYVER" head -4 Makefile | sed 's/ *= */=/' > $TMP/versionvars . $TMP/versionvars rm $TMP/versionvars KNLVER="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}-${MYVER}" PKGVER=$(echo "$KNLVER" | tr - _) make zImage $NUMJOBS LOCALVERSION="-$MYVER" mkdir -p $PKG/boot cp arch/arm/boot/zImage $PKG/boot/kernel.img cp System.map $PKG/boot/System.map # Put this in /usr/doc to avoid confusion with Pi-specific /boot/config.txt mkdir -p $PKG/usr/doc/$PRGNAM-$PKGVER cat .config > $PKG/usr/doc/$PRGNAM-$PKGVER/config # Create /boot/cmdline.txt copied from kernel config # Install as .new even though it's not in /etc # Root device will be filled in by doinst.sh grep 'CONFIG_CMDLINE=' .config | \ sed -e 's/CONFIG_CMDLINE="//' -e 's/"$//' -e 's:root=/dev/mmcblk0p[0-7]:root=@ROOTDEV@:' \ > $PKG/boot/cmdline.txt.new mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh # Add version stamp into /boot and /usr/doc echo "Package: $PRGNAM-$PKGVER-$KNLARCH-$BUILD$TAG" \ > $PKG/boot/version-$PRGNAM.txt echo "Build date: $(date -u '+%F %T')" \ >> $PKG/boot/version-$PRGNAM.txt echo "Git revision: $GITREV" \ >> $PKG/boot/version-$PRGNAM.txt cp \ $PKG/boot/version-$PRGNAM.txt \ $PKG/usr/doc/$PRGNAM-$PKGVER/version.txt cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$PKGVER-$KNLARCH-$BUILD$TAG.${PKGTYPE:-tgz} #------------------------------------------------------------------------------ # Prepare and install the modules. The kernel-modules SlackBuild traditionally # just picks them up from the running system. cd $CWD/linux make modules $NUMJOBS LOCALVERSION="-$MYVER" make modules_install # Link the source for the modules & source SlackBuilds rm -rf /usr/src/linux; ln -s $CWD/linux /usr/src/linux ( cd /lib/modules/$KNLVER rm build; ln -s /usr/src/linux build rm source; ln -s /usr/src/linux source ) #------------------------------------------------------------------------------ # Finished. exit 0