summaryrefslogtreecommitdiff
path: root/bin/pack_kernel.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/pack_kernel.sh')
-rwxr-xr-xbin/pack_kernel.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/bin/pack_kernel.sh b/bin/pack_kernel.sh
new file mode 100755
index 0000000..4f766be
--- /dev/null
+++ b/bin/pack_kernel.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+# This script is based on the work performed by Aristeu Rozanski
+# I got a copy from his work by e-mail, due that no CVS tree is
+# being referenced
+
+if [ -f include/generated/utsrelease.h ]; then
+ FILE=include/generated/utsrelease.h;
+else
+ FILE=include/linux/utsrelease.h;
+fi
+version=$(grep UTS_RELEASE $FILE | cut -f 2 -d '"');
+if [ -z "$version" ]; then
+ echo "couldn't get version" >&2;
+ exit 1;
+fi
+echo "version is $version" >&2
+dir=$(mktemp -d);
+
+#make $(cat vars) modules_install INSTALL_MOD_PATH=$dir/ >/dev/null;
+make $(cat vars) modules_install INSTALL_MOD_PATH=$dir/ >/dev/null;
+mkdir $dir/boot
+cp .config $dir/boot/config-$version;
+cp System.map $dir/boot/System.map-$version;
+cp arch/x86/boot/bzImage $dir/boot/vmlinuz-$version;
+cp vmlinux $dir/boot;
+last=$PWD;
+cd $dir
+
+debug_enabled=0;
+# stripping debug info and packing in a different tarball
+if [ -n "$(grep ^CONFIG_DEBUG_KERNEL=y $last/.config)" ]; then
+ debug_enabled=1;
+ debug=$(mktemp -d);
+ find . -name \*.ko -exec objcopy --only-keep-debug {} {}.debug \;
+ find . -name \*.ko -exec strip -g {} \;
+ tar cfj $last/debug-$version.tar.bz2 boot/vmlinux $(find lib -name \*.debug)
+ rm boot/vmlinux $(find lib -name \*.debug);
+ rm -Rf $debug;
+fi
+
+tar cfj $last/$version.tar.bz2 *
+cd $last;
+echo $version.tar.bz2;
+if [ $debug_enabled = 1 ]; then
+ echo "debug info saved on debug-$version.tar.bz2"
+fi
+rm -Rf $dir;