1 |
#!/bin/sh |
2 |
# Called by abrtd before producing a backtrace. |
3 |
# The task of this script is to install debuginfos. |
4 |
|
5 |
core="$1" |
6 |
debug=false |
7 |
|
8 |
# stderr may be used for status messages too |
9 |
exec 2>&1 |
10 |
|
11 |
error_msg_and_die() { |
12 |
echo "$*" |
13 |
exit 2 |
14 |
} |
15 |
|
16 |
count_words() { |
17 |
echo $# |
18 |
} |
19 |
|
20 |
print_missing_debuginfos() { |
21 |
local dir |
22 |
local executable |
23 |
dir="$1" |
24 |
sed -n -e 's|.*from /|/|p' < "$dir"/backtrace | sort -u |
25 |
executable=`cat "$dir"/executable` |
26 |
test -f /usr/lib/debug/"$executable" || echo "$executable" |
27 |
} |
28 |
|
29 |
print_package_names() { |
30 |
echo $missing_debuginfo_files | xargs rpm -qf --qf "%{SOURCERPM}\n" | sed 's/-[^-]*-[^-]*$/-debug/' | sort -u |
31 |
} |
32 |
|
33 |
# Sanity checking |
34 |
test -f "$core" || error_msg_and_die "not a file: '$core'" |
35 |
|
36 |
dir=`dirname "$core"` |
37 |
|
38 |
missing_debuginfo_files=`print_missing_debuginfos "$dir"` |
39 |
|
40 |
$debug && echo "missing_debuginfo_files:$missing_debuginfo_files" |
41 |
|
42 |
# Map $missing_debuginfo_files to package names. |
43 |
packages=`print_package_names` |
44 |
$debug && echo "packages:$packages" |
45 |
|
46 |
if test x"$packages" != x"" ; then |
47 |
num_packages=`count_words $packages` |
48 |
echo "Installing $num_packages packages" |
49 |
urpmi.update debug |
50 |
/usr/sbin/urpmi --auto --media debug $packages |
51 |
fi |
52 |
|
53 |
echo "All needed debuginfos are present" |
54 |
exit 0 |