diff options
Diffstat (limited to 'scripts/lib/wic')
| -rw-r--r-- | scripts/lib/wic/ksparser.py | 20 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 20 | 
2 files changed, 32 insertions, 8 deletions
| diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py index a762d3b6cf..4ccd70dc55 100644 --- a/scripts/lib/wic/ksparser.py +++ b/scripts/lib/wic/ksparser.py | |||
| @@ -16,6 +16,7 @@ import os | |||
| 16 | import shlex | 16 | import shlex | 
| 17 | import logging | 17 | import logging | 
| 18 | import re | 18 | import re | 
| 19 | import uuid | ||
| 19 | 20 | ||
| 20 | from argparse import ArgumentParser, ArgumentError, ArgumentTypeError | 21 | from argparse import ArgumentParser, ArgumentError, ArgumentTypeError | 
| 21 | 22 | ||
| @@ -196,6 +197,7 @@ class KickStart(): | |||
| 196 | bootloader.add_argument('--configfile') | 197 | bootloader.add_argument('--configfile') | 
| 197 | bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'), | 198 | bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'), | 
| 198 | default='msdos') | 199 | default='msdos') | 
| 200 | bootloader.add_argument('--diskid') | ||
| 199 | bootloader.add_argument('--timeout', type=int) | 201 | bootloader.add_argument('--timeout', type=int) | 
| 200 | bootloader.add_argument('--source') | 202 | bootloader.add_argument('--source') | 
| 201 | 203 | ||
| @@ -296,6 +298,24 @@ class KickStart(): | |||
| 296 | if append_var: | 298 | if append_var: | 
| 297 | self.bootloader.append = ' '.join(filter(None, \ | 299 | self.bootloader.append = ' '.join(filter(None, \ | 
| 298 | (self.bootloader.append, append_var))) | 300 | (self.bootloader.append, append_var))) | 
| 301 | if parsed.diskid: | ||
| 302 | if parsed.ptable == "msdos": | ||
| 303 | try: | ||
| 304 | self.bootloader.diskid = int(parsed.diskid, 0) | ||
| 305 | except ValueError: | ||
| 306 | err = "with --ptbale msdos only 32bit integers " \ | ||
| 307 | "are allowed for --diskid. %s could not " \ | ||
| 308 | "be parsed" % self.ptable | ||
| 309 | raise KickStartError(err) | ||
| 310 | else: | ||
| 311 | try: | ||
| 312 | self.bootloader.diskid = uuid.UUID(parsed.diskid) | ||
| 313 | except ValueError: | ||
| 314 | err = "with --ptable %s only valid uuids are " \ | ||
| 315 | "allowed for --diskid. %s could not be " \ | ||
| 316 | "parsed" % (parsed.ptable, parsed.diskid) | ||
| 317 | raise KickStartError(err) | ||
| 318 | |||
| 299 | else: | 319 | else: | 
| 300 | err = "%s:%d: more than one bootloader specified" \ | 320 | err = "%s:%d: more than one bootloader specified" \ | 
| 301 | % (confpath, lineno) | 321 | % (confpath, lineno) | 
| diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index 6e1f1c8cba..ad922cfbf1 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,16 @@ 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 and ptable_format in ('gpt', 'gpt-hybrid'): | 
| 319 | self.disk_guid = disk_id | ||
| 320 | elif os.getenv('SOURCE_DATE_EPOCH'): | ||
| 321 | self.disk_guid = uuid.UUID(int=int(os.getenv('SOURCE_DATE_EPOCH'))) | ||
| 322 | else: | ||
| 323 | self.disk_guid = uuid.uuid4() | ||
| 324 | |||
| 325 | if disk_id and ptable_format == 'msdos': | ||
| 326 | self.identifier = disk_id | ||
| 327 | elif os.getenv('SOURCE_DATE_EPOCH'): | ||
| 319 | self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff) | 328 | self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff) | 
| 320 | else: | 329 | else: | 
| 321 | self.identifier = random.SystemRandom().randint(1, 0xffffffff) | 330 | self.identifier = random.SystemRandom().randint(1, 0xffffffff) | 
| @@ -543,11 +552,6 @@ class PartitionedImage(): | |||
| 543 | 552 | ||
| 544 | def _write_disk_guid(self): | 553 | def _write_disk_guid(self): | 
| 545 | if self.ptable_format in ('gpt', 'gpt-hybrid'): | 554 | if self.ptable_format in ('gpt', 'gpt-hybrid'): | 
| 546 | if os.getenv('SOURCE_DATE_EPOCH'): | ||
| 547 | self.disk_guid = uuid.UUID(int=int(os.getenv('SOURCE_DATE_EPOCH'))) | ||
| 548 | else: | ||
| 549 | self.disk_guid = uuid.uuid4() | ||
| 550 | |||
| 551 | logger.debug("Set disk guid %s", self.disk_guid) | 555 | logger.debug("Set disk guid %s", self.disk_guid) | 
| 552 | sfdisk_cmd = "sfdisk --sector-size %s --disk-id %s %s" % \ | 556 | sfdisk_cmd = "sfdisk --sector-size %s --disk-id %s %s" % \ | 
| 553 | (self.sector_size, self.path, self.disk_guid) | 557 | (self.sector_size, self.path, self.disk_guid) | 
