#!/bin/sh
KVER=`uname -r`
if [ -n "$1" ]; then
    KVER=$1
fi
DEBUG=''
if echo "$KVER" | grep -q debug; then
    KVER=`echo $KVER | sed -e s/debug//`
    DEBUG="-debug"
fi
# fc5 and fc6 support
if [ -e /etc/yum.repos.d/fedora-core.repo ]; then
    sudo yum -y --enablerepo=core-debuginfo --enablerepo=updates-debuginfo \
	install kernel${DEBUG}-debuginfo-$KVER kernel-debuginfo-common-$KVER
# fc7+ suport
elif [ -e /etc/yum.repos.d/fedora.repo ]; then
    if grep -qi rawhide /etc/redhat-release; then
	sudo yum -y --enablerepo=rawhide-debuginfo \
	    install kernel${DEBUG}-debuginfo-$KVER kernel-debuginfo-common-$KVER
    else
	sudo yum -y --enablerepo=fedora-debuginfo \
	    --enablerepo=updates-debuginfo --enablerepo=updates-newkey-debuginfo\
	    install kernel${DEBUG}-debuginfo-$KVER kernel-debuginfo-common-$KVER
    fi
# rhel5 support
elif [ -e /etc/yum.repos.d/rhel-debuginfo.repo ]; then
    sudo yum -y --enablerepo=rhel-debuginfo \
	install kernel${DEBUG}-debuginfo-$KVER kernel-debuginfo-common-$KVER
else
    echo "Error:  Don't know how to find debuginfo."
fi
