summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorPrashant D <pdhange@redhat.com>2017-11-08 22:09:42 +1100
committerAmar Tumballi <amarts@redhat.com>2017-11-26 23:05:14 +0000
commita3f4b71c1f54eac885b5625b2387027be91e5a2a (patch)
treec276fc670d2f3e63e4560c861a9ffb79861484c1 /extras
parentf3a8953e6a72631dc29958e996388ffed2f5940a (diff)
extras/devel-tools: Fix print-backtrace script
Problem: If cpio version is less 2.11 then cpio command failing with unrecognised option --directory. Solution: Check the cpio version and run rpm2cpio/cpio with or without -D or --directory option. Fixes : #359 Change-Id: Ibd440207231807dab1b58291ab661857094f1a4a BUG: 1510874 Signed-off-by: Prashant D <pdhange@redhat.com>
Diffstat (limited to 'extras')
-rwxr-xr-xextras/devel-tools/print-backtrace.sh20
1 files changed, 18 insertions, 2 deletions
diff --git a/extras/devel-tools/print-backtrace.sh b/extras/devel-tools/print-backtrace.sh
index 873b6bc692d..72b93c1353f 100755
--- a/extras/devel-tools/print-backtrace.sh
+++ b/extras/devel-tools/print-backtrace.sh
@@ -20,6 +20,8 @@
# Usage with source install:
# print-packtrace.sh none bt-file.txt
+function version_compare() { test $(echo $1|awk -F '.' '{print $1 $2 $3}') -gt $(echo $2|awk -F '.' '{print $1 $2 $3}'); }
+
function Usage()
{
echo -e "Usage:\n\t$0 { none | <debuginfo-rpm> } <backtrace-file>"
@@ -53,6 +55,7 @@ if ! file $debuginfo_rpm | grep RPM >/dev/null 2>&1 ; then
exit 1
fi
+cpio_version=$(cpio --version|grep cpio|cut -f 2 -d ')'|sed -e 's/^[[:space:]]*//')
rpm_name=""
debuginfo_path=""
debuginfo_extension=""
@@ -66,8 +69,21 @@ if [ $debuginfo_rpm != "none" ]; then
exit 1
fi
mkdir -p $rpm_name
- rpm2cpio $debuginfo_rpm | cpio --quiet --extract --make-directories --preserve-modification-time --directory=$rpm_name
-
+ if version_compare $cpio_version "2.11"; then
+ rpm2cpio $debuginfo_rpm | cpio --quiet --extract --make-directories --preserve-modification-time --directory=$rpm_name
+ ret=$?
+ else
+ current_dir="$PWD"
+ cd $rpm_name
+ rpm2cpio $debuginfo_rpm | cpio --quiet --extract --make-directories --preserve-modification-time
+ ret=$?
+ cd $current_dir
+ fi
+ if [ $ret -eq 1 ]; then
+ echo "failed to extract rpm $debuginfo_rpm to $PWD/$rpm_name directory"
+ rm -rf $rpm_name
+ exit 1
+ fi
debuginfo_path="$PWD/$rpm_name/usr/lib/debug"
debuginfo_extension=".debug"
else