Placing kernel_debug.sh in kvmfornfv kernel module 25/35025/2
authorNavya <navyax.bathula@intel.com>
Fri, 19 May 2017 05:34:34 +0000 (11:04 +0530)
committerNavya Bathula <navyax.bathula@intel.com>
Mon, 22 May 2017 11:36:51 +0000 (11:36 +0000)
This patch includes placing the kernel_debug.sh script in kvmfornfv
kernel module as the script consists code purely related to kernel.

Change-Id: I7b89e1a192e2ae5c3d0aff037b92f78757032aed
Signed-off-by: Navya Bathula <navyax.bathula@intel.com>
kernel/scripts/kernel_debug.sh [new file with mode: 0755]
kernel/scripts/package/mkspec

diff --git a/kernel/scripts/kernel_debug.sh b/kernel/scripts/kernel_debug.sh
new file mode 100755 (executable)
index 0000000..5ccf1af
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+tmpdir=$1 #/tmp/kvmfornfv_rpmbuild.1/BUILD/kernel-4.4.50_rt62nfv
+OBJCOPY=objcopy
+if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
+for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do
+                        module=lib/modules/$module
+                        mkdir -p $(dirname $tmpdir/usr/lib/debug/$module)
+                        # only keep debug symbols in the debug file
+                        $OBJCOPY --only-keep-debug $tmpdir/$module $tmpdir/usr/lib/debug/$module
+                        # strip original module from debug symbols
+                        $OBJCOPY --strip-debug $tmpdir/$module
+                        # then add a link to those
+                        $OBJCOPY --add-gnu-debuglink=$tmpdir/usr/lib/debug/$module $tmpdir/$module
+                done
+fi
\ No newline at end of file
index 0f96d4f..401b948 100755 (executable)
@@ -92,7 +92,7 @@ echo "%endif"
 echo 'mkdir -p $RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
 
 echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= mod-fw= modules_install'
-echo '/opt/kvmfornfv/ci/kernel_debug.sh $RPM_BUILD_ROOT'
+echo '$RPM_SOURCE_DIR/scripts/kernel_debug.sh $RPM_BUILD_ROOT'
 echo 'INSTALL_FW_PATH=$RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
 echo 'make INSTALL_FW_PATH=$INSTALL_FW_PATH' firmware_install
 echo "%ifarch ia64"