Skip to contentSkip to conversation

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

PATCH Superseded [email protected] 2 participants 3 messages Nov 20 – Dec 4 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 image_types: keep the rootfs mtimes in ext2/3/4 images

From: Alex Kiernan <[email protected]>

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)

(cherry picked from commit 2096871145c16d3b534a252951b960f1306740c1)
---
 meta/classes-recipe/image_types.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)
meta/classes-recipe/image_types.bbclass +6 -0
index 326602d960..79b9ffb9dd 100644
@@ -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)
Signature · 1 line
2.56.1
#1 lore raw
Quoted 28 lines · Hugo Simeliere via openembedded-core

From: Alex Kiernan <[email protected]>

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)

Quoted 8 lines
(cherry picked from commit 2096871145c16d3b534a252951b960f1306740c1)
---
 meta/classes-recipe/image_types.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)

Hi, the commit message only applies to upstream versions. I think you should reword it specifically for wrynose, it can be confusing right now. wrynose is missing at least a commit to be compliant with this description.

Thanks,

Signature · 2 lines
Bastien Jauny
Smile

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 38 lines · Bastien Jauny via openembedded-core
Quoted 28 lines · Hugo Simeliere via openembedded-core

From: Alex Kiernan <[email protected]>

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)

Quoted 8 lines
(cherry picked from commit 2096871145c16d3b534a252951b960f1306740c1)
---
 meta/classes-recipe/image_types.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 5 lines

Hi, the commit message only applies to upstream versions. I think you should reword it specifically for wrynose, it can be confusing right now. wrynose is missing at least a commit to be compliant with this description.

Thanks,

Just to be clear: don't rewrite the whole commit message. Simply add a note about the differences.

Thanks,

Signature · 2 lines
Bastien Jauny
Smile