Skip to contentSkip to conversation

rootfs-postcommands.bbclass: use DATETIME as system timestamp

PATCH In review Ming Liu 2 participants 3 messages Mar 11

lore
Share & tools
lore

Ming Liu

author
#0 lore raw

PATCH 1/1 rootfs-postcommands.bbclass: use DATETIME as system timestamp

DATETIME is being used in BUILD_ID and some other places to mark the build time, let's use it as system timestamp, to have a consistent system-wide timestamp.

---
 meta/classes-recipe/rootfs-postcommands.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes-recipe/rootfs-postcommands.bbclass +2 -1
index f0c7ee658d..43001e09b5 100644
@@ -424,11 +424,12 @@ rootfs_update_timestamp () {
 		# 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`
+		sformatted=${DATETIME}
 	fi
 	echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp
 	bbnote "rootfs_update_timestamp: set /etc/timestamp to $sformatted"
 }
+rootfs_update_timestamp[vardepsexclude] = "DATETIME"
 
 # Prevent X from being started
 rootfs_no_x_startup () {
Signature · 1 line
2.43.0
#1 lore raw
Quoted 19 lines · Ming Liu via lists.openembedded.org

DATETIME is being used in BUILD_ID and some other places to mark the build time, let's use it as system timestamp, to have a consistent system-wide timestamp.

---
 meta/classes-recipe/rootfs-postcommands.bbclass | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes-recipe/rootfs-postcommands.bbclass +0 -0
index f0c7ee658d..43001e09b5 100644
@@ -424,11 +424,12 @@ rootfs_update_timestamp () {
  		# Convert UTC into %4Y%2m%2d%2H%2M%2S

  sformatted=date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS} +%4Y%2m%2d%2H%2M%2S else

meta/classes-recipe/rootfs-postcommands.bbclass +1 -1
-		sformatted=`date -u +%4Y%2m%2d%2H%2M%2S`
+		sformatted=${DATETIME}
Quoted 5 lines

  fi
  echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp
  bbnote "rootfs_update_timestamp: set /etc/timestamp to $sformatted" }
+rootfs_update_timestamp[vardepsexclude] = "DATETIME"

This could be a little tricky as this timestamp is meant to be the latest thing in the image. DATETIME is fixed when the build starts and therefore if files are modified during the image, those could have a later values.

I'm therefore not sure this is a good idea.

Cheers,

Richard

author
#2 lore raw

OK, that’s a good point, please ignore it.

//Ming Liu

On Wed, 2026-03-11 at 11:43 +0100, Ming Liu via lists.openembedded.org

Quoted 39 lines

Review

Quoted 10 lines · wrote:

DATETIME is being used in BUILD_ID and some other places to mark the build time, let's use it as system timestamp, to have a consistent system-wide timestamp.

---
 meta/classes-recipe/rootfs-postcommands.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/classes-recipe/rootfs-postcommands.bbclass

meta/classes-recipe/rootfs-postcommands.bbclass rootfs_update_timestamp () { · line 425

Quoted 6 lines

index f0c7ee658d..43001e09b5 100644

meta/classes-recipe/rootfs-postcommands.bbclass +0 -0
@@ -424,11 +424,12 @@ rootfs_update_timestamp () {
              # Convert UTC into %4Y%2m%2d%2H%2M%2S
              sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS}

+%4Y%2m%2d%2H%2M%2S`

meta/classes-recipe/rootfs-postcommands.bbclass rootfs_update_timestamp () { · line 432

Quoted 8 lines
meta/classes-recipe/rootfs-postcommands.bbclass +2 -1
      else
-             sformatted=`date -u +%4Y%2m%2d%2H%2M%2S`
+             sformatted=${DATETIME}
      fi
      echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp
      bbnote "rootfs_update_timestamp: set /etc/timestamp to $sformatted"
 }
+rootfs_update_timestamp[vardepsexclude] = "DATETIME"

This could be a little tricky as this timestamp is meant to be the latest thing in the image. DATETIME is fixed when the build starts and therefore if files are modified during the image, those could have a later values.

I'm therefore not sure this is a good idea.

Cheers,

Richard