← Back to team overview

curtin-dev team mailing list archive

[Merge] ~raharper/curtin:fix/multiple-carry-over-param-separators into curtin:master

 

Ryan Harper has proposed merging ~raharper/curtin:fix/multiple-carry-over-param-separators into curtin:master.

Commit message:
Handle multiple separators which were found in TestAllindata vmtest

TestAllindata specifies additional kernel args and include the '---'
separator. vmtest baseclass already includes a '---' and after landing of the
grub refactor, the python version of of get_carryover_params did not handle
the additional '---'.  Fix this by combining any args after the first '---'
separator.

Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~raharper/curtin/+git/curtin/+merge/384469
-- 
Your team curtin developers is requested to review the proposed merge of ~raharper/curtin:fix/multiple-carry-over-param-separators into curtin:master.
diff --git a/curtin/commands/install_grub.py b/curtin/commands/install_grub.py
index 11ffd55..777aa35 100644
--- a/curtin/commands/install_grub.py
+++ b/curtin/commands/install_grub.py
@@ -119,14 +119,19 @@ def get_carryover_params(distroinfo):
     def wrap(sep):
         return ' ' + sep + ' '
 
+    sections = []
     if wrap(preferred_sep) in cmdline:
-        lead, extra = cmdline.split(wrap(preferred_sep))
+        sections = cmdline.split(wrap(preferred_sep))
     elif wrap(legacy_sep) in cmdline:
-        lead, extra = cmdline.split(wrap(legacy_sep))
+        sections = cmdline.split(wrap(legacy_sep))
     else:
         extra = ""
         lead = cmdline
 
+    if sections:
+        lead = sections[0]
+        extra = " ".join(sections[1:])
+
     carry_extra = []
     if extra:
         for tok in extra.split():
diff --git a/tests/unittests/test_commands_install_grub.py b/tests/unittests/test_commands_install_grub.py
index 1d0c43f..8808159 100644
--- a/tests/unittests/test_commands_install_grub.py
+++ b/tests/unittests/test_commands_install_grub.py
@@ -181,7 +181,7 @@ class TestGetCarryoverParams(CiTestCase):
         self.m_load_file.return_value = cmdline
         self.assertEqual([], install_grub.get_carryover_params(distroinfo))
 
-    def test_legacy_seporator(self):
+    def test_legacy_separator(self):
         distroinfo = install_grub.distro.get_distroinfo()
         sep = '--'
         expected_carry_params = ['foo=bar', 'debug=1']
@@ -191,7 +191,7 @@ class TestGetCarryoverParams(CiTestCase):
         self.assertEqual(expected_carry_params,
                          install_grub.get_carryover_params(distroinfo))
 
-    def test_preferred_seporator(self):
+    def test_preferred_separator(self):
         distroinfo = install_grub.distro.get_distroinfo()
         sep = '---'
         expected_carry_params = ['foo=bar', 'debug=1']
@@ -201,6 +201,15 @@ class TestGetCarryoverParams(CiTestCase):
         self.assertEqual(expected_carry_params,
                          install_grub.get_carryover_params(distroinfo))
 
+    def test_multiple_preferred_separator(self):
+        distroinfo = install_grub.distro.get_distroinfo()
+        sep = '---'
+        expected_carry_params = ['extra', 'additional']
+        cmdline = "lead=args %s extra %s additional" % (sep, sep)
+        self.m_load_file.return_value = cmdline
+        self.assertEqual(expected_carry_params,
+                         install_grub.get_carryover_params(distroinfo))
+
     def test_drop_bootif_initrd_boot_image_from_extra(self):
         distroinfo = install_grub.distro.get_distroinfo()
         sep = '---'

Follow ups