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 # 3.18.6-100.fc20.i686+PAE (".arch+variant", dot, plus)
11 if [ "$#" -lt 1 ]; then
12 UNAME
=`uname -r` # determine the kernel running on the machine
14 UNAME
=$1 #user passed in uname value
16 UNAME
=`echo $UNAME | sed "s/ //"` #strip out any whitespace
18 for VARIANT
in debug kdump PAE xen
; do
19 # strip out ".variant" or else "+variant" or else "variant" at end.
20 TMP
=`echo $UNAME | sed "s/[\.\+]\?$VARIANT\$//"`
21 if [ "$TMP" != "$UNAME" ]; then
22 UNAME
=$TMP; KERNEL
="kernel-$VARIANT"
26 KERN_REV
=`echo $UNAME | sed s/.$KERN_ARCH//` # strip arch from uname
27 CANDIDATES
="$KERNEL-$KERN_REV.$KERN_ARCH \
28 $KERNEL-devel-$KERN_REV.$KERN_ARCH \
29 $KERNEL-debuginfo-$KERN_REV.$KERN_ARCH"
30 NEEDED
=`rpm --qf "%{name}-%{version}-%{release}.%{arch}\n" \
31 -q $CANDIDATES | grep "is not installed" | awk '{print $2}'`
32 if [ "$NEEDED" != "" ]; then
33 echo -e "Need to install the following packages:\n$NEEDED"
34 if [ `id -u` = "0" ]; then #attempt to install
35 yum
install -y --enablerepo=\
* $NEEDED
37 check_error $?
"problem installing rpm(s) $NEEDED"
44 echo "Specifying kernel version is not yet support on deb based systems." 1>&2
50 ABINAME
="$(cut -d " " -f 3 /proc/version)"
53 BASEVERSION
="$(echo "$ABINAME" | cut -d "-" -f 1)"
57 if uname
-v |
grep -q Debian
; then
58 VERSION
="$(uname -v | cut -d " " -f 4)"
60 VERSION
="$(cut -d " " -f 5 /proc/version | cut -d ")" -f 1)"
65 VERSION
="$(cut -d " " -f 2 /proc/version_signature | cut -d "-" -f 1-2)"
71 echo "linux-image-$ABINAME = $VERSION"
72 echo "linux-headers-$ABINAME = $VERSION"
75 echo "linux-image-$ABINAME-dbg = $VERSION"
78 echo "linux-image-$ABINAME-dbgsym = $VERSION"
81 ) |
while read package relation requiredversion
; do
82 installedversion
="$(dpkg-query -W "$package" 2> /dev/null | cut -f 2)"
83 if [ "$installedversion" = "" ]; then
84 availableversion
="$(apt-cache show $package 2> /dev/null | grep ^Version: | cut -d " " -f 2)"
85 if [ "$availableversion" = "" ]; then
86 echo "You need package $package but it does not seem to be available"
87 if [ "$DISTRO" = "Ubuntu" -a "$(echo $package | grep dbgsym$)" ]; then
88 echo " Ubuntu -dbgsym packages are typically in a separate repository"
89 echo " Follow https://wiki.ubuntu.com/DebuggingProgramCrash to add this repository"
90 elif [ "$DISTRO" = "Debian" -a "$(echo $package | grep dbg$)" ]; then
91 echo " Debian does not have -dbg packages for all kernels. Consider switching to a kernel that has one."
94 echo "Please install $package"
96 elif ! dpkg
--compare-versions $installedversion $relation $requiredversion; then
97 echo "Package $package version $installedversion does not match version of currently running kernel: $requiredversion"
98 echo " Consider apt-get upgrade && reboot"
102 user
="$(id --user --name)"
103 if [ "$user" != "root" ]; then
104 groups
="$(id --groups --name)"
105 for i
in stapusr stapdev
; do
106 if [ "$(echo $groups | grep $i)" = "" ]; then
107 echo "Be root or adduser $user $i"
113 DISTRO
="$(lsb_release --id --short 2> /dev/null)"
114 if [ $?
-ne 0 ]; then