diff mbox series

wic: use E2FSPROGS_FAKE_TIME and hash_seed to generate reproducible ext4 images

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

Commit Message

venkata.pyla@toshiba-tsip.com Dec. 12, 2023, 1:56 p.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 | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Khem Raj Dec. 15, 2023, 11:20 p.m. UTC | #1
I think a space is needed at the end of the string. We get into string
concatenation forning different element

| ERROR: _exec_cmd: export
PATH=/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-kiosk-image/1.0/recipe-sysroot-native/sbin:/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-kiosk-image/1.0/recipe-sysroot-native/usr/sbin:/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-kiosk-image/1.0/recipe-sysroot-native/usr/bin:/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-kiosk-image/1.0/recipe-sysroot-native/usr/bin/aarch64-yoe-linux:/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-kiosk-image/1.0/recipe-sysroot-native/bin:/mnt/b/yoe/master/build/tmp/hosttools:$PATH;export
E2FSPROGS_FAKE_TIME=1302044400;Nonemkfs.ext4 -F -i 8192 -E
hash_seed=a97814bc-a858-50e1-bb19-ddcf990c9d6e
/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-kiosk-image/1.0/tmp-wic/rootfs_boot.2.ext4
-L boot -U fc518f34-5d93-4088-98a4-0ec0bff70335 -d
/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-kiosk-image/1.0/tmp-wic/boot.2
returned '127' instead of 0
| output: /bin/sh: line 1: Nonemkfs.ext4: command not found


On Tue, Dec 12, 2023 at 5:56 AM Venkata Pyla
<venkata.pyla@toshiba-tsip.com> wrote:
>
> 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 | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
> index b1a2306dd1..8e2273ca2f 100644
> --- a/scripts/lib/wic/partition.py
> +++ b/scripts/lib/wic/partition.py
> @@ -284,6 +284,17 @@ class Partition():
>
>          extraopts = self.mkfs_extraopts or "-F -i 8192"
>
> +        if os.getenv('SOURCE_DATE_EPOCH'):
> +            sde_time = int(os.getenv('SOURCE_DATE_EPOCH'))
> +            pseudo = "export E2FSPROGS_FAKE_TIME=%s;%s" % (sde_time, pseudo)
> +
> +            # 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
> --
> 2.20.1
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#192192): https://lists.openembedded.org/g/openembedded-core/message/192192
> Mute This Topic: https://lists.openembedded.org/mt/103129684/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
venkata.pyla@toshiba-tsip.com Dec. 18, 2023, 4:12 a.m. UTC | #2
> -----Original Message-----
> From: Khem Raj <raj.khem@gmail.com>
> Sent: Saturday, December 16, 2023 4:50 AM
> To: pyla venkata(TSIP TMIEC ODG Porting) <Venkata.Pyla@toshiba-
> tsip.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH] wic: use E2FSPROGS_FAKE_TIME and hash_seed
> to generate reproducible ext4 images
> 
> I think a space is needed at the end of the string. We get into string concatenation
> forning different element

Thank you for pointing this out, I will send v2 patch with corrected

> 
> | ERROR: _exec_cmd: export
> PATH=/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-
> kiosk-image/1.0/recipe-sysroot-
> native/sbin:/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-
> linux/yoe-kiosk-image/1.0/recipe-sysroot-
> native/usr/sbin:/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-
> linux/yoe-kiosk-image/1.0/recipe-sysroot-
> native/usr/bin:/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-
> linux/yoe-kiosk-image/1.0/recipe-sysroot-native/usr/bin/aarch64-yoe-
> linux:/mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-
> kiosk-image/1.0/recipe-sysroot-
> native/bin:/mnt/b/yoe/master/build/tmp/hosttools:$PATH;export
> E2FSPROGS_FAKE_TIME=1302044400;Nonemkfs.ext4 -F -i 8192 -E
> hash_seed=a97814bc-a858-50e1-bb19-ddcf990c9d6e
> /mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-kiosk-
> image/1.0/tmp-wic/rootfs_boot.2.ext4
> -L boot -U fc518f34-5d93-4088-98a4-0ec0bff70335 -d
> /mnt/b/yoe/master/build/tmp/work/imx8qm_var_som-yoe-linux/yoe-kiosk-
> image/1.0/tmp-wic/boot.2
> returned '127' instead of 0
> | output: /bin/sh: line 1: Nonemkfs.ext4: command not found
> 
> 
> On Tue, Dec 12, 2023 at 5:56 AM Venkata Pyla <venkata.pyla@toshiba-tsip.com>
> wrote:
> >
> > 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 | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/scripts/lib/wic/partition.py
> > b/scripts/lib/wic/partition.py index b1a2306dd1..8e2273ca2f 100644
> > --- a/scripts/lib/wic/partition.py
> > +++ b/scripts/lib/wic/partition.py
> > @@ -284,6 +284,17 @@ class Partition():
> >
> >          extraopts = self.mkfs_extraopts or "-F -i 8192"
> >
> > +        if os.getenv('SOURCE_DATE_EPOCH'):
> > +            sde_time = int(os.getenv('SOURCE_DATE_EPOCH'))
> > +            pseudo = "export E2FSPROGS_FAKE_TIME=%s;%s" % (sde_time,
> > + pseudo)
> > +
> > +            # 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
> > --
> > 2.20.1
> >
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#192192):
> > https://lists.openembedded.org/g/openembedded-core/message/192192
> > Mute This Topic: https://lists.openembedded.org/mt/103129684/1997914
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
> > [raj.khem@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
diff mbox series

Patch

diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index b1a2306dd1..8e2273ca2f 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -284,6 +284,17 @@  class Partition():
 
         extraopts = self.mkfs_extraopts or "-F -i 8192"
 
+        if os.getenv('SOURCE_DATE_EPOCH'):
+            sde_time = int(os.getenv('SOURCE_DATE_EPOCH'))
+            pseudo = "export E2FSPROGS_FAKE_TIME=%s;%s" % (sde_time, pseudo)
+
+            # 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