diff options
Diffstat (limited to 'scripts/lib/wic/partition.py')
-rw-r--r-- | scripts/lib/wic/partition.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py index 795707ec5d..bf2c34d594 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py | |||
@@ -284,19 +284,8 @@ class Partition(): | |||
284 | 284 | ||
285 | extraopts = self.mkfs_extraopts or "-F -i 8192" | 285 | extraopts = self.mkfs_extraopts or "-F -i 8192" |
286 | 286 | ||
287 | if os.getenv('SOURCE_DATE_EPOCH'): | 287 | # use hash_seed to generate reproducible ext4 images |
288 | sde_time = int(os.getenv('SOURCE_DATE_EPOCH')) | 288 | (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, pseudo) |
289 | if pseudo: | ||
290 | pseudo = "export E2FSPROGS_FAKE_TIME=%s;%s " % (sde_time, pseudo) | ||
291 | else: | ||
292 | pseudo = "export E2FSPROGS_FAKE_TIME=%s; " % sde_time | ||
293 | |||
294 | # Set hash_seed to generate deterministic directory indexes | ||
295 | namespace = uuid.UUID("e7429877-e7b3-4a68-a5c9-2f2fdf33d460") | ||
296 | if self.fsuuid: | ||
297 | namespace = uuid.UUID(self.fsuuid) | ||
298 | hash_seed = str(uuid.uuid5(namespace, str(sde_time))) | ||
299 | extraopts += " -E hash_seed=%s" % hash_seed | ||
300 | 289 | ||
301 | label_str = "" | 290 | label_str = "" |
302 | if self.label: | 291 | if self.label: |
@@ -344,6 +333,23 @@ class Partition(): | |||
344 | 333 | ||
345 | self.check_for_Y2038_problem(rootfs, native_sysroot) | 334 | self.check_for_Y2038_problem(rootfs, native_sysroot) |
346 | 335 | ||
336 | def get_hash_seed_ext4(self, extraopts, pseudo): | ||
337 | if os.getenv('SOURCE_DATE_EPOCH'): | ||
338 | sde_time = int(os.getenv('SOURCE_DATE_EPOCH')) | ||
339 | if pseudo: | ||
340 | pseudo = "export E2FSPROGS_FAKE_TIME=%s;%s " % (sde_time, pseudo) | ||
341 | else: | ||
342 | pseudo = "export E2FSPROGS_FAKE_TIME=%s; " % sde_time | ||
343 | |||
344 | # Set hash_seed to generate deterministic directory indexes | ||
345 | namespace = uuid.UUID("e7429877-e7b3-4a68-a5c9-2f2fdf33d460") | ||
346 | if self.fsuuid: | ||
347 | namespace = uuid.UUID(self.fsuuid) | ||
348 | hash_seed = str(uuid.uuid5(namespace, str(sde_time))) | ||
349 | extraopts += " -E hash_seed=%s" % hash_seed | ||
350 | |||
351 | return (extraopts, pseudo) | ||
352 | |||
347 | def prepare_rootfs_btrfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir, | 353 | def prepare_rootfs_btrfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir, |
348 | native_sysroot, pseudo): | 354 | native_sysroot, pseudo): |
349 | """ | 355 | """ |
@@ -437,13 +443,16 @@ class Partition(): | |||
437 | 443 | ||
438 | extraopts = self.mkfs_extraopts or "-i 8192" | 444 | extraopts = self.mkfs_extraopts or "-i 8192" |
439 | 445 | ||
446 | # use hash_seed to generate reproducible ext4 images | ||
447 | (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, None) | ||
448 | |||
440 | label_str = "" | 449 | label_str = "" |
441 | if self.label: | 450 | if self.label: |
442 | label_str = "-L %s" % self.label | 451 | label_str = "-L %s" % self.label |
443 | 452 | ||
444 | mkfs_cmd = "mkfs.%s -F %s %s -U %s %s" % \ | 453 | mkfs_cmd = "mkfs.%s -F %s %s -U %s %s" % \ |
445 | (self.fstype, extraopts, label_str, self.fsuuid, rootfs) | 454 | (self.fstype, extraopts, label_str, self.fsuuid, rootfs) |
446 | exec_native_cmd(mkfs_cmd, native_sysroot) | 455 | exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) |
447 | 456 | ||
448 | self.check_for_Y2038_problem(rootfs, native_sysroot) | 457 | self.check_for_Y2038_problem(rootfs, native_sysroot) |
449 | 458 | ||