1
0
Fork 0

bootloader: Don't add nonexistent overlay image to grub.cfg

Resolves: rhbz#1454340

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
This commit is contained in:
Ondřej Lysoněk 2017-08-16 09:59:35 +02:00
parent a83170deb7
commit 750530de2e
2 changed files with 7 additions and 2 deletions

View file

@ -188,7 +188,8 @@ class BootloaderPlugin(base.Plugin):
def _install_initrd(self, img):
log.info("installing initrd image as '%s'" % self._initrd_dst_img_val)
img_name = os.path.basename(self._initrd_dst_img_val)
self._cmd.copy(img, self._initrd_dst_img_val)
if not self._cmd.copy(img, self._initrd_dst_img_val):
return False
self.update_grub2_cfg = True
curr_cmdline = self._cmd.read_file("/proc/cmdline").rstrip()
initrd_grubpath = "/"
@ -198,6 +199,7 @@ class BootloaderPlugin(base.Plugin):
if len(path) < lc:
initrd_grubpath = path
self._initrd_val = os.path.join(initrd_grubpath, img_name)
return True
@command_custom("grub2_cfg_file")
def _grub2_cfg_file(self, enabling, value, verify, ignore_missing):
@ -237,7 +239,8 @@ class BootloaderPlugin(base.Plugin):
self._init_initrd_dst_img(src_img)
if src_img == "":
return False
self._install_initrd(src_img)
if not self._install_initrd(src_img):
return False
@command_custom("initrd_add_dir", per_device = False, priority = 10)
def _initrd_add_dir(self, enabling, value, verify, ignore_missing):

View file

@ -158,9 +158,11 @@ class commands:
try:
log.debug("copying file '%s' to '%s'" % (src, dst))
shutil.copy(src, dst)
return True
except IOError as e:
if not no_error:
log.error("cannot copy file '%s' to '%s': %s" % (src, dst, e))
return False
def replace_in_file(self, f, pattern, repl):
data = self.read_file(f)