summaryrefslogtreecommitdiff
path: root/bin/pack_kernel.sh
diff options
context:
space:
mode:
authorCarlos Maiolino <[email protected]>2024-05-31 10:55:57 +0200
committerCarlos Maiolino <[email protected]>2024-05-31 10:55:57 +0200
commitc24810c3d5f07c076241b8fd5d912c1136c2cf80 (patch)
tree6c1f906de6212897559a28260d28670233988dd8 /bin/pack_kernel.sh
parent47b7016ed5ac6dd8efc041060d62e632e937a6d2 (diff)
Add a few extra scripts and move them to bin/
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;