diskimage-builder/elements/redhat-common/pre-install.d/15-remove-grub
Ian Wienand e42066d685 Cleanup yum downloading
Using "yum --downloadonly" breaks the abstraction of
"install-packages" because it downloads to the yum cache.  It also
acts funny if the package is already there.

Add an argument to "-d" which is the directory to download to.  dnf
has "download" built in, and for the old case use yumdownloader which
acts about the same.  Ensure it is installed, since it comes in
yum-utils.

Also a slight cleanup of the getopt parsing so it's easier to have the
required argument for -d

Thus we can remove most of the stuff in 15-remove-grub.  The check for
centos6 and it's lack of grub2 is clarified.  All the stuff about
having to remove the package, purging the cache etc so yum gets the
right thing is no longer relevant.  The long section of commented out
code at the end is also removed for clarity.

I tested this with an F21, F22 & centos (6) build

Change-Id: Id1e430e7d050a0b99ac449e2ea435e06cda1c4e6
2015-07-20 09:08:06 +10:00

22 lines
695 B
Bash
Executable File

#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# grub2 isn't available on rhel6/centos6; they are setup to use
# extlinux. skip this
# you would think we could match on $DISTRO or something else; but
# we can't because the rhel/centos elements are a bit mixed up;
# centos-minimal for example sets distro to "centos". so the best
# check is just for the original "grub-install" script
if [ -f /sbin/grub-install ]; then
exit 0
fi
# download the latest grub2 package and setup the install script which
# will be called later by vm/finalise.d/51-bootloader
install-packages -d /tmp/grub grub2
echo "rpm -i /tmp/grub/*.rpm" > /tmp/grub/install