From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7309878352299425792 X-Received: by 2002:a05:6870:2c91:b0:1fb:2e1:bf6a with SMTP id oh17-20020a0568702c9100b001fb02e1bf6amr2560602oab.5.1701963688385; Thu, 07 Dec 2023 07:41:28 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6870:c45:b0:1fb:3148:c486 with SMTP id lf5-20020a0568700c4500b001fb3148c486ls890290oab.2.-pod-prod-04-us; Thu, 07 Dec 2023 07:41:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGe69q61q4WAL3Ov1vgdJZmbuFGwOR8hY4AmbwtBEYigbM8+U0J/AODCeKKbmwJWyDYM0NI X-Received: by 2002:a05:6871:8a3:b0:1fb:2137:ebcb with SMTP id r35-20020a05687108a300b001fb2137ebcbmr3023711oaq.38.1701963687178; Thu, 07 Dec 2023 07:41:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701963687; cv=none; d=google.com; s=arc-20160816; b=t+1ddqY4ChffXOns9XUPOgF1iROzI7Dk7+XdJyQtpFpx2q+UAVWO2Lwf/gDAY0K1Ej /VzOX+jTpFcsWHXwXxK5ZHAIqJfHdI5/Np/s9eH2BbnSDdosibNbVr2anjrDyVwtT76H /tZRVoMiORx/j6NHywxgPHpIygyxobvlquJg3Jx9w0G6tP4soEYGI5bIMXzwMmaVqiOi TJIon8bag52TU24Ymn4qaOpD5HJJRFPfZ6ZjcASngnke4zOIBVywUAwCEsqNJ1ifOUyO XGT2tnbX9rXtbX2WkAJhCqNSf1iH47Df+HqzjnFF2JiC/VVjTdyAFbw/RCt6JWm49u5a ixLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=JQ02Jxz6K4B+7BPnz2ay1iEjVACGFU2UJjehvwy7ftE=; fh=0lUGB2344BCNlOMKgxbVcIhrk5SvZVfMXmxQVZJT4o8=; b=pccWTbpaMm5ucomMtorfZO2B0V5vHwPQshaedihbamhJymKiuWiBsILl3haE6otD/x irFuWAUKEejOwKYqhI9yGNBZu4VhmecvSsLC8wn8S8RZaHvfhL7b7nE+1BS8OQfHpQdM dk/vFCi6nR26j7g6MrQw2HBxSgCXIVmuTPDZu0dtqaXwi56DXwjOxNY/sw2W8lc5H33s LoPR5pQiZ9C+55UeIJRM39WYYn1bdduO7Bs7KNjoA/d73DLOvKg132MR7ZrvAtm0J7wy T3hAuNS8gEUL0iTPYwhxpQkfsTsoxs9aW48A3qIn3nqA92dhrifvIininD2brPm79J3a P58g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.158 as permitted sender) smtp.mailfrom=venkata.pyla@toshiba-tsip.com Return-Path: Received: from mo-csw.securemx.jp (mo-csw1122.securemx.jp. [210.130.202.158]) by gmr-mx.google.com with ESMTPS id lw12-20020a0568708e0c00b001fab154c144si8130oab.1.2023.12.07.07.41.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 07:41:27 -0800 (PST) Received-SPF: pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.158 as permitted sender) client-ip=210.130.202.158; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.158 as permitted sender) smtp.mailfrom=venkata.pyla@toshiba-tsip.com Received: by mo-csw.securemx.jp (mx-mo-csw1122) id 3B7FfOxA394143; Fri, 8 Dec 2023 00:41:24 +0900 X-Iguazu-Qid: 2rWhVu35FtyT0i2apc X-Iguazu-QSIG: v=2; s=0; t=1701963684; q=2rWhVu35FtyT0i2apc; m=A/vU35dwX+sag7U72XSZCYExOV7EAK1dlKbTq2DSkGw= Received: from imx2-a.toshiba.co.jp (imx2-a.toshiba.co.jp [106.186.93.35]) by relay.securemx.jp (mx-mr1123) id 3B7FfNit2798156 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 8 Dec 2023 00:41:23 +0900 From: venkata.pyla@toshiba-tsip.com To: isar-users@googlegroups.com Cc: venkata pyla , jan.kiszka@siemens.com, kazuhiro3.hayashi@toshiba.co.jp, dinesh.kumar@toshiba-tsip.com, felix.moessbauer@siemens.com Subject: [PATCH 5/5] wic: make ext2/3/4 images reproducible Date: Thu, 7 Dec 2023 21:11:14 +0530 X-TSB-HOP2: ON Message-Id: <20231207154114.20400-6-venkata.pyla@toshiba-tsip.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20231207154114.20400-1-venkata.pyla@toshiba-tsip.com> References: <20231207154114.20400-1-venkata.pyla@toshiba-tsip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 07 Dec 2023 15:41:14.0730 (UTC) FILETIME=[CFC5ECA0:01DA2923] X-TUID: FjQL4qDxIbqv From: venkata pyla 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. taken from openembedded-core: 75d2dd0ea7790db2e8ee921784ca373abff2df65 Signed-off-by: venkata pyla --- scripts/lib/wic/partition.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py index 44b1277e..e7641c9e 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py @@ -305,17 +305,36 @@ 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) mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs) exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) + if os.getenv('SOURCE_DATE_EPOCH'): + sde_time = hex(int(os.getenv('SOURCE_DATE_EPOCH'))) + debugfs_script_path = os.path.join(cr_workdir, "debugfs_script") + files = [] + for root, dirs, others in os.walk(rootfs_dir): + base = root.replace(rootfs_dir, "").rstrip(os.sep) + files += [ "/" if base == "" else base ] + files += [ base + "/" + n for n in dirs + others ] + with open(debugfs_script_path, "w") as f: + f.write("set_current_time %s\n" % (sde_time)) + if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update: + f.write("set_inode_field /etc/fstab mtime %s\n" % (sde_time)) + f.write("set_inode_field /etc/fstab mtime_extra 0\n") + for file in set(files): + for time in ["atime", "ctime", "crtime"]: + f.write("set_inode_field \"%s\" %s %s\n" % (file, time, sde_time)) + f.write("set_inode_field \"%s\" %s_extra 0\n" % (file, time)) + for time in ["wtime", "mkfs_time", "lastcheck"]: + f.write("set_super_value %s %s\n" % (time, sde_time)) + for time in ["mtime", "first_error_time", "last_error_time", "kbytes_written"]: + f.write("set_super_value %s 0\n" % (time)) + debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs) + exec_native_cmd(debugfs_cmd, native_sysroot) + self.check_for_Y2038_problem(rootfs, native_sysroot) def prepare_rootfs_btrfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir, -- 2.20.1