diff options
author | Sergei Zhmylev <s.zhmylev@yadro.com> | 2022-10-21 17:56:22 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-11-09 17:42:14 +0000 |
commit | d051fc188b6106bd72ba8baba6b5d2439349308c (patch) | |
tree | 290235385746e08c8843fefa0e445aefdcee92b9 /scripts | |
parent | 22c5e7fa3e21dddbc120842fd80728eb6234a9b5 (diff) | |
download | poky-d051fc188b6106bd72ba8baba6b5d2439349308c.tar.gz |
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.
(From OE-Core rev: 4d3f43fe06186b6580395a161fdbc4470b8aab62)
Signed-off-by: Sergei Zhmylev <s.zhmylev@yadro.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
(cherry picked from commit 99719a3712a88dce8450994d995803e126e49115)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/wic/partition.py | 7 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 3 | ||||
-rw-r--r-- | 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 e50871b8d7..bc889bdeb9 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py | |||
@@ -294,6 +294,11 @@ class Partition(): | |||
294 | f.write("cd etc\n") | 294 | f.write("cd etc\n") |
295 | f.write("rm fstab\n") | 295 | f.write("rm fstab\n") |
296 | f.write("write %s fstab\n" % (self.updated_fstab_path)) | 296 | f.write("write %s fstab\n" % (self.updated_fstab_path)) |
297 | if os.getenv('SOURCE_DATE_EPOCH'): | ||
298 | fstab_time = int(os.getenv('SOURCE_DATE_EPOCH')) | ||
299 | for time in ["atime", "mtime", "ctime"]: | ||
300 | f.write("set_inode_field fstab %s %s\n" % (time, hex(fstab_time))) | ||
301 | f.write("set_inode_field fstab %s_extra 0\n" % (time)) | ||
297 | debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs) | 302 | debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs) |
298 | exec_native_cmd(debugfs_cmd, native_sysroot) | 303 | exec_native_cmd(debugfs_cmd, native_sysroot) |
299 | 304 | ||
@@ -353,7 +358,7 @@ class Partition(): | |||
353 | exec_native_cmd(mcopy_cmd, native_sysroot) | 358 | exec_native_cmd(mcopy_cmd, native_sysroot) |
354 | 359 | ||
355 | if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update: | 360 | if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update: |
356 | mcopy_cmd = "mcopy -i %s %s ::/etc/fstab" % (rootfs, self.updated_fstab_path) | 361 | mcopy_cmd = "mcopy -m -i %s %s ::/etc/fstab" % (rootfs, self.updated_fstab_path) |
357 | exec_native_cmd(mcopy_cmd, native_sysroot) | 362 | exec_native_cmd(mcopy_cmd, native_sysroot) |
358 | 363 | ||
359 | chmod_cmd = "chmod 644 %s" % rootfs | 364 | 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 da483daed5..3e766972b4 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py | |||
@@ -149,6 +149,9 @@ class DirectPlugin(ImagerPlugin): | |||
149 | self.updated_fstab_path = os.path.join(self.workdir, "fstab") | 149 | self.updated_fstab_path = os.path.join(self.workdir, "fstab") |
150 | with open(self.updated_fstab_path, "w") as f: | 150 | with open(self.updated_fstab_path, "w") as f: |
151 | f.writelines(fstab_lines) | 151 | f.writelines(fstab_lines) |
152 | if os.getenv('SOURCE_DATE_EPOCH'): | ||
153 | fstab_time = int(os.getenv('SOURCE_DATE_EPOCH')) | ||
154 | os.utime(self.updated_fstab_path, (fstab_time, fstab_time)) | ||
152 | 155 | ||
153 | def _full_path(self, path, name, extention): | 156 | def _full_path(self, path, name, extention): |
154 | """ Construct full file path to a file we generate. """ | 157 | """ 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): | |||
224 | if part.update_fstab_in_rootfs and part.has_fstab and not part.no_fstab_update: | 224 | if part.update_fstab_in_rootfs and part.has_fstab and not part.no_fstab_update: |
225 | fstab_path = os.path.join(new_rootfs, "etc/fstab") | 225 | fstab_path = os.path.join(new_rootfs, "etc/fstab") |
226 | # Assume that fstab should always be owned by root with fixed permissions | 226 | # Assume that fstab should always be owned by root with fixed permissions |
227 | install_cmd = "install -m 0644 %s %s" % (part.updated_fstab_path, fstab_path) | 227 | install_cmd = "install -m 0644 -p %s %s" % (part.updated_fstab_path, fstab_path) |
228 | if new_pseudo: | 228 | if new_pseudo: |
229 | pseudo = cls.__get_pseudo(native_sysroot, new_rootfs, new_pseudo) | 229 | pseudo = cls.__get_pseudo(native_sysroot, new_rootfs, new_pseudo) |
230 | else: | 230 | else: |