Files
openwrt/tools/mtd-utils/Makefile
T
Paul Spooren 1eaea67aef tools/mtd-utils: make mkfs.ubifs images reproducible
UBIFS root file systems differ between builds, e.g. the one of the
Microchip SAMA7G5-EK: the superblock gets a random UUID, the inodes get
the ctime of the build host, which can't be reset with touch, and the
entries of each directory are added in readdir() order, which depends on
the host file system and decides inode numbers and layout.

Add a patch that, when SOURCE_DATE_EPOCH is set, uses a time-based
(version 1) UUID with that time and clamps all inode times to it. The
node ID of the UUID is taken from the new --uuid-node option, which the
image build sets from IMG_PART_DISKGUID, itself derived from
SOURCE_DATE_EPOCH and the kernel vermagic.
Directory entries are added sorted by name. Two trees with the same
contents but different ctimes and readdir() order now give identical
images; without SOURCE_DATE_EPOCH the UUID stays random.

Link: https://github.com/openwrt/openwrt/pull/25430
Signed-off-by: Paul Spooren <mail@aparcar.org>
2026-10-03 22:45:10 +02:00

59 lines
1.2 KiB
Makefile

#
# Copyright (C) 2006-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=mtd-utils
PKG_VERSION:=2.3.1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://infraroot.at/pub/mtd/
PKG_HASH:=03d9dc58ad10ea3549d9528f6b17a44d8944e18e96c0f31474f9f977078b83dc
PKG_CPE_ID:=cpe:/a:mtd-utils_project:mtd-utils
PKG_FIXUP:=autoreconf
HOST_BUILD_PARALLEL:=1
HOST_CONFIGURE_CACHE:=1
include $(INCLUDE_DIR)/host-build.mk
ifneq ($(HOST_OS),Linux)
HOST_CFLAGS += \
-I$(CURDIR)/include \
-Dloff_t=off_t \
-D__BYTE_ORDER=BYTE_ORDER \
-include endian.h \
-DNO_NATIVE_SUPPORT \
-include fls.h
endif
HOST_CONFIGURE_ARGS+= \
--without-tests \
--without-crypto \
--without-xattr \
--without-zstd \
--without-lzo \
--with-lzma
HOST_MAKE_FLAGS += \
PROGRAMS="mkfs.jffs2 ubinize mkfs.ubifs"
define Host/Install
$(CP) \
$(HOST_BUILD_DIR)/mkfs.jffs2 \
$(HOST_BUILD_DIR)/mkfs.ubifs \
$(HOST_BUILD_DIR)/ubinize \
$(STAGING_DIR_HOST)/bin/
endef
define Host/Clean
rm -f $(STAGING_DIR_HOST)/bin/{mkfs.jffs2,mkfs.ubifs,ubinize}
endef
$(eval $(call HostBuild))