summaryrefslogtreecommitdiff
path: root/bin/pack_kernel.sh
blob: 4f766bef947643f668c3b2708282f01c56d9d263 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;