diff options
author | Sergei Zhmylev <s.zhmylev@yadro.com> | 2022-11-07 17:24:53 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-11-07 21:57:21 +0000 |
commit | be91408e10805070f42f94e7f197aac9093b51b3 (patch) | |
tree | cc3bafe119b32f45d1df675dc58bfc5010a4057d /scripts | |
parent | 2cdaa164e8b4618a82ccd3fcb87cf58e36b6d6d3 (diff) | |
download | poky-be91408e10805070f42f94e7f197aac9093b51b3.tar.gz |
wic: make ext2/3/4 images reproducible
Ext2/3/4 FS contains not only mtime, but also ctime, atime and crtime.
Currently, all the files are being added into the rootfs image using
mkfs -d functionality which affects all the timestamps excluding mtime.
This patch ensures these timestamps inside the FS image equal to
the SOURCE_DATE_EPOCH if it is set.
(From OE-Core rev: 75d2dd0ea7790db2e8ee921784ca373abff2df65)
Signed-off-by: Sergei Zhmylev <s.zhmylev@yadro.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/wic/partition.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py index bc889bdeb9..2a916e077c 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py | |||
@@ -294,17 +294,36 @@ 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)) | ||
302 | debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs) | 297 | debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs) |
303 | exec_native_cmd(debugfs_cmd, native_sysroot) | 298 | exec_native_cmd(debugfs_cmd, native_sysroot) |
304 | 299 | ||
305 | mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs) | 300 | mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs) |
306 | exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) | 301 | exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) |
307 | 302 | ||
303 | if os.getenv('SOURCE_DATE_EPOCH'): | ||
304 | sde_time = hex(int(os.getenv('SOURCE_DATE_EPOCH'))) | ||
305 | debugfs_script_path = os.path.join(cr_workdir, "debugfs_script") | ||
306 | files = [] | ||
307 | for root, dirs, others in os.walk(rootfs_dir): | ||
308 | base = root.replace(rootfs_dir, "").rstrip(os.sep) | ||
309 | files += [ "/" if base == "" else base ] | ||
310 | files += [ base + "/" + n for n in dirs + others ] | ||
311 | with open(debugfs_script_path, "w") as f: | ||
312 | f.write("set_current_time %s\n" % (sde_time)) | ||
313 | if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update: | ||
314 | f.write("set_inode_field /etc/fstab mtime %s\n" % (sde_time)) | ||
315 | f.write("set_inode_field /etc/fstab mtime_extra 0\n") | ||
316 | for file in set(files): | ||
317 | for time in ["atime", "ctime", "crtime"]: | ||
318 | f.write("set_inode_field \"%s\" %s %s\n" % (file, time, sde_time)) | ||
319 | f.write("set_inode_field \"%s\" %s_extra 0\n" % (file, time)) | ||
320 | for time in ["wtime", "mkfs_time", "lastcheck"]: | ||
321 | f.write("set_super_value %s %s\n" % (time, sde_time)) | ||
322 | for time in ["mtime", "first_error_time", "last_error_time"]: | ||
323 | f.write("set_super_value %s 0\n" % (time)) | ||
324 | debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs) | ||
325 | exec_native_cmd(debugfs_cmd, native_sysroot) | ||
326 | |||
308 | self.check_for_Y2038_problem(rootfs, native_sysroot) | 327 | self.check_for_Y2038_problem(rootfs, native_sysroot) |
309 | 328 | ||
310 | def prepare_rootfs_btrfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir, | 329 | def prepare_rootfs_btrfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir, |