rootfs-postcommands: Make /etc/timestamp consistent with image
PATCH 1/1 rootfs-postcommands: Make /etc/timestamp consistent with image
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.
--- meta/classes-recipe/rootfs-postcommands.bbclass | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
meta/classes-recipe/rootfs-postcommands.bbclass +7 -5
@@ -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" }
Signature · 1 line
2.37.2.672.g94769d06f0-goog
Quoted 4 lines · William A. Kennington III via lists.openembedded.org
This makes the determination of the timestamp for the
/etc/timestampfile 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.
This is only going to pay attention to poky, or oe-core... the rootfs will vary with a change to ANY layer in the system.
If you really want to be consistent you would need to iterate over all of the layers and look at every file in the system for the timestamp (or if they're git repositories last commit in each layer..)
All of this doesn't seem like it really makes sense to me which is why a static timestamp was defined previously.
(with the previous change to the time stamps, I've had more then one user get concerned they were 'using old software' when they just built something from scratch -- this will get even more confusing if it's only based on the oe-core/poky repository.)
--Mark
Quoted 41 lines
Change-Id I7d9fe32906aa93baf53948aa40b7a98fb05dd384Signed-off-by William A. Kennington III <[email protected]>--- meta/classes-recipe/rootfs-postcommands.bbclass | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)meta/classes-recipe/rootfs-postcommands.bbclass +7
-6@@ -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" } -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#170041): https://lists.openembedded.org/g/openembedded-core/message/170041
Mute This Topic: https://lists.openembedded.org/mt/93339153/3616948
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 4 lines · Mark Hatle
On 8/29/22 6:59 PM, William A. Kennington III via lists.openembedded.org wrote:
Quoted 8 lines
Quoted 4 lines
This makes the determination of the timestamp for the
/etc/timestampfile 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.This is only going to pay attention to poky, or oe-core... the rootfs will vary
with a change to ANY layer in the system.
Yes, this is what I expect. It is following the same behavior as image.bbclass.
Quoted 7 lines
If you really want to be consistent you would need to iterate over all of the
layers and look at every file in the system for the timestamp (or if they're git
repositories last commit in each layer..)
I'm just looking for consistency with the image generation side of things that set the timestamp based on the same logic flow. It's weird that they used different logic for setting timestamps in the output image. Sure we could improve the most recent timestamp by looking at all the git repos of all the meta layers, but that's not the point of this change.
Quoted 4 lines
All of this doesn't seem like it really makes sense to me which is why a static
timestamp was defined previously.
That's fine too, we just want our builds to have reasonably recent timestamps that are deterministic when REPRODUCIBLE_TIMESTAMP_ROOTFS is unset.
Quoted 60 lines
(with the previous change to the time stamps, I've had more then one user get
concerned they were 'using old software' when they just built something from
scratch -- this will get even more confusing if it's only based on the oe-core/poky repository.)--Mark
Review
Quoted 7 lines
Change-Id I7d9fe32906aa93baf53948aa40b7a98fb05dd384Signed-off-by William A. Kennington III <[email protected]>--- meta/classes-recipe/rootfs-postcommands.bbclass | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)(quoted diff) +0
-0b/meta/classes-recipe/rootfs-postcommands.bbclass
meta/classes-recipe/rootfs-postcommands.bbclass python write_image_manifest () { · line 312
Quoted 5 lines
index
215e38e33d..8d710186d7100644meta/classes-recipe/rootfs-postcommands.bbclass +0
-0@@ -312,12 +312,14 @@ python write_image_manifest () { # Can be used to create /etc/timestamp during image construction togive a reasonably
meta/classes-recipe/rootfs-postcommands.bbclass python write_image_manifest () {
Quoted 5 lines
meta/classes-recipe/rootfs-postcommands.bbclass +0
-3# 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`
meta/classes-recipe/rootfs-postcommands.bbclass python write_image_manifest () {
Quoted 4 lines
meta/classes-recipe/rootfs-postcommands.bbclass +2
-2- 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
meta/classes-recipe/rootfs-postcommands.bbclass python write_image_manifest () { · line 318
Quoted 2 lines
meta/classes-recipe/rootfs-postcommands.bbclass +2
-0+ if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then + REPRODUCIBLE_TIMESTAMP_ROOTFS=`stat -c%Y${@bb.utils.which(d.getVar("BBPATH"), "conf/bitbake.conf")}`
meta/classes-recipe/rootfs-postcommands.bbclass python write_image_manifest () {
Quoted 4 lines
meta/classes-recipe/rootfs-postcommands.bbclass +3
-0+ fi fi + # Convert UTC into %4Y%2m%2d%2H%2M%2S + sformatted=`date -u -d @${REPRODUCIBLE_TIMESTAMP_ROOTFS}+%4Y%2m%2d%2H%2M%2S`
Quoted 9 lines
meta/classes-recipe/rootfs-postcommands.bbclass +0
-1echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp bbnote "rootfs_update_timestamp: set /etc/timestamp to $sformatted" } -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group. View/Reply Online (#170041):
https://lists.openembedded.org/g/openembedded-core/message/170041
Quoted 3 lines
Mute This Topic: https://lists.openembedded.org/mt/93339153/3616948
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [Quoted 2 lines
-=-=-=-=-=-=-=-=-=-=-=-