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

* Re: [OE-core] [PATCH] rootfs-postcommands: Make /etc/timestamp consistent with image
  2022-08-29 23:59 [PATCH] rootfs-postcommands: Make /etc/timestamp consistent with image William A. Kennington III
@ 2022-08-30  0:15 ` Mark Hatle
  2022-08-30  0:39   ` William Kennington
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Hatle @ 2022-08-30  0:15 UTC (permalink / raw)
  To: wak, openembedded-core



On 8/29/22 6:59 PM, William A. Kennington III via lists.openembedded.org wrote:
> 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.

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

> 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"
>   }
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> 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: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mark.hatle@kernel.crashing.org]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


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

* Re: [OE-core] [PATCH] rootfs-postcommands: Make /etc/timestamp consistent with image
  2022-08-30  0:15 ` [OE-core] " Mark Hatle
@ 2022-08-30  0:39   ` William Kennington
  0 siblings, 0 replies; 3+ messages in thread
From: William Kennington @ 2022-08-30  0:39 UTC (permalink / raw)
  To: Mark Hatle; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 3969 bytes --]

On Mon, Aug 29, 2022 at 5:19 PM Mark Hatle <mark.hatle@kernel.crashing.org>
wrote:

>
>
> On 8/29/22 6:59 PM, William A. Kennington III via lists.openembedded.org
> wrote:
> > 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.
>
> 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.


> 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.


> 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.


>
> (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
>
> > 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"
> >   }
> >
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > 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: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> mark.hatle@kernel.crashing.org]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>

[-- Attachment #2: Type: text/html, Size: 5903 bytes --]

^ permalink raw reply	[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.