summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorSteffen Greber <sgreber@lilafast.org>2025-10-21 09:47:38 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-10-27 11:37:43 +0000
commit213d2989407b9d4f136dea93321c3ae9f29d8390 (patch)
tree4055873f6ca840191fa5d091d58ff6b864047ae2 /scripts/lib
parent06237fd316b3a123f20ee4f9a7fe73424be1f8ca (diff)
downloadpoky-213d2989407b9d4f136dea93321c3ae9f29d8390.tar.gz
wic: add option to specify the diskid
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. (From OE-Core rev: a31453fd52e0a52f3fa02cb9ae0878ea3782c2b7) 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>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/wic/ksparser.py1
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py8
2 files changed, 6 insertions, 3 deletions
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index a762d3b6cf..48b5b09ddd 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -196,6 +196,7 @@ class KickStart():
196 bootloader.add_argument('--configfile') 196 bootloader.add_argument('--configfile')
197 bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'), 197 bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'),
198 default='msdos') 198 default='msdos')
199 bootloader.add_argument('--diskid', type=lambda x: int(x, 0))
199 bootloader.add_argument('--timeout', type=int) 200 bootloader.add_argument('--timeout', type=int)
200 bootloader.add_argument('--source') 201 bootloader.add_argument('--source')
201 202
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 6e1f1c8cba..f40f033a3d 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -76,7 +76,7 @@ class DirectPlugin(ImagerPlugin):
76 break 76 break
77 77
78 image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") 78 image_path = self._full_path(self.workdir, self.parts[0].disk, "direct")
79 self._image = PartitionedImage(image_path, self.ptable_format, 79 self._image = PartitionedImage(image_path, self.ptable_format, self.ks.bootloader.diskid,
80 self.parts, self.native_sysroot, 80 self.parts, self.native_sysroot,
81 options.extra_space) 81 options.extra_space)
82 82
@@ -302,7 +302,7 @@ class PartitionedImage():
302 Partitioned image in a file. 302 Partitioned image in a file.
303 """ 303 """
304 304
305 def __init__(self, path, ptable_format, partitions, native_sysroot=None, extra_space=0): 305 def __init__(self, path, ptable_format, disk_id, partitions, native_sysroot=None, extra_space=0):
306 self.path = path # Path to the image file 306 self.path = path # Path to the image file
307 self.numpart = 0 # Number of allocated partitions 307 self.numpart = 0 # Number of allocated partitions
308 self.realpart = 0 # Number of partitions in the partition table 308 self.realpart = 0 # Number of partitions in the partition table
@@ -315,7 +315,9 @@ class PartitionedImage():
315 # all partitions (in bytes) 315 # all partitions (in bytes)
316 self.ptable_format = ptable_format # Partition table format 316 self.ptable_format = ptable_format # Partition table format
317 # Disk system identifier 317 # Disk system identifier
318 if os.getenv('SOURCE_DATE_EPOCH'): 318 if disk_id:
319 self.identifier = disk_id
320 elif os.getenv('SOURCE_DATE_EPOCH'):
319 self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff) 321 self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff)
320 else: 322 else:
321 self.identifier = random.SystemRandom().randint(1, 0xffffffff) 323 self.identifier = random.SystemRandom().randint(1, 0xffffffff)