From f45ba85bf5a19281a52ac11e85ffba289baed696 Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 11 Feb 2005 21:12:50 +0000 Subject: [PATCH] added this forgotten script! --- scripts/Make-KPkg | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100755 scripts/Make-KPkg diff --git a/scripts/Make-KPkg b/scripts/Make-KPkg new file mode 100755 index 0000000..b12afe6 --- /dev/null +++ b/scripts/Make-KPkg @@ -0,0 +1,96 @@ +#!/bin/bash +# +# author: hackbard@hackdaworld.dyndns.org +# +# create a kernel binary package +# + +config="" +name="" +homedir=$PWD + +while [ "$1" ] ; do + case "$1" in + -config) config=$2 ; shift 2 ;; + -name) name=$2 ; shift 2 ;; + *) + echo + echo "usage:" + echo + echo "-config " + echo "-name " + echo + exit 1 ;; + esac +done + +. ./Config + +if [ "$hdw_arch" != "ia32" ] ; then + echo "warning: only ia32 supported by now" + echo "hack me ... " + exit 1 +fi + +[ -z "$config" ] && config="./misc/arch/${hdw_arch}/linux.config" +[ -z "$name" ] && name="custom-$hdw_arch" + +if [ ! -f $config ] ; then + echo "$config doesn't exist, aborting ..." + exit 1 +fi + +kerpkg="`grep '^#\ \[D\]' ./packages/base/linux/linux | awk '{ print $3 }'`" +kerver="`grep '^#\ \[V\]' ./packages/base/linux/linux | awk '{ print $3 }'`" + +trg=$homedir/kernel-image-${kerver}_${name}.tar.bz2 +if [ -f $trg ] ; then + echo "image $trg already exists, aborting ..." + exit 1 +fi + +[ ! -f ./download/base/linux/$kerpkg ] && ./scripts/Download -package linux + +# backing up old kernel + modules +kerbackup=no +if [ -f /boot/vmlinuz_$kerver ] ; then + mv /boot/vmlinuz_$kerver /boot/vmlinuz_${kerver}__orig + kerbackup=yes +fi +modbackup=no +if [ -d /lib/modules/$kerver ] ; then + mv /lib/modules/$kerver /lib/modules/${kerver}__orig + modbackup=yes +fi + +# build kernel & modules +kerarch=${hdw_arch//ia32/i386} +cp $config /tmp/linux.config +rm -rf /tmp/linux-$kerver +tar xfj ./download/base/linux/$kerpkg -C /tmp +cd /tmp/linux-$kerver +mv ../linux.config .config +cd include && ln -sf asm-${kerarch} asm && cd .. +yes "" | make oldconfig +make bzImage modules modules_install +cp arch/$kerarch/boot/bzImage /boot/vmlinuz_$kerver +cp .config /boot/kernel-config-$kerver-$name + +# create the package +cd / +tar --use-compress-program=bzip2 -cf $trg lib/modules/$kerver \ + boot/vmlinuz_$kerver /boot/kernel-config-$kerver-$name + +cd $homedir + +# restore kernel & modules +rm -f /boot/vmlinuz_$kerver +[ "$kerbackup" = "yes" ] && \ + mv /boot/vmlinuz_${kerver}__orig /boot/vmlinuz_$kerver +rm -rf /lib/modules/$kerver +[ "$modbackup" = "yes" ] && \ + mv /lib/modules/${kerver}__orig /lib/modules/$kerver + +echo +echo "done" +echo -- 2.39.2