Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # ----------------------
- KERNEL_ARCHIVE=/usr/src/linux-source-2.6.18.tar.bz2
- KERNEL=linux-source-2.6.18
- SQUASHFS_LATEST_KERNEL_PATCH=linux-2.6.18
- SQUASHFS=squashfs3.3
- LZMA=lzma457
- # ----------------------
- eecho()
- {
- echo "-------------------------------------"
- echo " * " "$@"
- echo "-------------------------------------"
- }
- set -e
- CURDIR=`pwd`
- TMP=$CURDIR/build
- PKG=$CURDIR/target
- eecho "setting up build and target dir"
- rm -Rf $TMP
- mkdir -p $TMP
- rm -Rf $PKG
- mkdir -p $PKG
- cd $TMP
- K=`echo $TMP/$KERNEL | sed -r s/'\/'/'\\\\\/'/g`
- eecho "Unpacking archives"
- mkdir -p $LZMA
- echo $LZMA
- tar -C $LZMA -xf $CURDIR/$LZMA.tar.*
- echo $SQUASHFS
- tar -xf $CURDIR/$SQUASHFS.tar.*
- echo $KERNEL
- tar -xf $KERNEL_ARCHIVE
- ln -s $KERNEL ./linux
- ln -s $KERNEL ./linux-2.6.24.3
- echo "Squashfs LZMA patches"
- tar -xf $CURDIR/patches/squashfs/sqlzma.tar.*
- eecho "Preparing kernel: squashfs + lzma patches"
- cd $TMP/$KERNEL
- patch -p1 < $TMP/$SQUASHFS/kernel-patches/$SQUASHFS_LATEST_KERNEL_PATCH/*patch
- cd $TMP
- patch -p0 < $TMP/sqlzma2k-3.3.patch
- patch -p0 < $TMP/sqlzma2u-3.3.patch
- patch -p0 < $CURDIR/patches/squashfs/cvs/typo_mkflags_u.patch
- patch -p0 < $CURDIR/patches/squashfs/cvs/unsquashfs_bugfixes.patch
- patch -p0 < $CURDIR/patches/squashfs/cvs/mksquashfs_trace_fixes.patch
- patch -p0 < $CURDIR/patches/squashfs/cvs/mksquashfs_unused_vars.patch
- patch -p0 < $CURDIR/patches/squashfs/cvs/mksquashfs_code_cleanups.patch
- patch -p0 < $CURDIR/patches/squashfs/cvs/mksquashfs_bug_fixes.patch
- #patch -p0 < $CURDIR/patches/squashfs/cvs/missing_void.patch
- patch -p0 < $CURDIR/patches/squashfs/cvs/code_cleanup.patch
- cd $KERNEL
- #patch -p1 < $CURDIR/patches/squashfs/cvs/static_declarations.patch
- patch -p1 < $CURDIR/patches/squashfs/cvs/typo_mkflags_k.patch
- # I need to remove the following 2.6.24.3 patch in order to even compile the kernel. Why?
- patch -p1 -R < $CURDIR/patches/kernel_compile.patch
- cd $TMP/$LZMA
- patch -p1 < $TMP/sqlzma1-449.patch
- cd $TMP/$SQUASHFS/squashfs-tools
- patch -p0 < $CURDIR/patches/squashfs/mksquashfs.quiet.patch
- cd $TMP
- cat Makefile | sed -r "s/KDir = .*/KDir = $K/" \
- | sed -r "s/SqFs = .*/SqFs = $K\/fs\/squashfs\//" \
- | sed -r "s/LzmaVer =.*/LzmaVer = $LZMA/" \
- | sed -r "s/C=1/C=0/" >Makefile2
- cat Makefile2 >Makefile
- cd $TMP/$KERNEL
- eecho "configuring kernel"
- # squashfs will be compiled separately, so make sure it's not in the kernel configuration
- #cat $CURDIR/config | grep -v "CONFIG_SQUASHFS_" | sed -r "s/.*CONFIG_SQUASHFS[^_]*/CONFIG_SQUASHFS=n/" > ./.config
- make oldconfig
- make scripts
- make prepare
- #eecho "compiling kernel"
- #cd $TMP/$KERNEL
- #make -j 3 modules
- #INSTALL_MOD_PATH=$PKG make modules_install
- #make -j 3 bzImage
- eecho "compiling squashfs+lzma and tools"
- cd $TMP
- make 2>&1 > $CURDIR/log
- mkdir -p $PKG/usr/bin
- cp $TMP/$SQUASHFS/squashfs-tools/{mk,un}squashfs $PKG/usr/bin
- strip --strip-unneeded $PKG/usr/bin/*
- mkdir -p $PKG/lib/modules/
- cd $PKG/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 $PKG
- if [ -e /sbin/makepkg ]; then
- makepkg -l n -c n $KERNEL-i486-1.tgz
- eecho "now install $PKG/$KERNEL-i486-1.tgz, run lilo & reboot"
- else
- echo "your kernel is ready in $PKG"
- fi
- echo press any key...
- read
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement