All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gaël PORTAY" <gael.portay@gmail.com>
To: "Alexander Kanavin" <alex.kanavin@gmail.com>,
	<gael.portay+rtone@gmail.com>
Cc: <openembedded-core@lists.openembedded.org>
Subject: Re: [OE-core] [PATCH] classes: rootfs-postcommands: set better sane time to systemd
Date: Mon, 21 Oct 2024 19:02:09 +0200	[thread overview]
Message-ID: <D51N9GUUD7NN.KLL01VZA4V8U@gmail.com> (raw)
In-Reply-To: <CANNYZj-bdtFmFHnK2ppSMY+iXRDX-J5GwWaQjYMwX_t66SnJoQ@mail.gmail.com>

Hello Alex,

On Mon Oct 21, 2024 at 12:25 PM CEST, Alexander Kanavin wrote:
> Can this be done from systemd recipe itself? Items in
> rootfs-postprocess list should not be recipe-specific.
>

Sure it could be done in the recipe itself ;) but...

The recipe harcodes already a sane value at configure time thanks to the
meson option -Dtime-epoch and the environment variable $SOURCE_DATE_EPOC
(or the date the creation of the latest git-tag or the modification time
of the NEWS file). systemd sets the date somewhere in 2022 (kirkstone).

I have created a rootfs-postcommand to be able to set a better time **at
image creation** to keep the systemd package untouched (not rebuilt) by
updateing the variable $REPRODUCIBLE_TIMESTAMP_ROOTFS.

That variable is suffixed by _ROOTFS; and I guess that variable **SHOULD
NOT** be used by package recipes.

The rootfs_systemd_timestamp() is based on rootfs_update_timestamp(); it
touches the file and it leaves the file empty.

Also, to decrease the systemd-specific thing, I wonder if this is
acceptable:

	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`
	        fi
	        echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp
	        bbnote "rootfs_update_timestamp: set /etc/timestamp to $sformatted"
	+
	+       if [ -x /lib/systemd/systemd ]; then
	+           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`
	+           fi
	+           touch -m -t "$sformatted" ${IMAGE_ROOTFS}/usr/lib/clock-epoch
	+           bbnote "rootfs_systemd_timestamp: set /usr/lib/clock-epoch mtime to $sformatted"
	+       }
	}

Or, linking the file instead:

	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`
	        fi
	        echo $sformatted > ${IMAGE_ROOTFS}/etc/timestamp
	        bbnote "rootfs_update_timestamp: set /etc/timestamp to $sformatted"
	+
	+       if [ -x /lib/systemd/systemd ]; then
	+           ln -sf /etc/timestamp /usr/lib/clock-epoch
	+       }
	}

Does it look better for you?

> Alex
>

Regards,
Gaël


  reply	other threads:[~2024-10-21 17:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-19  2:19 [PATCH] classes: rootfs-postcommands: set better sane time to systemd Gaël PORTAY
2024-10-21 10:25 ` [OE-core] " Alexander Kanavin
2024-10-21 17:02   ` Gaël PORTAY [this message]
2024-10-21 17:09     ` Alexander Kanavin
2024-10-21 18:02       ` Gaël PORTAY
2024-10-21 18:06         ` Alexander Kanavin
2024-10-22 18:40     ` [OE-core] " Peter Kjellerstedt
2024-10-22 23:13       ` Gaël PORTAY
2024-10-23  2:40 ` ChenQi
2024-10-23  5:23   ` Gaël PORTAY

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D51N9GUUD7NN.KLL01VZA4V8U@gmail.com \
    --to=gael.portay@gmail.com \
    --cc=alex.kanavin@gmail.com \
    --cc=gael.portay+rtone@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.