From 99719a3712a88dce8450994d995803e126e49115 Mon Sep 17 00:00:00 2001 From: Sergei Zhmylev Date: Fri, 21 Oct 2022 17:56:22 +0300 Subject: wic: honor the SOURCE_DATE_EPOCH in case of updated fstab 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. Signed-off-by: Sergei Zhmylev Signed-off-by: Alexandre Belloni --- scripts/lib/wic/plugins/imager/direct.py | 3 +++ scripts/lib/wic/plugins/source/rootfs.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/lib/wic/plugins') diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index 6faa16bf9b..58965b75da 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 fc06312ee4..e29f3a4c2f 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: -- cgit 1.2.3-korg