]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
wic: add option to specify the diskid
authorSteffen Greber <sgreber@lilafast.org>
Tue, 21 Oct 2025 09:47:38 +0000 (09:47 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 27 Oct 2025 11:37:39 +0000 (11:37 +0000)
This adds a feature to specify the disk ID when creating a disk with
the wic tool. This is useful when using the DOS partition scheme and
booting with root=PARTUUID=<partuuid>. In DOS partitions, the partition
ID is <diskid>-<partition-number>, so it makes sense to let the user
define the disk ID.

You can specify it in the kickstart file using the --diskid argument
to the bootloader command. The value can be given in decimal or
hexadecimal format (e.g. 3735928559 or 0xdeadbeef). If omitted, the
previous behaviour does not change.

Signed-off-by: Steffen Greber <sgreber@lilafast.org>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/wic/ksparser.py
scripts/lib/wic/plugins/imager/direct.py

index a762d3b6cf4c53d42c4de480f3dfe3fd062eb0f8..48b5b09ddd16dc3d18002e04bbf84a40128228b2 100644 (file)
@@ -196,6 +196,7 @@ class KickStart():
         bootloader.add_argument('--configfile')
         bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'),
                                 default='msdos')
+        bootloader.add_argument('--diskid', type=lambda x: int(x, 0))
         bootloader.add_argument('--timeout', type=int)
         bootloader.add_argument('--source')
 
index 6e1f1c8cba50e86a41ce06d1379e702d748a7e25..f40f033a3d2d5367540c3466a03616eae742e2bf 100644 (file)
@@ -76,7 +76,7 @@ class DirectPlugin(ImagerPlugin):
                 break
 
         image_path = self._full_path(self.workdir, self.parts[0].disk, "direct")
-        self._image = PartitionedImage(image_path, self.ptable_format,
+        self._image = PartitionedImage(image_path, self.ptable_format, self.ks.bootloader.diskid,
                                        self.parts, self.native_sysroot,
                                        options.extra_space)
 
@@ -302,7 +302,7 @@ class PartitionedImage():
     Partitioned image in a file.
     """
 
-    def __init__(self, path, ptable_format, partitions, native_sysroot=None, extra_space=0):
+    def __init__(self, path, ptable_format, disk_id, partitions, native_sysroot=None, extra_space=0):
         self.path = path  # Path to the image file
         self.numpart = 0  # Number of allocated partitions
         self.realpart = 0 # Number of partitions in the partition table
@@ -315,7 +315,9 @@ class PartitionedImage():
                           # all partitions (in bytes)
         self.ptable_format = ptable_format  # Partition table format
         # Disk system identifier
-        if os.getenv('SOURCE_DATE_EPOCH'):
+        if disk_id:
+            self.identifier = disk_id
+        elif os.getenv('SOURCE_DATE_EPOCH'):
             self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff)
         else:
             self.identifier = random.SystemRandom().randint(1, 0xffffffff)