Skip to content

Instantly share code, notes, and snippets.

@alanivey
Last active March 7, 2017 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanivey/efd909473988a43aca686a1f785cf8bb to your computer and use it in GitHub Desktop.
Save alanivey/efd909473988a43aca686a1f785cf8bb to your computer and use it in GitHub Desktop.
kernel-devel from CentOS 7 Vault
#!/usr/bin/env bash
# /etc/yum.repos.d/CentOS-Vault.repo on a fully-updated 7.3 system contains repositories for 7.0.1406, 7.1.1503, 7.2.1511:
rpm -q kernel --queryformat '%{VERSION}-%{RELEASE}\n' \
| xargs -I{} yum --enablerepo="C7.?.????-base" --enablerepo="C7.?.????-updates" -y install "kernel-devel-{}"
#!/usr/bin/env bash
# If Vault repositories are not available, install kernel-devel directly:
for KVER in $( rpm -q kernel --queryformat '%{VERSION}-%{RELEASE}\n' ); do
if ! rpm -q "kernel-devel-${KVER}"; then
if [[ "$KVER" == 3.10.0-123.el7 ]]; then
KDURL="0.1406/os"
elif [[ "$KVER" =~ ^3\.10\.0-123\.[0-9\.]+\.el7$ ]]; then
KDURL="0.1406/updates"
elif [[ "$KVER" == 3.10.0-229.el7 ]]; then
KDURL="1.1503/os"
elif [[ "$KVER" =~ ^3\.10\.0-229\.[0-9\.]+\.el7$ ]]; then
KDURL="1.1503/updates"
elif [[ "$KVER" == 3.10.0-327.el7 ]]; then
KDURL="2.1511/os"
elif [[ "$KVER" =~ ^3\.10\.0-327\.[0-9\.]+\.el7$ ]]; then
KDURL="2.1511/updates"
fi
if [[ "$KDURL" ]]; then
yum -y install "http://vault.centos.org/7.${KDURL}/x86_64/Packages/kernel-devel-${KVER}.x86_64.rpm"
else
yum -y install "kernel-devel-${KVER}"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment