diff mbox series

[v2] wic: use E2FSPROGS_FAKE_TIME and hash_seed to generate reproducible ext4 images

Message ID 20231218043030.32027-1-venkata.pyla@toshiba-tsip.com
State Accepted, archived
Commit bb822ab75de0020572058090439b93cc56bbf7e0
Headers show
Series [v2] wic: use E2FSPROGS_FAKE_TIME and hash_seed to generate reproducible ext4 images | expand

Commit Message

venkata.pyla@toshiba-tsip.com Dec. 18, 2023, 4:30 a.m. UTC
From: venkata pyla <venkata.pyla@toshiba-tsip.com>

E2FSPROGS_FAKE_TIME: sets fixed times for the inodes in the file system.
hash_seed: creates reproducible directory indexes in the file system.

Reference commit in e2fsprogs: e1f7100643a46456be107b33098f6034b0835e6d

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
---
 scripts/lib/wic/partition.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index b1a2306dd1..795707ec5d 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -284,6 +284,20 @@  class Partition():
 
         extraopts = self.mkfs_extraopts or "-F -i 8192"
 
+        if os.getenv('SOURCE_DATE_EPOCH'):
+            sde_time = int(os.getenv('SOURCE_DATE_EPOCH'))
+            if pseudo:
+                pseudo = "export E2FSPROGS_FAKE_TIME=%s;%s " % (sde_time, pseudo)
+            else:
+                pseudo = "export E2FSPROGS_FAKE_TIME=%s; " % sde_time
+
+            # Set hash_seed to generate deterministic directory indexes
+            namespace = uuid.UUID("e7429877-e7b3-4a68-a5c9-2f2fdf33d460")
+            if self.fsuuid:
+                namespace = uuid.UUID(self.fsuuid)
+            hash_seed = str(uuid.uuid5(namespace, str(sde_time)))
+            extraopts += " -E hash_seed=%s" % hash_seed
+
         label_str = ""
         if self.label:
             label_str = "-L %s" % self.label