← Back to team overview

curtin-dev team mailing list archive

[Merge] ~mwhudson/curtin:lp-1899699 into curtin:master

 

Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:lp-1899699 into curtin:master.

Commit message:
fix udevadm_info in the face of udev database values having "=" in them

LP: #1899699

Requested reviews:
  curtin developers (curtin-dev)
Related bugs:
  Bug #1899699 in curtin: "udevadm_info() fails if any value contains "=""
  https://bugs.launchpad.net/curtin/+bug/1899699

For more details, see:
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/392197
-- 
Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:lp-1899699 into curtin:master.
diff --git a/curtin/udev.py b/curtin/udev.py
index f83f216..2b7a46e 100644
--- a/curtin/udev.py
+++ b/curtin/udev.py
@@ -90,9 +90,9 @@ def udevadm_info(path=None):
     for line in output.splitlines():
         if not line:
             continue
-        # maxsplit=2 gives us key and remaininng part of line is value
+        # maxsplit=1 gives us key and remaininng part of line is value
         # py2.7 on Trusty doesn't have keyword, pass as argument
-        key, value = line.split('=', 2)
+        key, value = line.split('=', 1)
         if not value:
             value = None
         if value:
diff --git a/tests/unittests/test_udev.py b/tests/unittests/test_udev.py
index 919c7c0..dcab288 100644
--- a/tests/unittests/test_udev.py
+++ b/tests/unittests/test_udev.py
@@ -18,7 +18,7 @@ DEVPATH='/devices/pci0000:00/0000:00:1c.4/0000:05:00.0/nvme/nvme0/nvme0n1'
 DEVTYPE='disk'
 ID_PART_TABLE_TYPE='gpt'
 ID_PART_TABLE_UUID='ea0b9ddc-a114-4e01-b257-750d86e3a944'
-ID_SERIAL='SAMSUNG MZVLB1T0HALR-000L7_S3TPNY0JB00151'
+ID_SERIAL='SAMSUNG=MZVLB1T0HALR-000L7_S3TPNY0JB00151'
 ID_SERIAL_SHORT='S3TPNY0JB00151'
 MAJOR='259'
 MINOR='0'
@@ -36,7 +36,7 @@ INFO_DICT = {
     'DEVTYPE': 'disk',
     'ID_PART_TABLE_TYPE': 'gpt',
     'ID_PART_TABLE_UUID': 'ea0b9ddc-a114-4e01-b257-750d86e3a944',
-    'ID_SERIAL': 'SAMSUNG MZVLB1T0HALR-000L7_S3TPNY0JB00151',
+    'ID_SERIAL': 'SAMSUNG=MZVLB1T0HALR-000L7_S3TPNY0JB00151',
     'ID_SERIAL_SHORT': 'S3TPNY0JB00151',
     'MAJOR': '259',
     'MINOR': '0',

References