3 check_error
() { if test $1 != 0; then echo $2; exit $1; fi }
6 # uname -r can produce different kinds of output:
7 # 2.6.32-30.el6.x86_64 (no variant, but including ".arch")
8 # 2.6.18-194.3.1.el5debug ("variant", without dot, no arch)
9 # 2.6.33.4-95.fc13.i686.PAE (".arch.variant", two dots)
10 if [ "$#" -lt 1 ]; then
11 UNAME
=`uname -r` # determine the kernel running on the machine
13 UNAME
=$1 #user passed in uname value
15 UNAME
=`echo $UNAME | sed "s/ //"` #strip out any whitespace
17 for VARIANT
in debug kdump PAE xen
; do
18 # strip out ".variant" or else "variant" at end.
19 TMP
=`echo $UNAME | sed s/\\\\.$VARIANT\$// | sed s/$VARIANT\$//`
20 if [ "$TMP" != "$UNAME" ]; then
21 UNAME
=$TMP; KERNEL
="kernel-$VARIANT"
25 KERN_REV
=`echo $UNAME | sed s/.$KERN_ARCH//` # strip arch from uname
26 CANDIDATES
="$KERNEL-$KERN_REV.$KERN_ARCH \
27 $KERNEL-devel-$KERN_REV.$KERN_ARCH \
28 $KERNEL-debuginfo-$KERN_REV.$KERN_ARCH"
29 NEEDED
=`rpm --qf "%{name}-%{version}-%{release}.%{arch}\n" \
30 -q $CANDIDATES | grep "is not installed" | awk '{print $2}'`
31 if [ "$NEEDED" != "" ]; then
32 echo -e "Need to install the following packages:\n$NEEDED"
33 if [ `id -u` = "0" ]; then #attempt download and install
34 DIR
=`mktemp -d` ||
exit 1
35 if [ ! -x /usr
/bin
/yumdownloader
]; then
36 echo "Need to first install yum-utils for yumdownloader"
37 yum
install -y yum-utils
39 yumdownloader
--enablerepo="*debuginfo*" $NEEDED --destdir=$DIR \
41 check_error $?
"problem downloading rpm(s) $NEEDED"
42 rpm
--force -ivh $DIR/*.rpm
43 check_error $?
"problem installing rpm(s) $NEEDED"
51 echo "Specifying kernel version is not yet support on deb based systems." 1>&2
57 ABINAME
="$(cut -d " " -f 3 /proc/version)"
60 BASEVERSION
="$(echo "$ABINAME" | cut -d "-" -f 1)"
64 if uname
-v |
grep -q Debian
; then
65 VERSION
="$(uname -v | cut -d " " -f 4)"
67 VERSION
="$(cut -d " " -f 5 /proc/version | cut -d ")" -f 1)"
72 VERSION
="$(cut -d " " -f 2 /proc/version_signature | cut -d "-" -f 1-2)"
78 echo "linux-image-$ABINAME = $VERSION"
79 echo "linux-headers-$ABINAME = $VERSION"
82 echo "linux-image-$ABINAME-dbg = $VERSION"
85 echo "linux-image-$ABINAME-dbgsym = $VERSION"
88 ) |
while read package relation requiredversion
; do
89 installedversion
="$(dpkg-query -W "$package" 2> /dev/null | cut -f 2)"
90 if [ "$installedversion" = "" ]; then
91 availableversion
="$(apt-cache show $package 2> /dev/null | grep ^Version: | cut -d " " -f 2)"
92 if [ "$availableversion" = "" ]; then
93 echo "You need package $package but it does not seem to be available"
94 if [ "$DISTRO" = "Ubuntu" -a "$(echo $package | grep dbgsym$)" ]; then
95 echo " Ubuntu -dbgsym packages are typically in a separate repository"
96 echo " Follow https://wiki.ubuntu.com/DebuggingProgramCrash to add this repository"
97 elif [ "$DISTRO" = "Debian" -a "$(echo $package | grep dbg$)" ]; then
98 echo " Debian does not have -dbg packages for all kernels. Consider switching to a kernel that has one."
101 echo "Please install $package"
103 elif ! dpkg
--compare-versions $installedversion $relation $requiredversion; then
104 echo "Package $package version $installedversion does not match version of currently running kernel: $requiredversion"
105 echo " Consider apt-get upgrade && reboot"
109 user
="$(id --user --name)"
110 if [ "$user" != "root" ]; then
111 groups
="$(id --groups --name)"
112 for i
in stapusr stapdev
; do
113 if [ "$(echo $groups | grep $i)" = "" ]; then
114 echo "Be root or adduser $user $i"
120 DISTRO
="$(lsb_release --id --short 2> /dev/null)"
121 if [ $?
-ne 0 ]; then