image: create the archive images with fixed metadata

Several image recipes call tar without the options that pin the member
order, the owner, the mode and the modification time. The archive then
holds the build time, the umask of the build user and the readdir order of
the build directory, so two builds of the same source produce different
images.

Pass the same options that Image/mkfs/targz and sysupgrade-tar.sh already
use. The recipes define no member order, so sorting the members takes
nothing away. The diffoscope of the published WAX610 archive shows the
order differing between the build machines, which is what a readdir order
produces.

--mode=go-w clears the write bit of the group and of the others. tar keeps
the mode of the file on disk, which follows the umask of the build user,
so without it the archive differs between a host with umask 022 and one
with umask 002.

Covers the Netgear factory archives of ipq40xx, ipq60xx and ipq807x, the
Creality factory archive of mt76x8, the D-Link DWL8610AP archive of
bcm53xx, the Freecom archive of ixp4xx and the Linksys switch archive of
realtek.

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin committed 2026-09-22 18:46:30 +02:00
1 parent 115209aa22
commit 8e7a8a2b92
7 files changed
+19 -7

No files matched your search

+6 -1
View File
@@ -89,6 +89,11 @@ chmod +x $imgdir/iss_nand_imageupgrade.sh
cp $1 $imgdir/series_vmlinux.bix
tar cf $2 -C $tmpdir image/
mtime=""
if [ -n "$SOURCE_DATE_EPOCH" ]; then
mtime="--mtime=@${SOURCE_DATE_EPOCH}"
fi
tar cf $2 -C $tmpdir --sort=name --numeric-owner --owner=0 --group=0 --mode=go-w $mtime image/
rm -rf $tmpdir
+2 -1
View File
@@ -122,7 +122,8 @@ define Build/dwl8610ap-image
cp $@ $@.tmptar/rootfs.bin
# Hash the rootfs.bin
cat $@.tmptar/rootfs.bin | md5sum > $@.tmptar/rootfs.md5
cd $@.tmptar && tar -c -f $@.new *
cd $@.tmptar && $(TAR) -c -f $@.new --sort=name --numeric-owner --owner=0 --group=0 --mode=go-w \
$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") *
rm -rf $@.tmptar
mv $@.new $@
endef
+2 -1
View File
@@ -80,7 +80,8 @@ define Build/wac5xx-netgear-tar
md5sum $@.tmp/wac5xx-ubifs-root.img > $@.tmp/wac5xx-ubifs-root.md5sum
echo "WAC505 WAC510" > $@.tmp/metadata.txt
echo "WAC505_V9.9.9.9" > $@.tmp/version
tar -C $@.tmp/ -cf $@ .
$(TAR) -C $@.tmp/ -cf $@ --sort=name --numeric-owner --owner=0 --group=0 --mode=go-w \
$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") .
rm -rf $@.tmp
endef
+2 -1
View File
@@ -16,7 +16,8 @@ define Build/freecom-image
mkdir -p $@.tmptar
# Add kernel
cp $@ $@.tmptar/zImage
cd $@.tmptar && tar -c -j -f $@.new --numeric-owner --owner=0 --group=0 *
cd $@.tmptar && $(TAR) -c -j -f $@.new --sort=name --numeric-owner --owner=0 --group=0 --mode=go-w \
$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") *
rm -rf $@.tmptar
encode_crc $@.new $@
rm -f $@.new
+2 -1
View File
@@ -7,7 +7,8 @@ define Build/wax610-netgear-tar
md5sum $@.tmp/nand-ipq6018-apps.img | cut -c 1-32 > $@.tmp/nand-ipq6018-apps.md5sum
echo "WAX610" > $@.tmp/metadata.txt
echo "WAX610-610Y_V99.9.9.9" > $@.tmp/version
tar -C $@.tmp/ -cf $@ .
$(TAR) -C $@.tmp/ -cf $@ --sort=name --numeric-owner --owner=0 --group=0 --mode=go-w \
$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") .
rm -rf $@.tmp
endef
+2 -1
View File
@@ -41,7 +41,8 @@ define Build/wax6xx-netgear-tar
md5sum $@.tmp/nand-ipq807x-apps.img | cut -c 1-32 > $@.tmp/nand-ipq807x-apps.md5sum
echo $(DEVICE_MODEL) > $@.tmp/metadata.txt
echo $(DEVICE_MODEL)"_V99.9.9.9" > $@.tmp/version
tar -C $@.tmp/ -cf $@ .
$(TAR) -C $@.tmp/ -cf $@ --sort=name --numeric-owner --owner=0 --group=0 --mode=go-w \
$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") .
rm -rf $@.tmp
endef
+3 -1
View File
@@ -19,7 +19,9 @@ define Build/creality_wb-01-factory
echo 'mtd_write -o 0 -l $(kernel_size) write $$file Kernel'; \
echo 'mtd_write -r -o $(kernel_size) -l $$rootfs_size write $$file RootFS'; \
) > $(dir $@)install.sh
tar cjf $@ -C $(dir $@) factory.bin install.sh
$(TAR) -cjf $@ -C $(dir $@) --numeric-owner --owner=0 --group=0 --mode=go-w \
$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
factory.bin install.sh
endef
define Build/elecom-header