From 0ae7bbe74e2d2dddccddda40db6c2f8a04b53543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Fri, 12 Jun 2020 18:39:11 +0200 Subject: [PATCH] Fixed check for root device in grub config There is a code path that fixes the grub2-mkconfig used root device when building in an environment that does not allow to resolve the by-X path names, e.g an obs build worker without udev. For images that explicitly defines a root=... value in the kernelcmdline attribute the root device check was not called because the _get_root_cmdline_parameter method returns None. This commit fixes the method to return the expected root device in any case such that the grub2-mkconfig root device check has a chance to fix what grub2-mkconfig has created. This fixes bsc#1172928 --- kiwi/bootloader/config/base.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kiwi/bootloader/config/base.py b/kiwi/bootloader/config/base.py index 173f7355..ba4102ec 100644 --- a/kiwi/bootloader/config/base.py +++ b/kiwi/bootloader/config/base.py @@ -16,6 +16,7 @@ # along with kiwi. If not, see # import os +import re import logging from collections import namedtuple @@ -274,7 +275,7 @@ class BootLoaderConfigBase: if custom_cmdline: cmdline += ' ' + custom_cmdline custom_root = self._get_root_cmdline_parameter(uuid) - if custom_root: + if custom_root and custom_root not in cmdline: cmdline += ' ' + custom_root return cmdline.strip() @@ -548,7 +549,9 @@ class BootLoaderConfigBase: log.info( 'Kernel root device explicitly set via kernelcmdline' ) - return None + root_search = re.search(r'(root=(.*)[ ]+|root=(.*)$)', cmdline) + if root_search: + return root_search.group(1) want_root_cmdline_parameter = False if firmware and 'ec2' in firmware: