File: stap-prep

package info (click to toggle)
systemtap 1.7-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 18,448 kB
  • sloc: ansic: 43,401; cpp: 42,120; exp: 12,293; sh: 8,703; xml: 7,522; perl: 2,088; tcl: 954; python: 912; makefile: 625; ruby: 419; awk: 94; asm: 73; sed: 16
file content (45 lines) | stat: -rwxr-xr-x 1,772 bytes parent folder | download
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
#! /bin/bash
LANG=C; export LANG
check_error() { if test $1 != 0; then echo $2; exit $1; fi }

# uname -r can produce different kinds of output:
# 2.6.32-30.el6.x86_64 (no variant, but including ".arch")
# 2.6.18-194.3.1.el5debug ("variant", without dot, no arch)
# 2.6.33.4-95.fc13.i686.PAE (".arch.variant", two dots)
if [ "$#" -lt 1 ]; then
    UNAME=`uname -r` # determine the kernel running on the machine
else
    UNAME=$1 #user passed in uname value
fi
UNAME=`echo $UNAME | sed "s/ //"` #strip out any whitespace
KERNEL="kernel"
for VARIANT in debug kdump PAE xen; do
  # strip out ".variant" or else "variant" at end.
  TMP=`echo $UNAME | sed s/\\\\.$VARIANT\$// | sed s/$VARIANT\$//`
  if [ "$TMP" != "$UNAME" ]; then
      UNAME=$TMP; KERNEL="kernel-$VARIANT"
  fi
done
KERN_ARCH=`uname -m`
KERN_REV=`echo $UNAME | sed s/.$KERN_ARCH//` # strip arch from uname
CANDIDATES="$KERNEL-$KERN_REV.$KERN_ARCH \
  $KERNEL-devel-$KERN_REV.$KERN_ARCH \
  $KERNEL-debuginfo-$KERN_REV.$KERN_ARCH"
NEEDED=`rpm --qf "%{name}-%{version}-%{release}.%{arch}\n" \
    -q $CANDIDATES | grep "is not installed" | awk '{print $2}'`
if [ "$NEEDED" != "" ]; then
    echo -e "Need to install the following packages:\n$NEEDED"
    if [ `id -u` = "0" ]; then #attempt download and install
        DIR=`mktemp -d` || exit 1
        if [ ! -x /usr/bin/yumdownloader ]; then
            echo "Need to first install yum-utils for yumdownloader"
            yum install -y yum-utils
        fi
        yumdownloader --enablerepo="*debuginfo*" $NEEDED --destdir=$DIR \
                      --resolve
        check_error $? "problem downloading rpm(s) $NEEDED"
        rpm --force -ivh $DIR/*.rpm
        check_error $? "problem installing rpm(s) $NEEDED"
        rm -r $DIR #cleanup
    fi
fi