]> hackdaworld.org Git - hdw-linux/hdw-linux.git/commitdiff
added this forgotten script!
authorhackbard <hackbard>
Fri, 11 Feb 2005 21:12:50 +0000 (21:12 +0000)
committerhackbard <hackbard>
Fri, 11 Feb 2005 21:12:50 +0000 (21:12 +0000)
scripts/Make-KPkg [new file with mode: 0755]

diff --git a/scripts/Make-KPkg b/scripts/Make-KPkg
new file mode 100755 (executable)
index 0000000..b12afe6
--- /dev/null
@@ -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 <kernel config file>"
+                       echo "-name <kernel 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