From c24810c3d5f07c076241b8fd5d912c1136c2cf80 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Fri, 31 May 2024 10:55:57 +0200 Subject: Add a few extra scripts and move them to bin/ --- bin/pack_kernel.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 bin/pack_kernel.sh (limited to 'bin/pack_kernel.sh') 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; -- cgit v1.2.3