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
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#206127): 
https://lists.openembedded.org/g/openembedded-core/message/206127
Mute This Topic: https://lists.openembedded.org/mt/109095282/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to