summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Spooren2026-09-23 10:50:12 +0000
committerPaul Spooren2026-09-27 08:18:12 +0000
commit4092869bc87d62c6f67236f59c13e3b9a255cdbe (patch)
tree8162cc78998fa5319c8077ddddc2375a6b468121
parent177bc19f275908572805e36d9e5debe8b32ef471 (diff)
sata: make the boot partition reproducible
The ext2 boot partition of the WD My Book Live images differs between builds: -Linux rev 1.0 ext2 filesystem data, UUID=8474430c-7c37-4000-95a5-1d8f4f0607d1 +Linux rev 1.0 ext2 filesystem data, UUID=4b8e89bb-aee0-4fde-971c-893df8d8fcd1 -drwxr-xr-x 0 1000 1000 0 2026-09-23 08:27:40.000000 ./boot/ +drwxr-xr-x 0 1000 1000 0 2026-09-23 10:17:28.000000 ./boot/ genext2fs copies owner, mode and mtime of the staged files from the host and adds them in readdir() order, which also decides their inode numbers and blocks. It leaves the UUID empty, so e2fsck fills in a random one, and e2fsck stamps the last check with the current time. Pass genext2fs a name sorted tarball with root ownership, group and other write permission dropped and mtimes clamped to SOURCE_DATE_EPOCH, derive the UUID from the file system contents and run e2fsck with E2FSCK_TIME set to SOURCE_DATE_EPOCH. Remove the staging directory and the tarball afterwards. Link: https://github.com/openwrt/openwrt/pull/25357 Signed-off-by: Paul Spooren <mail@aparcar.org>
-rw-r--r--target/linux/apm821xx/image/Makefile16
1 files changed, 13 insertions, 3 deletions
diff --git a/target/linux/apm821xx/image/Makefile b/target/linux/apm821xx/image/Makefile
index 1f09f8de75..966ebff62d 100644
--- a/target/linux/apm821xx/image/Makefile
+++ b/target/linux/apm821xx/image/Makefile
@@ -11,14 +11,24 @@ define Build/boot-img
$(CP) $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb $@.bootdir/boot/$(DEVICE_DTB)
$(CP) $(IMAGE_KERNEL) $@.bootdir/boot/uImage
+ $(TAR) -C $@.bootdir -cf $@.bootdir.tar --sort=name --numeric-owner \
+ --owner=0 --group=0 --mode=go-w \
+ $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)" --clamp-mtime) \
+ boot
+
genext2fs --block-size $(BLOCKSIZE:%k=%Ki) \
--size-in-blocks $$((1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE))) \
- --root $@.bootdir $@.boot
+ --tarball $@.bootdir.tar $@.boot
# convert it to revision 1 - needed for u-boot ext2load
- $(STAGING_DIR_HOST)/bin/tune2fs -O filetype $@.boot
+ $(STAGING_DIR_HOST)/bin/tune2fs -O filetype \
+ -U $(patsubst %00,%01,$(IMG_PART_DISKGUID)) \
+ $@.boot
# Ignore errors because file system was intentionally broken with tune2fs
- -$(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.boot > /dev/null
+ -$(if $(SOURCE_DATE_EPOCH),E2FSCK_TIME=$(SOURCE_DATE_EPOCH)) \
+ $(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.boot > /dev/null
+
+ rm -rf $@.bootdir $@.bootdir.tar
endef
define Build/boot-script