3 # author: hackbard@hackdaworld.dyndns.org
5 # create a kernel binary package
15 -config) config=$2 ; shift 2 ;;
16 -name) name=$2 ; shift 2 ;;
17 -dir) builddir=$2 ; shift 2 ;;
22 echo "-config <kernel config file>"
23 echo "-name <kernel name>"
24 echo "-dir <build dir>"
32 if [ "$hdw_arch" != "ia32" ] ; then
33 echo "warning: only ia32 supported by now"
38 [ -z "$config" ] && config="./misc/arch/${hdw_arch}/linux.config"
39 [ -z "$name" ] && name="custom-$hdw_arch"
40 [ -z "$builddir" ] && builddir="/tmp"
42 if [ ! -f $config ] ; then
43 echo "$config doesn't exist, aborting ..."
47 if [ ! -d $builddir ] ; then
48 echo "$builddir doesn't exist, aborting ..."
52 kerpkg="`grep '^#\ \[D\]' ./packages/base/linux/linux | awk '{ print $3 }'`"
53 kerver="`grep '^#\ \[V\]' ./packages/base/linux/linux | awk '{ print $3 }'`"
55 trg=$homedir/kernel-image-${kerver}_${name}.tar.bz2
57 echo "image $trg already exists, aborting ..."
61 [ ! -f ./download/base/linux/$kerpkg ] && ./scripts/Download -package linux
63 # backing up old kernel + modules
65 if [ -f /boot/vmlinuz_$kerver ] ; then
66 mv /boot/vmlinuz_$kerver /boot/vmlinuz_${kerver}__orig
70 if [ -d /lib/modules/$kerver ] ; then
71 mv /lib/modules/$kerver /lib/modules/${kerver}__orig
75 # build kernel & modules
76 kerarch=${hdw_arch//ia32/i386}
77 cp $config $builddir/linux.config
78 rm -rf $builddir/linux-$kerver
79 tar xfj ./download/base/linux/$kerpkg -C $builddir
80 cd $builddir/linux-$kerver
81 mv ../linux.config .config
82 cd include && ln -sf asm-${kerarch} asm && cd ..
83 yes "" | make oldconfig
84 make bzImage modules modules_install
85 cp arch/$kerarch/boot/bzImage /boot/vmlinuz_$kerver
86 cp .config /boot/kernel-config-$kerver-$name
90 tar --use-compress-program=bzip2 -cf $trg lib/modules/$kerver \
91 boot/vmlinuz_$kerver /boot/kernel-config-$kerver-$name
95 # restore kernel & modules
96 rm -f /boot/vmlinuz_$kerver
97 [ "$kerbackup" = "yes" ] && \
98 mv /boot/vmlinuz_${kerver}__orig /boot/vmlinuz_$kerver
99 rm -rf /lib/modules/$kerver
100 [ "$modbackup" = "yes" ] && \
101 mv /lib/modules/${kerver}__orig /lib/modules/$kerver