-
Notifications
You must be signed in to change notification settings - Fork 1
/
everything-dbg
executable file
·46 lines (42 loc) · 1.58 KB
/
everything-dbg
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
#!/bin/bash
set -e
if type apt-rdepends > /dev/null 2>&1; then true; else
echo "Required dependency 'apt-rdepends' is not installed. You can install it by typing:
sudo apt install apt-rdepends" > /dev/stderr
exit 1
fi
if [ "$1" = "" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "
Usage: $(basename "$0") PACKAGE
Prints names of debugging packages for all dependencies of the specified package.
You can pass these names to 'apt install' to install everything required for debugging the package you've specified." > /dev/stderr
exit 1
fi
all_known_packages="$(mktemp)"
existing_debug_packages="$(mktemp)"
function cleanup {
rm -f "$all_known_packages"
rm -f "$existing_debug_packages"
}
trap cleanup EXIT
apt-cache pkgnames | sort > "$all_known_packages"
apt-rdepends "$1" | grep -v '^ ' | grep '^lib' | while read -r package_name; do
if grep -q -- "$package_name"'-dbgsym' "$all_known_packages"; then
echo "$package_name"'-dbgsym' >> "$existing_debug_packages"
elif grep -q -- "$package_name"'-dbg' "$all_known_packages"; then
echo "$package_name"'-dbg' >> "$existing_debug_packages"
else
echo "W: $package_name has no associated debug package" > /dev/stderr
fi
done
#echo "Checking if required -dbg packages are actually installable..." > /dev/stderr
result=$( (
cat "$existing_debug_packages" | while read -r package_name; do
if apt-get -s install "$package_name" > /dev/null 2>&1; then
echo "$package_name"
else
echo "W: $package_name exists, but cannot be installed" > /dev/stderr
fi
done
) | tr '\n' ' ')
echo "$result"