← Back to team overview

curtin-dev team mailing list archive

[Merge] ~dbungert/curtin:udi-513 into curtin:master

 

Dan Bungert has proposed merging ~dbungert/curtin:udi-513 into curtin:master.

Commit message:
The version of lsblk in Jammy, utils-linux 2.37.2,
has a modified output format from what curtin is expecting.
Normalize that format to the older style.
This appears to be the root cause for install failures of u-d-i
as reported in
https://github.com/canonical/ubuntu-desktop-installer/issues/513

Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/412027
-- 
Your team curtin developers is requested to review the proposed merge of ~dbungert/curtin:udi-513 into curtin:master.
diff --git a/curtin/block/__init__.py b/curtin/block/__init__.py
index 5046eb9..ca0bc10 100644
--- a/curtin/block/__init__.py
+++ b/curtin/block/__init__.py
@@ -227,6 +227,10 @@ def _lsblock_pairs_to_dict(lines):
         cur = {}
         for tok in toks:
             k, v = tok.split("=", 1)
+            if k == 'MAJ_MIN':
+                k = 'MAJ:MIN'
+            else:
+                k = k.replace('_', '-')
             cur[k] = v
         # use KNAME, as NAME may include spaces and other info,
         # for example, lvm decices may show 'dm0 lvm1'
diff --git a/tests/unittests/test_block.py b/tests/unittests/test_block.py
index 519628a..6d9b776 100644
--- a/tests/unittests/test_block.py
+++ b/tests/unittests/test_block.py
@@ -615,6 +615,69 @@ class TestNonAscii(CiTestCase):
         block.blkid()
 
 
+class TestLsblkNormalization(CiTestCase):
+    # In the Jammy timeframe, lsblk changed output such that column names
+    # that previously contained dashes now have underscores instead.
+    # _lsblk is expected to normalize this format to the dash style.
+    # MAJ:MIN was also changed to MAJ_MIN
+    # impish, and expected format:
+    #   ALIGNMENT="0" DISC-ALN="512" MAJ:MIN="252:0" ...
+    # jammy:
+    #   ALIGNMENT="0" DISC_ALN="512" MAJ_MIN="252:0" ...
+    expected = {
+        'vda': {
+            'ALIGNMENT': "0",
+            'DISC-ALN': "512",
+            'DISC-GRAN': "512",
+            'DISC-MAX': "2147483136",
+            'DISC-ZERO': "0",
+            'FSTYPE': "",
+            'GROUP': "disk",
+            'KNAME': "vda",
+            'LABEL': "",
+            'LOG-SEC': "512",
+            'MAJ:MIN': "252:0",
+            'MIN-IO': "512",
+            'MODE': "brw-rw----",
+            'MODEL': "",
+            'MOUNTPOINT': "",
+            'NAME': "vda",
+            'OPT-IO': "0",
+            'OWNER': "root",
+            'PHY-SEC': "512",
+            'RM': "0",
+            'RO': "0",
+            'ROTA': "1",
+            'RQ-SIZE': "256",
+            'SIZE': "12884901888",
+            'STATE': "",
+            'TYPE': "disk",
+            'UUID': "",
+            'device_path': '/dev/vda'
+        }
+    }
+
+    def test_lsblk_impish_style(self):
+        line = ('ALIGNMENT="0" DISC-ALN="512" DISC-GRAN="512" '
+                'DISC-MAX="2147483136" DISC-ZERO="0" FSTYPE="" GROUP="disk" '
+                'KNAME="vda" LABEL="" LOG-SEC="512" MAJ:MIN="252:0" '
+                'MIN-IO="512" MODE="brw-rw----" MODEL="" MOUNTPOINT="" '
+                'NAME="vda" OPT-IO="0" OWNER="root" PHY-SEC="512" RM="0" '
+                'RO="0" ROTA="1" RQ-SIZE="256" SIZE="12884901888" STATE="" '
+                'TYPE="disk" UUID=""')
+        self.assertEqual(self.expected, block._lsblock_pairs_to_dict(line))
+
+    def test_lsblk_jammy_style(self):
+        line = ('ALIGNMENT="0" DISC_ALN="512" DISC_GRAN="512" '
+                'DISC_MAX="2147483136" DISC_ZERO="0" FSTYPE="" GROUP="disk" '
+                'KNAME="vda" LABEL="" LOG_SEC="512" MAJ_MIN="252:0" '
+                'MIN_IO="512" MODE="brw-rw----" MODEL="" MOUNTPOINT="" '
+                'NAME="vda" OPT_IO="0" OWNER="root" PHY_SEC="512" RM="0" '
+                'RO="0" ROTA="1" RQ_SIZE="256" SIZE="12884901888" STATE="" '
+                'TYPE="disk" UUID=""')
+        self.assertEqual(self.expected, block._lsblock_pairs_to_dict(line))
+
+
 class TestSlaveKnames(CiTestCase):
 
     def setUp(self):

Follow ups