To generate debug rpm and debian package for kvmfornfv kernel
[kvmfornfv.git] / ci / kernel_debug.sh
1 #!/bin/sh
2
3 tmpdir=$1 #/tmp/kvmfornfv_rpmbuild.1/BUILD/kernel-4.4.50_rt62nfv
4 OBJCOPY=objcopy
5 if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
6 for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do
7                         module=lib/modules/$module
8                         mkdir -p $(dirname $tmpdir/usr/lib/debug/$module)
9                         # only keep debug symbols in the debug file
10                         $OBJCOPY --only-keep-debug $tmpdir/$module $tmpdir/usr/lib/debug/$module
11                         # strip original module from debug symbols
12                         $OBJCOPY --strip-debug $tmpdir/$module
13                         # then add a link to those
14                         $OBJCOPY --add-gnu-debuglink=$tmpdir/usr/lib/debug/$module $tmpdir/$module
15                 done
16 fi