public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: venkata.pyla@toshiba-tsip.com
To: isar-users@googlegroups.com
Cc: venkata pyla <venkata.pyla@toshiba-tsip.com>,
	jan.kiszka@siemens.com, kazuhiro3.hayashi@toshiba.co.jp,
	dinesh.kumar@toshiba-tsip.com, felix.moessbauer@siemens.com
Subject: [PATCH 4/5] wic: honor the SOURCE_DATE_EPOCH in case of updated fstab
Date: Thu,  7 Dec 2023 21:11:13 +0530	[thread overview]
Message-ID: <20231207154114.20400-5-venkata.pyla@toshiba-tsip.com> (raw)
In-Reply-To: <20231207154114.20400-1-venkata.pyla@toshiba-tsip.com>

From: venkata pyla <venkata.pyla@toshiba-tsip.com>

In case user requested to build a binary repeatable package,
it's required to honor the SOURCE_DATE_EPOCH environment
variable. So forcefully set mtime inside all the routines
which modify fstab in case it is updated.

Taken from openembedded-core: 99719a3712a88dce8450994d995803e126e49115

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
---
 scripts/lib/wic/partition.py             | 7 ++++++-
 scripts/lib/wic/plugins/imager/direct.py | 3 +++
 scripts/lib/wic/plugins/source/rootfs.py | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 90b2c037..44b1277e 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -305,6 +305,11 @@ class Partition():
                 f.write("cd etc\n")
                 f.write("rm fstab\n")
                 f.write("write %s fstab\n" % (self.updated_fstab_path))
+                if os.getenv('SOURCE_DATE_EPOCH'):
+                    fstab_time = int(os.getenv('SOURCE_DATE_EPOCH'))
+                    for time in ["atime", "mtime", "ctime"]:
+                        f.write("set_inode_field fstab %s %s\n" % (time, hex(fstab_time)))
+                        f.write("set_inode_field fstab %s_extra 0\n" % (time))
             debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs)
             exec_native_cmd(debugfs_cmd, native_sysroot)
 
@@ -364,7 +369,7 @@ class Partition():
         exec_native_cmd(mcopy_cmd, native_sysroot)
 
         if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update:
-            mcopy_cmd = "mcopy -i %s %s ::/etc/fstab" % (rootfs, self.updated_fstab_path)
+            mcopy_cmd = "mcopy -m -i %s %s ::/etc/fstab" % (rootfs, self.updated_fstab_path)
             exec_native_cmd(mcopy_cmd, native_sysroot)
 
         chmod_cmd = "chmod 644 %s" % rootfs
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index c44159b2..4d8f9216 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -149,6 +149,9 @@ class DirectPlugin(ImagerPlugin):
             self.updated_fstab_path = os.path.join(self.workdir, "fstab")
             with open(self.updated_fstab_path, "w") as f:
                 f.writelines(fstab_lines)
+            if os.getenv('SOURCE_DATE_EPOCH'):
+                fstab_time = int(os.getenv('SOURCE_DATE_EPOCH'))
+                os.utime(self.updated_fstab_path, (fstab_time, fstab_time))
 
     def _full_path(self, path, name, extention):
         """ Construct full file path to a file we generate. """
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index fc06312e..e29f3a4c 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -224,7 +224,7 @@ class RootfsPlugin(SourcePlugin):
             if part.update_fstab_in_rootfs and part.has_fstab and not part.no_fstab_update:
                 fstab_path = os.path.join(new_rootfs, "etc/fstab")
                 # Assume that fstab should always be owned by root with fixed permissions
-                install_cmd = "install -m 0644 %s %s" % (part.updated_fstab_path, fstab_path)
+                install_cmd = "install -m 0644 -p %s %s" % (part.updated_fstab_path, fstab_path)
                 if new_pseudo:
                     pseudo = cls.__get_pseudo(native_sysroot, new_rootfs, new_pseudo)
                 else:
-- 
2.20.1



  parent reply	other threads:[~2023-12-07 15:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AQHaKSPYp2dXzOOhJUivzLFOKAgd4rF2a70A>
2023-12-07 15:41 ` [PATCH 0/5] Make ext4 images reproducible venkata.pyla
2023-12-07 15:41   ` [PATCH 1/5] linux-module: Use debug-prefix-map to build modules deterministically venkata.pyla
2023-12-08 10:27     ` MOESSBAUER, Felix
2023-12-07 15:41   ` [PATCH 2/5] wic: Set file system uuid to ext4 partitions venkata.pyla
2023-12-07 15:41   ` [PATCH 3/5] wic: use E2FSPROGS_FAKE_TIME and hash_seed to generate reproducible ext4 images venkata.pyla
2023-12-08 10:33     ` MOESSBAUER, Felix
2023-12-08 18:14       ` Venkata.Pyla
2023-12-09 11:07         ` Florian Bezdeka
2023-12-12 14:06           ` Venkata.Pyla
2023-12-28  6:02             ` Venkata.Pyla
2023-12-28  8:47               ` Florian Bezdeka
2023-12-28 10:10                 ` Anton Mikanovich
2024-03-13 10:01                   ` Adithya.Balakumar
2024-03-13 16:00                     ` Anton Mikanovich
2024-03-14  4:37                       ` Adithya.Balakumar
2024-04-25  6:24                       ` MOESSBAUER, Felix
2024-04-25  6:30                         ` Jan Kiszka
2024-04-25  7:02                           ` MOESSBAUER, Felix
2024-04-26  8:58                         ` Anton Mikanovich
2024-04-23  9:17     ` MOESSBAUER, Felix
2024-07-05 12:13       ` Adithya Balakumar
2024-07-08 10:43         ` 'MOESSBAUER, Felix' via isar-users
     [not found]           ` <CAM=oSXcw+sH3VYsstvDmRbLTK-H0ncFEbuqOhG2R0_P4bUYXjw@mail.gmail.com>
2024-07-08 11:12             ` Adithya.Balakumar
2023-12-07 15:41   ` venkata.pyla [this message]
2023-12-07 15:41   ` [PATCH 5/5] wic: make ext2/3/4 images reproducible venkata.pyla
2023-12-08 10:29   ` [PATCH 0/5] Make ext4 " MOESSBAUER, Felix
2023-12-08 18:12     ` Venkata.Pyla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231207154114.20400-5-venkata.pyla@toshiba-tsip.com \
    --to=venkata.pyla@toshiba-tsip.com \
    --cc=dinesh.kumar@toshiba-tsip.com \
    --cc=felix.moessbauer@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kazuhiro3.hayashi@toshiba.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox