vabs / var / vabs / kernel-3.9 / src / kernel-3.9.SlackBuild

#!/bin/bash

# ----------------------
VER=3.9.1
KERNEL=linux-$VER
SQUASHFS_LATEST_KERNEL_PATCH=linux-2.6.24
SQUASHFS=squashfs4.2
LZMA=lzma457
AUFS=aufs
BUILDNUM=${BUILDNUM:-"1"}
VL_VERSION=${VL_VERSION:-"$(ls /var/log/packages/|grep vlconfig2|cut -d "-" -f4|cut -c 2-5)"}
BUILD=${BUILD:-"$BUILDNUM""$VL_VERSION"}
ARCH=$(uname -m)
LINK=${LINK:-"http://www.kernel.org/pub/linux/kernel/v3.0/$KERNEL.tar.xz http://downloads.sourceforge.net/project/squashfs/squashfs/$SQUASHFS/$SQUASHFS.tar.gz"} #Enter URL for package here!
MAKEDEPENDS="bc"
# ----------------------

if [ "$NORUN" != 1 ]; then

eecho()
{
   echo "-------------------------------------"
   echo " * " "$@"
   echo "-------------------------------------"
}

#set -e
CURDIR=$(pwd)
TMP="/usr/src/"
cd ../
PKG=$(pwd)
cd $CURDIR
#GET THE SOURCE
#--------------------------------------------
for SRC in $(echo $LINK);do
  if [ ! -f $(basename $SRC) ];then
    wget --no-check-certificate -c $SRC
  fi
done
#--------------------------------------------
rm -rf $TMP/Makefile* $TMP/$AUFS $TMP/$LZMA $TMP/$SQUASHFS $TMP/$KERNEL
mkdir -p $TMP
rm -Rf $PKG/{kernel,modules,pkgsrc}
mkdir -p $PKG/{kernel,modules,pkgsrc}/install
##setup package dirs
cat >> $PKG/kernel/install/doinst.sh << EOF
if [ ! -f /boot/vmlinuz ];then
( cd boot ; rm -rf System.map )
( cd boot ; ln -sf System.map-$VER System.map )
( cd boot ; rm -rf config )
( cd boot ; ln -sf config-$VER config )
( cd boot ; ln -sf vmlinuz-$VER vmlinuz )
fi

EOF
cat >> $PKG/kernel/install/slack-desc << EOF
kernel: VectorLinux $KERNEL kernel
kernel:
kernel: Built for Vectorlinux
kernel: based on the config-2.6.19.2-VLsleep
kernel: config by joe1962
kernel:
kernel:
kernel:
kernel:
kernel:
kernel: Package Created By: Uelsk8s

EOF
cat >> $PKG/modules/install/doinst.sh << EOF

depmod -aq $VER

EOF
cat >> $PKG/modules/install/slack-desc << EOF
kernel-modules: VectorLinux $KERNEL kernel modules
kernel-modules:
kernel-modules: These are Linux kernel modules (device drivers)
kernel-modules: 
kernel-modules: config by joe1962 
kernel-modules: 
kernel-modules: 
kernel-modules:  
kernel-modules: 
kernel-modules: 
kernel-modules: built by Uelsk8s for Vectorlinux

EOF
cat >> $PKG/pkgsrc/install/doinst.sh << EOF
#!/bin/bash

EOF
cat >> $PKG/pkgsrc/install/slack-desc << EOF
kernel-src: VectorLinux $KERNEL kernel source
kernel-src:
kernel-src: Built for Vectorlinux
kernel-src:
kernel-src: based on the config-2.6.19.2-VLsleep
kernel-src: by joe1962
kernel-src:
kernel-src:
kernel-src:
kernel-src:
kernel-src: Package Created By: Uel Archuletta

EOF
##start
cd $TMP
K=`echo $TMP/$KERNEL | sed -r s/'\/'/'\\\\\/'/g`

function unpackKernel()
{
   # when the kernel version exist, simply untar:
   if [ -e $CURDIR/$KERNEL.tar.xz ]; then
      tar -xf $CURDIR/$KERNEL.tar.xz || exit 1
   else # a -rc kernel is used, we must unpack older version and apply -rc patch
      wget http://www.kernel.org/pub/linux/kernel/v3.0/$KERNEL.tar.xz 
      mv $KERNEL.tar.xz $CURDIR
      tar -xf $CURDIR/$KERNEL.tar.xz || exit 1
   fi
}

eecho "Unpacking archives"

echo $SQUASHFS
tar -xf $CURDIR/$SQUASHFS.tar.gz || exit 1
echo $KERNEL
unpackKernel $KERNEL
ln -s $KERNEL ./linux

eecho "Preparing kernel: aufs performance patches, squashfs + lzma patches"

cd $TMP/$KERNEL
eecho "Patch1"
cp $CURDIR/patches/aufs3-base.patch .
patch -p1<aufs3-base.patch || exit 1
eecho "Patch2"
cp $CURDIR/patches/aufs3-proc_map.patch .
patch -p1 <aufs3-proc_map.patch || exit 1
eecho "Patch3"
cp $CURDIR/patches/aufs3-standalone.patch .
patch -p1 <aufs3-standalone.patch || exit 1
eecho "Patch4"
cp $CURDIR/patches/aufs3-kbuild.patch .
patch -p1 <aufs3-kbuild.patch || exit 1
eecho "Patch5"
cp $CURDIR/patches/aufs3.9-20132804.patch .
patch -p1 <aufs3.9-20132804.patch || exit 1
#cp $CURDIR/patches/current-tuxonice-for-2.6.37.1.patch_0 .
#if [ -e current-tuxonice-for-2.6.37.1.patch_0 ]; then
#patch -p1 <current-tuxonice-for-2.6.37.1.patch_0  || exit 1
#fi
#cp $CURDIR/patches/2.6.36-zen1.patch .
#patch -p1 < 2.6.36-zen1.patch 
#eecho "Patch5"
#cp $CURDIR/patches/squashfs-lzma.patch .
#patch -p1 <squashfs-lzma.patch || exit 1
eecho "Patch6"
cp $CURDIR/patches/404-ath_regd_optional.patch .
patch -p1 <404-ath_regd_optional.patch || exit 1
eecho "Patch7"
cp $CURDIR/patches/405-world_regd_fixup.patch .
patch -p1 <405-world_regd_fixup.patch || exit 1
eecho "Patch8"
#cp $CURDIR/patches/bootsplash-3.4.diff .
#patch -p1 < bootsplash-3.4.diff || exit 1
#cp $CURDIR/patches/4200_fbcondecor-0.9.6.patch .
#patch -p1 <4200_fbcondecor-0.9.6.patch || exit 1
#eecho "Patch6"
#cp $CURDIR/patches/ickle-i855-v2-with-ccc-.4.patch .
#patch -p1 < ickle-i855-v2-with-ccc-.4.patch || exit 1
#cp $CURDIR/patches/fix-i855-cache-coherency-v9.3.patch .
#patch -p1 < fix-i855-cache-coherency-v9.3.patch || exit 1

eecho "configuring kernel"

if [ $ARCH == x86_64 ];then
  cp $CURDIR/config-64 .config
elif [ $ARCH == "i686" ];then
  ARCH=x86
  cp $CURDIR/config-32 .config
else
  echo "$ARCH Unsuported Arch"
  exit 1
fi
make oldconfig
make scripts
make prepare

eecho "compiling kernel"

make -j 3 modules || exit 1
INSTALL_MOD_PATH=$PKG/modules make modules_install || exit 1
make -j 3 bzImage || exit 1

eecho "compiling squashfs+lzma and tools"

mkdir -p $PKG/modules/usr/bin
cd $TMP/$SQUASHFS/squashfs-tools
patch -p2 <$CURDIR/patches/squashfs/Makefile.diff || exit 1
make
cd $TMP
cp $TMP/$SQUASHFS/squashfs-tools/{mk,un}squashfs $PKG/modules/usr/bin
strip --strip-unneeded $PKG/modules/usr/bin/*
cd $PKG/modules/lib/modules/*
#rm -f modules.*
mkdir -p kernel/fs/squashfs/
cp $TMP/$LZMA/C/Compress/Lzma/kmod/{un,sq}lzma.ko kernel/fs/squashfs/
cp $TMP/$KERNEL/fs/squashfs/squashfs.ko kernel/fs/squashfs/

cd $TMP/$KERNEL
mkdir -p $PKG/kernel/boot
cp .config $PKG/kernel/boot/config-$VER
if [ $ARCH == x86_64 ];then
	cp arch/x86/boot/bzImage $PKG/kernel/boot/vmlinuz-$VER
else
	cp arch/i386/boot/bzImage $PKG/kernel/boot/vmlinuz-$VER
fi
cp System.map $PKG/kernel/boot/System.map-$VER

eecho "Building Packages"
#build packages
cd $PKG/kernel
makepkg -l y -c n $PKG/kernel-$VER-$ARCH-$BUILD.txz

cd ../modules
makepkg -l y -p -c n $PKG/kernel-modules-$VER-$ARCH-$BUILD.txz

##Starting driver builds
installpkg $PKG/kernel-modules-*
( cd /usr/src && rm linux; ln -s $KERNEL linux )
cd $CURDIR
for i in $(cat list);do
	cp -ax /home/slackbuilds/var/vabs/$i /tmp/builds/
	cd /tmp/builds/$i/src/
	KVERS=$VER KERNEL=$VER sh $i.SlackBuild
done

eecho "cleaning Source tree"
cd ../pkgsrc
mkdir -p usr/src
cp -ax $TMP/$KERNEL usr/src
( cd usr/src && ln -s $KERNEL linux )
mkdir -p usr/src/build-$VER
cp usr/src/$KERNEL/.config $CURDIR/config
for i in $CURDIR/*;do if ! [ -d $i ];then cp -ax $i usr/src/build-$VER;fi;done
rm -rf usr/src/build-$VER/linux-$VER*
cp -ax $CURDIR/patches usr/src/build-$VER
find . -name *.ko|xargs rm
find . -name *.o|xargs rm
find . -name ..tmp*|xargs rm -r
find . -name .tmp*|xargs rm -r
find . -name *.old|xargs rm -r
find . -name *~|xargs rm -r
rm usr/src/$KERNEL/arch/x86/boot/bzImage
rm usr/src/$KERNEL/arch/x86/boot/vmlinux.bin
rm usr/src/$KERNEL/arch/x86/boot/compressed/vmlinux
rm usr/src/$KERNEL/arch/x86/boot/compressed/vmlinux.bin
rm usr/src/$KERNEL/arch/x86/boot/compressed/vmlinux.bin.*
rm usr/src/$KERNEL/vmlinux
makepkg -l y -c n $PKG/kernel-src-$VER-$ARCH-$BUILD.txz

eecho "cleaning Crippled source tree"
# build crippled kernel source package
cd usr/src/$KERNEL
# remove a lot of stuff
rm -Rf Documentation drivers fs net sound
ls -1d arch/* | grep -v x86 | xargs rm -Rf
ls -1d include/* | grep asm- | grep -v x86 | grep -v generic | xargs rm -Rf
cd ..
rm -r build*

cd $PKG/pkgsrc
cat > $PKG/pkgsrc/install/slack-desc << EOF
kernel-src: VectorLinux $KERNEL kernel source
kernel-src: stripped kernel source
kernel-src: Built for Vectorlinux
kernel-src: This is a stripped down kernel source 
kernel-src: tree. It is INCOMPLETE!
kernel-src: It's used if you build a kernel modules
kernel-src: for your devices, but it can't be used 
kernel-src: to build completely new kernel.
kernel-src: based on the config-2.6.19.2-VLsleep
kernel-src: by joe1962
kernel-src: Package Created By: Uel Archuletta


EOF
cat << EOFF > usr/src/$KERNEL/README.IMPORTANT
This is a stripped down kernel source tree. It is INCOMPLETE!
It's used if you build a kernel modules for your devices,
but it can't be used to build completely new kernel.

If you need full kernel sources, detele all the directories here 
and get the sources from http://www.kernel.org/
EOFF

makepkg -l y -c n $PKG/kernel-stripped-src-$VER-$ARCH-$BUILD.txz

cd ../
rm -r kernel modules pkgsrc
echo packages are finished

fi
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.