# SliTaz package receipt.
PACKED_SIZE="1.1M"
UNPACKED_SIZE="1.9M"
PACKAGE="linux"
VERSION="2.6.20"
CATEGORY="base-system"
SHORT_DESC="The Linux kernel."
TARGET="i486"
MAINTAINER="devel@slitaz.org"
LICENSE="GPL2"
TARBALL="$PACKAGE-$VERSION.tar.bz2"
WEB_SITE="http://www.kernel.org/"
WGET_URL="https://www.kernel.org/pub/linux/kernel/v${VERSION:0:3}/$TARBALL"
AUTO_SELECTION="always"
DEPENDS=""
BUILD_DEPENDS="slitaz-toolchain perl git lzma wget upx"
INSTALL_DEPENDS="lz4 grep"
case "$TARGET" in
i486) SUGGESTED="memtest ipxe plop tfttest x86test";; # bundle may install a boot menu
esac
S2bin()
{
[ -s $stuff/$1.S ] &&
cc -o $1.o -Wa,-algms=$1.lst -c $stuff/$1.S &&
objcopy -O binary $1.o $1.bin
}
rootfs()
{
[ -s $stuff/root.cpio ] && cp $stuff/root.cpio . &&
sed -i 's|CONFIG_INITRAMFS_SOURCE="|&root.cpio|' .config
}
# Rules to configure and make the package.
compile_rules()
{
export CFLAGS="-march=i386 -Os -pipe -fomit-frame-pointer"
for i in $stuff/linux-$VERSION-*.u ; do
patch -p0 < $i
done
sed -i 's/O_CREAT/&|O_TRUNC/' init/initramfs.c
sed -i 's|hostname|echo tank|' scripts/mkcompile_h
mkdir $src/slitaz
cp $stuff/list_modules.sh $src/slitaz
S2bin bootloader
S2bin helper
S2bin unpacklz4
cp $stuff/pack .
sh ./pack --build
sed -i '/config %config:/{NNNps/config %config:/%config:/}' Makefile &&
sed -i 's/^config %config:/config:/' Makefile
#2.6.20
sed -i '/\/ %\/:/{NNps/\/ %\/:/%\/:/}' Makefile &&
sed -i 's/^\/ %\/:/\/:/' Makefile
sed -i 's|.*netinet/in|#include \n&|' scripts/mod/sumversion.c
cp $stuff/linux-$VERSION-slitaz.config .config
rootfs
yes '' | make ARCH=i386 HOSTCC=gcc config
make ARCH=i386 CC=gcc HOSTCC=gcc -j 4 bzImage
grep -q "CONFIG_MODULES=y" .config &&
make ARCH=i386 CC=gcc HOSTCC=gcc -j 4 modules &&
make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR -j 1 modules_install || true
S2bin bundle
cp $stuff/bundle .
sh ./bundle
S2bin cmdline
[ $(upx --version 2> /dev/null | sed '/upx/!d;s|upx ||;s|\.||;q')0 -ge 3960 ] &&
upx --ultra-brute arch/i386/boot/bzImage
cp arch/i386/boot/bzImage arch/i386/boot/bzImage.386
cp .config .config.386
cp System.map System.map.386
cp $stuff/linux-$VERSION-slitaz.config.586 .config
rootfs
yes '' | make ARCH=i386 HOSTCC=gcc config
make ARCH=i386 CC=gcc HOSTCC=gcc -j 4 bzImage
which upx 2> /dev/null && upx --ultra-brute arch/i386/boot/bzImage
}
# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
mkdir $fs/boot
cp -a $src/pack $fs/boot/
cp -a $src/bundle.sh $fs/boot/bundle
for i in '' .386 ; do
[ -s $src/arch/i386/boot/bzImage$i ] || continue
cp -a $src/arch/i386/boot/bzImage$i $fs/boot/
dd if=$src/bootloader.bin of=$fs/boot/bzImage$i conv=notrunc
dd if=$src/cmdline.bin bs=1 seek=560 of=$fs/boot/bzImage$i conv=notrunc
cp -a $src/System.map$i $fs/boot/
cp -a $src/.config$i $fs/boot/config$i
done
}
config_form()
{
cat <
Tune the kernel according to the CPU type
EOT
}
# Pre and post install commands for Tazpkg.
post_install()
{
for i in $1/boot/*.386 ; do
[ "$CPU586" = "yes" ] && rm -f $i || mv -f $i ${i%.386}
done 2> /dev/null
[ -s $1/boot/cmdline ] && cat $1/boot/cmdline | sed 's/^ *//' | \
dd of=$1/boot/bzImage conv=notrunc bs=1 seek=768 count=3072
$1/boot/pack $1/boot/bzImage
}