From 8349f0350ea635e49e42cf8788cd4759d0e0a890 Mon Sep 17 00:00:00 2001 From: Evgeny Antyshev Date: Mon, 10 Aug 2015 12:17:04 +0000 Subject: [PATCH] Remove grub2 in redhat-common/pre-install.d/15-remove-grub In Id1e430e7d050a0b99ac449e2ea435e06cda1c4e6 I made the mistake of not actually removing grub in 15-remove-grub. This restores the removal phase and adds a bunch of comments. It seems the centos7 and centos (6) images have grub2 installed, but F22 does not; hence the check. For anyone interested in the history; it seems the whole idea of removing grub and re-installing it in the finalise stage is to do with Ubuntu grub scripts failing in the chroot. It is not clear this does, or has ever, affected rpm based systems; but that's how it is, so leave well enough alone. The whole reasoning behind the rpm download & re-install is actually explained in If095adc4abb52a19a3aa0b1caebfb3e4d8f605ef, but over time the comments got lost as code moved around. I've restored in here some detailed explaination of why we don't just re-install the package "normally". I've also added a note to the pre-install of various things that are related to this step. Again I think there are some questions around this that we can investigate in another change. Change-Id: I1acd19da8567ab93b5003caf67673cc70efea5fa --- elements/redhat-common/package-installs.yaml | 3 ++ .../pre-install.d/15-remove-grub | 30 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/elements/redhat-common/package-installs.yaml b/elements/redhat-common/package-installs.yaml index 71e5f517..025158f1 100644 --- a/elements/redhat-common/package-installs.yaml +++ b/elements/redhat-common/package-installs.yaml @@ -6,6 +6,9 @@ traceroute: which: gettext: phase: pre-install.d + +# these are being installed to satisfy the dependencies of grub2. See +# 15-remove-grub for more details grub2-tools: phase: pre-install.d os-prober: diff --git a/elements/redhat-common/pre-install.d/15-remove-grub b/elements/redhat-common/pre-install.d/15-remove-grub index 21ab6815..f116a852 100755 --- a/elements/redhat-common/pre-install.d/15-remove-grub +++ b/elements/redhat-common/pre-install.d/15-remove-grub @@ -15,7 +15,33 @@ 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 +# remove grub2 package. As described in +# elements/ubuntu/pre-install.d/00-remove-grub; the grub post-kernel +# install hook will barf if the block device can't be found (as +# happens in a chroot). +# +# XXX : it is not clear this is necessary for fedora/centos7 and it's +# install hooks. Investigation is required. +if rpm -q grub2; then + install-packages -e grub2 +fi + +# now configure things to re-install grub at the end. We don't want +# to rely on vm/finalise.d/51-bootloader to simply reinstall the +# package via the package-manager, because at that point (during +# finalise) the build-time yum-cache has been unmounted (hence the +# local-cache looks empty) and yum may try to repopulate the +# local-cache with all the grub2 dependencies. This is slow, and +# potentially fills up the disk. +# +# XXX : At this point, keepcache=0 *should* probably be set for +# yum/dnf. We have not standarised/documented that this will be done, +# however. This would *probably* stop dependencies being populated +# into the cache. We could investigate this, and possibly remove this +# all together if we standardise some of these behaviours. + +# So we download the latest grub2 package and setup the install script +# to just install the single-package, 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