#!/bin/bash

####################################################
# Script : kernel-2.6-sourcepackage.SlackBuild
# Purpose: Build a source package of the 2.6 Kernel
# Author : Stuart Winter <mozes@armedslack.org>
# Date...: 27-May-2006
####################################################

source /usr/share/slackdev/buildkit.sh

# Package information:
export PKGNAM=kernel-source
#export VERSION=2.6.24.2
export VERSION=2.6.23.17
export BUILD=2
export PKGSERIES=k
export ARCH=noarch
export SLACKPACKAGE=$PKGNAM-$VERSION-$ARCH-$BUILD.tgz

CWD=$PWD
TMP=/tmp/package-kernel-source
rm -rf $TMP
mkdir -pm755 $TMP/usr/src

# Extract the virgin 2.6 kernel source:
cd $TMP/usr/src
tar xf $CWD/sources/linux-2.6/linux-$VERSION.tar.bz2
ln -vfs linux-$VERSION linux

# Configure the Kernel.  We do this so that we can build stuff like lm_sensors
# on a freshly fully installed ARM versatile system.
# We use the Versatile config file because it has I2C support which lm_sensors
# needs.
rm -f include/linux/autoconf.h
touch include/linux/autoconf.h
#cp -fav armedslack/configs/*versatile* .config
# Eventually this will change -- I've specified a specific versatile config
# since I have two configs - one for the ARMv3 arch and the other for the armv5
# using EABI.
cp -fav armedslack/configs/config-versatile-linux-2.6 .config
make oldconfig
cd linux
make clean
rm -f .version

# We put patches and config files into an 'armedslack' 
# directory.  This way users can have one source package and
# easily find the Kernel config and patches used.
mkdir -vpm755 armedslack
cp -favv $CWD/configs armedslack/
cp -favv $CWD/sources/linux-2.6/patches armedslack/

# Install package description.  This modified from the Slackware version
# because we need to mention the additional 'armedslack' directory.
cd $TMP
mkdir -vm755 install
install -vpm644 $CWD/slack-descs/kernel-source install/slack-desc

start_fakeroot
chown -R root:root .
chmod -R og-w .
slackmp # run makepkg
