scripts: sd_fusing: support device symlinks in ensure_parttable() 39/312739/1
authorŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 13 Jun 2024 11:12:41 +0000 (13:12 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 13 Jun 2024 11:12:41 +0000 (13:12 +0200)
sd_fusing needs to support referring to devices by symlinks created by udev like
/dev/disk/by-id/usb-Generic_STORAGE_DEVICE_000000000272-0. Their partitions
are named /dev/disk/by-id/usb-Generic_STORAGE_DEVICE_000000000272-0-partX. Therefore
there is no universal way to access both /dev/sdXY and the symlinked
partitions and using get_partition_device() is the way to go.

Change-Id: I4c586f8e9b6e3940faa6055c90835bbff1777ec5
Fixes: 43ab41c7e7 ("sd_fusing.py: Ensure selected flashing target actually matches what is on device")
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
scripts/tizen/sd_fusing.py

index 8f57d15a8b7c247603dc0547bac4096844f6eabd..1996250aa6f31c7207778e37582750836d13cb24 100755 (executable)
@@ -15,7 +15,7 @@ import sys
 import tarfile
 import tempfile
 
-__version__ = "1.1.2"
+__version__ = "1.1.3"
 
 Format = False
 Device = ""
@@ -179,7 +179,8 @@ class SdFusingTarget:
     def ensure_parttable(self):
         logging.notice(f"Verifying that partition table on {Device} matches target specification")
         for partnum, part in enumerate(self.part_table, 1):
-            bo = subprocess.check_output(["blkid", "-o", "export", Device + str(partnum)]).decode('utf-8')
+            d = "/dev/" + get_partition_device(Device, partnum)
+            bo = subprocess.check_output(["blkid", "-o", "export", d]).decode('utf-8')
             if "PARTLABEL=" in bo and f"PARTLABEL={part['name']}" not in bo:
                 logging.error(f'On-device partition label mismatch with selected target: partlabel={part["name"]}, on-device:\n{bo}')
                 sys.exit(1)