public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v4 0/1] Fix for reproducible build issue v4
@ 2023-01-09 16:05 venkata.pyla
  2023-01-09 16:05 ` [PATCH v4 1/1] image.bbclass: fix non-reproducible file time-stamps inside rootfs venkata.pyla
  0 siblings, 1 reply; 2+ messages in thread
From: venkata.pyla @ 2023-01-09 16:05 UTC (permalink / raw)
  To: isar-users
  Cc: venkata pyla, amikan, jan.kiszka, henning.schild,
	kazuhiro3.hayashi, dinesh.kumar

From: venkata pyla <venkata.pyla@toshiba-tsip.com>

Hi,

Chages from v3:
 - bbwarn only file type for modified timestamps and exlcude others like directories, links and char files as they are obvious changes for modified file timestamps.

venkata pyla (1):
  image.bbclass: fix non-reproducible file time-stamps inside rootfs

 meta-isar/conf/local.conf.sample | 10 ++++++++++
 meta/classes/image.bbclass       | 10 ++++++++++
 2 files changed, 20 insertions(+)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v4 1/1] image.bbclass: fix non-reproducible file time-stamps inside rootfs
  2023-01-09 16:05 [PATCH v4 0/1] Fix for reproducible build issue v4 venkata.pyla
@ 2023-01-09 16:05 ` venkata.pyla
  0 siblings, 0 replies; 2+ messages in thread
From: venkata.pyla @ 2023-01-09 16:05 UTC (permalink / raw)
  To: isar-users
  Cc: venkata pyla, amikan, jan.kiszka, henning.schild,
	kazuhiro3.hayashi, dinesh.kumar

From: venkata pyla <venkata.pyla@toshiba-tsip.com>

As part of reproducible-build work, the rootfs images generated on same
source should be identical between two builds.

In this commit it tries to solve one of the non-reproducible problem
i.e. the rootfs file time-stamps generated during build time are not
reproducible, it uses one of the solution provided in the debian
live-build image project (refer [1]), it fixes by finding all the
files/folders that are gernerated newly and set the time-stamp provided
by `SOURCE_DATE_EPOCH` environment variable.

[1] https://salsa.debian.org/live-team/live-build/-/merge_requests/218

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>

image.bbclass

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
---
 meta-isar/conf/local.conf.sample | 10 ++++++++++
 meta/classes/image.bbclass       | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 57d0620..3c4a473 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -255,3 +255,13 @@ USER_isar[flags] += "clear-text-password"
 #CCACHE_TOP_DIR ?= "${TMPDIR}/ccache"
 # Enable ccache debug mode
 #CCACHE_DEBUG = "1"
+
+# Uncommnet and add value to it to build images reproducibly
+#
+# The value for `SOURCE_DATE_EPOCH` should be latest source change time in
+# seconds since the Epoch.
+# Git repository users can use value from 'git log -1 --pretty=%ct'
+# Non git repository users can use value from 'stat -c%Y ChangeLog'
+# To know more details about this variable and how to set the value refer below
+# https://reproducible-builds.org/docs/source-date-epoch/
+#SOURCE_DATE_EPOCH =
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 813e1f3..38a8609 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -431,6 +431,16 @@ do_rootfs_finalize() {
 
         rm -f "${ROOTFSDIR}/etc/apt/sources-list"
 EOSUDO
+
+    # Set same time-stamps to the newly generated file/folders in the
+    # rootfs image for the purpose of reproducible builds.
+    test ! -z "${SOURCE_DATE_EPOCH}" && \
+        sudo find ${ROOTFSDIR} -newermt \
+            "$(date -d@${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S')" \
+            -printf "%y %p\n" \
+            -exec touch '{}' -h -d@${SOURCE_DATE_EPOCH} ';' > ${DEPLOY_DIR_IMAGE}/files.modified_timestamps && \
+            bbwarn "$(grep ^f ${DEPLOY_DIR_IMAGE}/files.modified_timestamps) \nModified above file timestamps to build image reproducibly"
+
 }
 addtask rootfs_finalize before do_rootfs after do_rootfs_postprocess
 
-- 
2.20.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-09 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 16:05 [PATCH v4 0/1] Fix for reproducible build issue v4 venkata.pyla
2023-01-09 16:05 ` [PATCH v4 1/1] image.bbclass: fix non-reproducible file time-stamps inside rootfs venkata.pyla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox