diff mbox series

[blacksail] image_types: keep the rootfs mtimes in ext2/3/4 images

Message ID 20261120072149.2725461-1-hsimeliere.opensource@witekio.com
State Not Applicable, archived
Delegated to: Yoann Congal
Headers show
Series [blacksail] image_types: keep the rootfs mtimes in ext2/3/4 images | expand

Commit Message

Hugo Simeliere Nov. 20, 2026, 7:21 a.m. UTC
From: Alex Kiernan <alex.kiernan@gmail.com>

mke2fs reads SOURCE_DATE_EPOCH from the environment and clamps the time
of every inode it creates to it. bitbake exports the image's
SOURCE_DATE_EPOCH, which is older than the REPRODUCIBLE_TIMESTAMP_ROOTFS
that reproducible_final_image_task gives every file, so an ext image
carries different mtimes from a tar or squashfs image of the same rootfs,
and anything recorded against the rootfs mtimes, such as the fontconfig
caches, is wrong in it.

Give mke2fs the rootfs mtime instead, as oe_mksquashfs does for
mksquashfs. It is just as fixed, so the image stays reproducible.

This changes the times stamped into an ext image. Every inode's atime,
ctime, mtime and crtime, and the superblock's created, last write and
last checked times, move from the image's SOURCE_DATE_EPOCH to
REPRODUCIBLE_TIMESTAMP_ROOTFS. An image recipe has no source of its own,
so its SOURCE_DATE_EPOCH is SOURCE_DATE_EPOCH_FALLBACK; with the
bitbake.conf defaults for that and REPRODUCIBLE_TIMESTAMP_ROOTFS, the
times move from 1302044400 (2011-04-05) to 1520598896 (2018-03-09).

Where a distro sets REPRODUCIBLE_TIMESTAMP_ROOTFS earlier than
SOURCE_DATE_EPOCH the inode times were not clamped and only the
superblock times change. The directory hash seed is still derived from
SOURCE_DATE_EPOCH and does not change. An ext image therefore differs
from one built before this change.

AI-Generated: Claude Opus 5.5 (Claude Code)
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 2096871145c16d3b534a252951b960f1306740c1)
Signed-off-by: Hugo SIMELIERE (Schneider Electric) <hsimeliere.opensource@witekio.com>
---
 meta/classes-recipe/image_types.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Hugo Simeliere Nov. 20, 2026, 7:30 a.m. UTC | #1
Please ignore, this was meant for wrynose. Resent as "[wrynose][PATCH v2]".
Yoann Congal Nov. 20, 2026, 7:33 a.m. UTC | #2
On Fri Nov 20, 2026 at 8:30 AM CET, Hugo Simeliere via openembedded-core wrote:
> Please ignore, this was meant for wrynose. Resent as "[wrynose][PATCH v2]".

Noted. But
https://patchwork.yoctoproject.org/project/oe-core/patch/20261120072058.2724815-1-hsimeliere.opensource@witekio.com/
is indeed for blacksail, right?
Hugo Simeliere Nov. 20, 2026, 7:45 a.m. UTC | #3
On Fri Nov 20, 2026 at 8:33 AM CET, Yoann Congal wrote:
> Noted. But
> https://patchwork.yoctoproject.org/project/oe-core/patch/20261120072058.2724815-1-hsimeliere.opensource@witekio.com/
> is indeed for blacksail, right?

Yes, that one is for blacksail.

I also mistakenly resent it as "[blacksail][PATCH v2]" after my
"please ignore" mail; it is identical to this v1, so please take
either one and drop the other.

Hugo
Yoann Congal Nov. 20, 2026, 7:52 a.m. UTC | #4
On Fri Nov 20, 2026 at 8:45 AM CET, hsimeliere.opensource wrote:
> On Fri Nov 20, 2026 at 8:33 AM CET, Yoann Congal wrote:
>> Noted. But
>> https://patchwork.yoctoproject.org/project/oe-core/patch/20261120072058.2724815-1-hsimeliere.opensource@witekio.com/
>> is indeed for blacksail, right?
>
> Yes, that one is for blacksail.
>
> I also mistakenly resent it as "[blacksail][PATCH v2]" after my
> "please ignore" mail; it is identical to this v1, so please take
> either one and drop the other.

Ok, noted (kept the v2).

>
> Hugo
diff mbox series

Patch

diff --git a/meta/classes-recipe/image_types.bbclass b/meta/classes-recipe/image_types.bbclass
index 326602d960..79b9ffb9dd 100644
--- a/meta/classes-recipe/image_types.bbclass
+++ b/meta/classes-recipe/image_types.bbclass
@@ -81,6 +81,12 @@  oe_mkext234fs () {
 		extra_imagecmd=$@
 	fi
 
+	# mke2fs reads SOURCE_DATE_EPOCH itself and clamps every inode time to it,
+	# so give it the time the rootfs files carry, as oe_mksquashfs does.
+	if [ -n "$SOURCE_DATE_EPOCH" ]; then
+		export SOURCE_DATE_EPOCH=$(stat -c '%Y' ${IMAGE_ROOTFS})
+	fi
+
 	# If generating an empty image the size of the sparse block should be large
 	# enough to allocate an ext4 filesystem using 4096 bytes per inode, this is
 	# about 60K, so dd needs a minimum count of 60, with bs=1024 (bytes per IO)