All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rootfs-postcommands: Make /etc/timestamp consistent with image
@ 2022-08-29 23:59 William A. Kennington III
  2022-08-30  0:15 ` [OE-core] " Mark Hatle
  0 siblings, 1 reply; 3+ messages in thread
From: William A. Kennington III @ 2022-08-29 23:59 UTC (permalink / raw)
  To: openembedded-core; +Cc: William A. Kennington III

This makes the determination of the timestamp for the /etc/timestamp
file consistent with mtimes in the generated image. This is desirable to
make the built image reproducible with the git commit date instead of
the current date.

Change-Id: I7d9fe32906aa93baf53948aa40b7a98fb05dd384
Signed-off-by: William A. Kennington III <wak@google.com>
---
 meta/classes-recipe/rootfs-postcommands.bbclass | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/meta/classes-recipe/rootfs-postcommands.bbclass b/meta/classes-recipe/rootfs-postcommands.bbclass
index 215e38e33d..8d710186d7 100644
--- a/meta/classes-recipe/rootfs-postcommands.bbclass
+++ b/meta/classes-recipe/rootfs-postcommands.bbclass
@@ -312,12 +312,14 @@ python write_image_manifest () {
 # Can be used to create /etc/timestamp during image construction to give a reasonably
 # sane default time setting
 rootfs_update_timestamp () {
-	if [ "${REPRODUCIBLE_TIMESTAMP_ROOTFS}" != "" ]; then
-		# Convert UTC into %4Y%2m%2d%2H%2M%2S
-		sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS} +%4Y%2m%2d%2H%2M%2S`
-	else
-		sformatted=`date -u +%4Y%2m%2d%2H%2M%2S`
+	if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
+		REPRODUCIBLE_TIMESTAMP_ROOTFS=`git -C "${COREBASE}" log -1 --pretty=%ct 2>/dev/null` || true
+		if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
+			REPRODUCIBLE_TIMESTAMP_ROOTFS=`stat -c%Y ${@bb.utils.which(d.getVar("BBPATH"), "conf/bitbake.conf")}`
+		fi
 	fi
+	# Convert UTC into %4Y%2m%2d%2H%2M%2S
+	sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS} +%4Y%2m%2d%2H%2M%2S`
 	echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp
 	bbnote "rootfs_update_timestamp: set /etc/timestamp to $sformatted"
 }
-- 
2.37.2.672.g94769d06f0-goog



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

end of thread, other threads:[~2022-08-30  0:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29 23:59 [PATCH] rootfs-postcommands: Make /etc/timestamp consistent with image William A. Kennington III
2022-08-30  0:15 ` [OE-core] " Mark Hatle
2022-08-30  0:39   ` William Kennington

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.