[v2,1/2] isar-bootstrap.inc: Export SOURCE_DATE_EPOCH variable

Message ID 20240306061423.1088541-2-Adithya.Balakumar@toshiba-tsip.com
State Accepted, archived
Headers show
Series Fix reproducibility of /etc/shadow file when image built on different days | expand

Commit Message

Adithya Balakumar March 6, 2024, 6:14 a.m. UTC
The third field in the /etc/shadow file (sp_lstchg) contains the date of
the last password change expressed as the number of days since Jan 1,
1970. The sp_lstchg value changes when the images are built on
different days making the image not reproducible.

Exporting the SOURCE_DATE_EPOCH variable ensures that sp_lstchg value is
set with respect to the SOURCE_DATE_EPOCH value while debootstrap creates
the minimal rootfile system.

Signed-off-by: Adithya Balakumar <Adithya.Balakumar@toshiba-tsip.com>
---
 meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 4 ++++
 1 file changed, 4 insertions(+)

Patch

diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
index 3477c2fb..b1fcd7b0 100644
--- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
@@ -292,6 +292,10 @@  do_bootstrap() {
     sudo rm -rf --one-file-system "${ROOTFSDIR}"
     deb_dl_dir_import "${ROOTFSDIR}" "${BOOTSTRAP_BASE_DISTRO}-${BASE_DISTRO_CODENAME}"
 
+    if [ -n "${SOURCE_DATE_EPOCH}" ]; then
+        export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}"
+    fi
+
     sudo -E -s <<'EOSUDO'
         set -e
         if [ "${BOOTSTRAP_FOR_HOST}" = "0" ]; then