Merge "Remove hard-coded path to grub binaries"
This commit is contained in:
commit
0fb3329a18
@ -108,12 +108,14 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None):
|
|||||||
|
|
||||||
# Add /bin to PATH variable as grub requires it to find efibootmgr
|
# Add /bin to PATH variable as grub requires it to find efibootmgr
|
||||||
# when running in uefi boot mode.
|
# when running in uefi boot mode.
|
||||||
|
# Add /usr/sbin to PATH variable to ensure it is there as we do
|
||||||
|
# not use full path to grub binary anymore.
|
||||||
path_variable = os.environ.get('PATH', '')
|
path_variable = os.environ.get('PATH', '')
|
||||||
path_variable = '%s:/bin' % path_variable
|
path_variable = '%s:/bin:/usr/sbin' % path_variable
|
||||||
|
|
||||||
# Install grub
|
# Install grub
|
||||||
utils.execute('chroot %(path)s /bin/sh -c '
|
utils.execute('chroot %(path)s /bin/sh -c '
|
||||||
'"/usr/sbin/%(bin)s-install %(dev)s"' %
|
'"%(bin)s-install %(dev)s"' %
|
||||||
{'path': path, 'bin': binary_name, 'dev': device},
|
{'path': path, 'bin': binary_name, 'dev': device},
|
||||||
shell=True, env_variables={'PATH': path_variable})
|
shell=True, env_variables={'PATH': path_variable})
|
||||||
# Also run grub-install with --removable, this installs grub to the
|
# Also run grub-install with --removable, this installs grub to the
|
||||||
@ -126,13 +128,13 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None):
|
|||||||
# prevents NVRAM from being updated.
|
# prevents NVRAM from being updated.
|
||||||
if efi_partition:
|
if efi_partition:
|
||||||
utils.execute('chroot %(path)s /bin/sh -c '
|
utils.execute('chroot %(path)s /bin/sh -c '
|
||||||
'"/usr/sbin/%(bin)s-install %(dev)s --removable"' %
|
'"%(bin)s-install %(dev)s --removable"' %
|
||||||
{'path': path, 'bin': binary_name, 'dev': device},
|
{'path': path, 'bin': binary_name, 'dev': device},
|
||||||
shell=True, env_variables={'PATH': path_variable})
|
shell=True, env_variables={'PATH': path_variable})
|
||||||
|
|
||||||
# Generate the grub configuration file
|
# Generate the grub configuration file
|
||||||
utils.execute('chroot %(path)s /bin/sh -c '
|
utils.execute('chroot %(path)s /bin/sh -c '
|
||||||
'"/usr/sbin/%(bin)s-mkconfig -o '
|
'"%(bin)s-mkconfig -o '
|
||||||
'/boot/%(bin)s/grub.cfg"' %
|
'/boot/%(bin)s/grub.cfg"' %
|
||||||
{'path': path, 'bin': binary_name}, shell=True,
|
{'path': path, 'bin': binary_name}, shell=True,
|
||||||
env_variables={'PATH': path_variable})
|
env_variables={'PATH': path_variable})
|
||||||
|
@ -87,14 +87,14 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
mock.call('mount', '-t', 'sysfs', 'none',
|
mock.call('mount', '-t', 'sysfs', 'none',
|
||||||
self.fake_dir + '/sys'),
|
self.fake_dir + '/sys'),
|
||||||
mock.call(('chroot %s /bin/sh -c '
|
mock.call(('chroot %s /bin/sh -c '
|
||||||
'"/usr/sbin/grub-install %s"' %
|
'"grub-install %s"' %
|
||||||
(self.fake_dir, self.fake_dev)), shell=True,
|
(self.fake_dir, self.fake_dev)), shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin:/usr/sbin'}),
|
||||||
mock.call(('chroot %s /bin/sh -c '
|
mock.call(('chroot %s /bin/sh -c '
|
||||||
'"/usr/sbin/grub-mkconfig -o '
|
'"grub-mkconfig -o '
|
||||||
'/boot/grub/grub.cfg"' % self.fake_dir),
|
'/boot/grub/grub.cfg"' % self.fake_dir),
|
||||||
shell=True,
|
shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin:/usr/sbin'}),
|
||||||
mock.call('umount', self.fake_dir + '/dev',
|
mock.call('umount', self.fake_dir + '/dev',
|
||||||
attempts=3, delay_on_retry=True),
|
attempts=3, delay_on_retry=True),
|
||||||
mock.call('umount', self.fake_dir + '/proc',
|
mock.call('umount', self.fake_dir + '/proc',
|
||||||
@ -132,18 +132,18 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
mock.call('mount', self.fake_efi_system_part,
|
mock.call('mount', self.fake_efi_system_part,
|
||||||
self.fake_dir + '/boot/efi'),
|
self.fake_dir + '/boot/efi'),
|
||||||
mock.call(('chroot %s /bin/sh -c '
|
mock.call(('chroot %s /bin/sh -c '
|
||||||
'"/usr/sbin/grub-install %s"' %
|
'"grub-install %s"' %
|
||||||
(self.fake_dir, self.fake_dev)), shell=True,
|
(self.fake_dir, self.fake_dev)), shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin:/usr/sbin'}),
|
||||||
mock.call(('chroot %s /bin/sh -c '
|
mock.call(('chroot %s /bin/sh -c '
|
||||||
'"/usr/sbin/grub-install %s --removable"' %
|
'"grub-install %s --removable"' %
|
||||||
(self.fake_dir, self.fake_dev)), shell=True,
|
(self.fake_dir, self.fake_dev)), shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin:/usr/sbin'}),
|
||||||
mock.call(('chroot %s /bin/sh -c '
|
mock.call(('chroot %s /bin/sh -c '
|
||||||
'"/usr/sbin/grub-mkconfig -o '
|
'"grub-mkconfig -o '
|
||||||
'/boot/grub/grub.cfg"' % self.fake_dir),
|
'/boot/grub/grub.cfg"' % self.fake_dir),
|
||||||
shell=True,
|
shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin:/usr/sbin'}),
|
||||||
mock.call('umount', self.fake_dir + '/boot/efi',
|
mock.call('umount', self.fake_dir + '/boot/efi',
|
||||||
attempts=3, delay_on_retry=True),
|
attempts=3, delay_on_retry=True),
|
||||||
mock.call('umount', self.fake_dir + '/dev',
|
mock.call('umount', self.fake_dir + '/dev',
|
||||||
@ -192,18 +192,18 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
mock.call('mount', self.fake_efi_system_part,
|
mock.call('mount', self.fake_efi_system_part,
|
||||||
self.fake_dir + '/boot/efi'),
|
self.fake_dir + '/boot/efi'),
|
||||||
mock.call(('chroot %s /bin/sh -c '
|
mock.call(('chroot %s /bin/sh -c '
|
||||||
'"/usr/sbin/grub-install %s"' %
|
'"grub-install %s"' %
|
||||||
(self.fake_dir, self.fake_dev)), shell=True,
|
(self.fake_dir, self.fake_dev)), shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin:/usr/sbin'}),
|
||||||
mock.call(('chroot %s /bin/sh -c '
|
mock.call(('chroot %s /bin/sh -c '
|
||||||
'"/usr/sbin/grub-install %s --removable"' %
|
'"grub-install %s --removable"' %
|
||||||
(self.fake_dir, self.fake_dev)), shell=True,
|
(self.fake_dir, self.fake_dev)), shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin:/usr/sbin'}),
|
||||||
mock.call(('chroot %s /bin/sh -c '
|
mock.call(('chroot %s /bin/sh -c '
|
||||||
'"/usr/sbin/grub-mkconfig -o '
|
'"grub-mkconfig -o '
|
||||||
'/boot/grub/grub.cfg"' % self.fake_dir),
|
'/boot/grub/grub.cfg"' % self.fake_dir),
|
||||||
shell=True,
|
shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin:/usr/sbin'}),
|
||||||
mock.call('umount', self.fake_dir + '/boot/efi',
|
mock.call('umount', self.fake_dir + '/boot/efi',
|
||||||
attempts=3, delay_on_retry=True)]
|
attempts=3, delay_on_retry=True)]
|
||||||
mock_execute.assert_has_calls(expected)
|
mock_execute.assert_has_calls(expected)
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Uses the PATH environment variable to get the grub (or grub2)
|
||||||
|
binary instead of assuming it is in /usr/sbin. This provides
|
||||||
|
flexibilty for grub to be installed in any PATH directory,
|
||||||
|
on a partitioned image.
|
Loading…
Reference in New Issue
Block a user