From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7309878352299425792 X-Received: by 2002:a05:6358:278f:b0:16d:bc40:3055 with SMTP id l15-20020a056358278f00b0016dbc403055mr3821723rwb.19.1701963688049; Thu, 07 Dec 2023 07:41:28 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6214:1242:b0:67a:bf7a:7ba6 with SMTP id r2-20020a056214124200b0067abf7a7ba6ls1190020qvv.1.-pod-prod-01-us; Thu, 07 Dec 2023 07:41:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/u9uAmvVl20+VS6jmDpX6zgSqIL1dM/wLT7ujJW6pOSzLeH6WGcMCfb+sK+SZ0YNXjIVf X-Received: by 2002:a05:6102:511e:b0:464:7c56:d827 with SMTP id bm30-20020a056102511e00b004647c56d827mr3017380vsb.60.1701963686620; Thu, 07 Dec 2023 07:41:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701963686; cv=none; d=google.com; s=arc-20160816; b=YxHiQtSx4pocU6XpMNmbZlhA0bVuzxs8PFC1CWpy+cOSbtR4FdhsSO9IFleKeEMNpM DksOXGgKuN4QSLr4b6Aov9ggExa3eIAHbkqxZSzDusGDiriZQSs8fqWf1w0klGy/9cfL kjTPVRW2yxhgWB1fbX83lxYWrJ9v9gmzAIsB25fgllVDbLAdSI3redaBIaICYECYwD6+ uXU97YX9+l55P2y8bSmLuhPvp9sT4eNQkpKWnfeNqoC3mADWqmReW0ogBwFcBcI344pH 4Wa2ix8wZvqoOpaxzA77NfVLJ3WNcNKtzpTVFaPZIJkRUYV7l/SMUbtnqMi1RV6BsP0T LBlQ== 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=3Jno3Dgkk5+HWp0gRTwL9FCy3cqK4loaRFpvMQkRfK4=; fh=0lUGB2344BCNlOMKgxbVcIhrk5SvZVfMXmxQVZJT4o8=; b=oGvEpfAhkYZBl14nwfrwgw14bCB/3lfmB/75SF8i3Vr8Zle+mjQIX/So2N+rBHhUes RhuVU+gbbemYjgXclHuhSRZj7tiZp+0oETvN6UnjVPx99MEudWdT9SgFD3u6+kkaKIco lE6VMR3lbh7apX9/s/JbDngbHUFFnBi8MFQme/ZPJ8X5V+Ov8i+c0pVP06uoi3Lea681 wXFKkUplpxFI7ow4Z6qjXWXy/NwoMd05NYyNf7/8moRNm1vCW1A1y7AID3o6bsbvY0eu IWOZCCJHvygAB0C87KgaZ0OKJMTQh8BJCWXSZgIQPI+Wu/EUzNYQsbGOZsO26eZHT2JE dXgA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.134 as permitted sender) smtp.mailfrom=venkata.pyla@toshiba-tsip.com Return-Path: Received: from mo-csw.securemx.jp (mo-csw1800.securemx.jp. [210.130.202.134]) by gmr-mx.google.com with ESMTPS id bq17-20020ab03e11000000b007c56697eaefsi122830uab.1.2023.12.07.07.41.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 07:41:25 -0800 (PST) Received-SPF: pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.134 as permitted sender) client-ip=210.130.202.134; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.134 as permitted sender) smtp.mailfrom=venkata.pyla@toshiba-tsip.com Received: by mo-csw.securemx.jp (mx-mo-csw1800) id 3B7FfMd34084148; Fri, 8 Dec 2023 00:41:23 +0900 X-Iguazu-Qid: 2yAbPDmovHUXRs1X5E X-Iguazu-QSIG: v=2; s=0; t=1701963682; q=2yAbPDmovHUXRs1X5E; m=mp+9d9LxgmiyUI6KWA8JFKwGK6pFtuaH5nb3zg8QN+U= Received: from imx12-a.toshiba.co.jp ([38.106.60.135]) by relay.securemx.jp (mx-mr1801) id 3B7FfM1a668078 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 8 Dec 2023 00:41:22 +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 4/5] wic: honor the SOURCE_DATE_EPOCH in case of updated fstab Date: Thu, 7 Dec 2023 21:11:13 +0530 X-TSB-HOP2: ON Message-Id: <20231207154114.20400-5-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.0667 (UTC) FILETIME=[CFBC4FB0:01DA2923] X-TUID: h/dVzYCpLgZE From: venkata pyla 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 --- 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