Matthew Booth
2010-Apr-29 13:05 UTC
[Libguestfs] [PATCH] GuestOS: Fix augeas grub configuration
Augeas now configures the Grub lens for /boot/grub/menu.lst by default. The code which was checking this was broken in the case where there was more than 1 included path. We now check if /boot/grub/menu.lst is included. If it is, we don't reload. If it isn't, we add it, but don't remove any other config first. This fixes RHBZ#586822 --- lib/Sys/VirtV2V/GuestOS/RedHat.pm | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm b/lib/Sys/VirtV2V/GuestOS/RedHat.pm index 6dc4c95..a4680c5 100644 --- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm +++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm @@ -87,7 +87,7 @@ sub new bless($self, $class); $self->_init_selinux(); - $self->_init_augeas_modprobe(); + $self->_init_augeas(); return $self; } @@ -107,7 +107,7 @@ sub _init_selinux $g->touch('/.autorelabel'); } -sub _init_augeas_modprobe +sub _init_augeas { my $self = shift; @@ -158,15 +158,24 @@ sub _init_augeas_modprobe } } - # Remove all includes for the Grub lens, and add only - # /boot/grub/menu.lst + # Check if /boot/grub/menu.lst is included by the Grub lens + my $found = 0; foreach my $incl ($g->aug_match("/augeas/load/Grub/incl")) { - $g->aug_rm($incl); + if ($g->aug_get($incl) eq '/boot/grub/menu.lst') { + $found = 1; + last; + } + } + + # If it wasn't there, add it + unless ($found) { + $g->aug_set("/augeas/load/Grub/incl[last()+1]", + "/boot/grub/menu.lst"); + + # Make augeas pick up the new configuration + $g->aug_load(); } - $g->aug_set("/augeas/load/Grub/incl[last()+1]", "/boot/grub/menu.lst"); - # Make augeas pick up the new configuration - $g->aug_load(); }; # The augeas calls will die() on any error. -- 1.6.6.1
Richard W.M. Jones
2010-Apr-29 20:43 UTC
[Libguestfs] [PATCH] GuestOS: Fix augeas grub configuration
On Thu, Apr 29, 2010 at 02:05:13PM +0100, Matthew Booth wrote:> Augeas now configures the Grub lens for /boot/grub/menu.lst by default. The code > which was checking this was broken in the case where there was more than 1 > included path. > > We now check if /boot/grub/menu.lst is included. If it is, we don't reload. If > it isn't, we add it, but don't remove any other config first. > > This fixes RHBZ#586822ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
Reasonably Related Threads
- [PATCH] Rely on new augeas lens for modules.conf and conf.modules
- [PATCH] GuestOS: Update XF86Config or xorg.conf as appropriate
- [PATCH] Improve augeas error reporting
- [PATCH] GuestOS: Delete blkid.tab if it's present
- [PATCH] GuestOS: Fix error when checking for rpm which isn't installed