@@ -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 =
@@ -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