]>
Commit | Line | Data |
---|---|---|
3266a355 WC |
1 | #! /bin/bash |
2 | check_error() { if test $1 != 0; then echo $2; exit $1; fi } | |
3266a355 | 3 | |
6f6a731f MW |
4 | # uname -r can produce different kinds of output: |
5 | # 2.6.32-30.el6.x86_64 (no variant, but including ".arch") | |
6 | # 2.6.18-194.3.1.el5debug ("variant", without dot, no arch) | |
7 | # 2.6.33.4-95.fc13.i686.PAE (".arch.variant", two dots) | |
3266a355 WC |
8 | if [ "$#" -lt 1 ]; then |
9 | UNAME=`uname -r` # determine the kernel running on the machine | |
10 | else | |
11 | UNAME=$1 #user passed in uname value | |
12 | fi | |
13 | UNAME=`echo $UNAME | sed "s/ //"` #strip out any whitespace | |
14 | KERNEL="kernel" | |
15 | for VARIANT in debug kdump PAE xen; do | |
6f6a731f MW |
16 | # strip out ".variant" or else "variant" at end. |
17 | TMP=`echo $UNAME | sed s/\\\\.$VARIANT\$// | sed s/$VARIANT\$//` | |
3266a355 WC |
18 | if [ "$TMP" != "$UNAME" ]; then |
19 | UNAME=$TMP; KERNEL="kernel-$VARIANT" | |
20 | fi | |
21 | done | |
22 | KERN_ARCH=`uname -m` | |
23 | KERN_REV=`echo $UNAME | sed s/.$KERN_ARCH//` # strip arch from uname | |
ca8bf77e WC |
24 | CANDIDATES="$KERNEL-$KERN_REV.$KERN_ARCH \ |
25 | $KERNEL-devel-$KERN_REV.$KERN_ARCH \ | |
928c149c | 26 | $KERNEL-debuginfo-$KERN_REV.$KERN_ARCH" |
ca8bf77e WC |
27 | NEEDED=`rpm --qf "%{name}-%{version}-%{release}.%{arch}\n" \ |
28 | -q $CANDIDATES | grep "is not installed" | awk '{print $2}'` | |
3266a355 WC |
29 | if [ "$NEEDED" != "" ]; then |
30 | echo -e "Need to install the following packages:\n$NEEDED" | |
31 | if [ `id -u` = "0" ]; then #attempt download and install | |
ca8bf77e | 32 | DIR=`mktemp -d` || exit 1 |
601f4c5a MW |
33 | if [ ! -x /usr/bin/yumdownloader ]; then |
34 | echo "Need to first install yum-utils for yumdownloader" | |
35 | yum install -y yum-utils | |
36 | fi | |
928c149c MW |
37 | yumdownloader --enablerepo="*debuginfo*" $NEEDED --destdir=$DIR \ |
38 | --resolve | |
ca8bf77e WC |
39 | check_error $? "problem downloading rpm(s) $NEEDED" |
40 | rpm --force -ivh $DIR/*.rpm | |
41 | check_error $? "problem installing rpm(s) $NEEDED" | |
42 | rm -r $DIR #cleanup | |
3266a355 WC |
43 | fi |
44 | fi |