1
1
openwrt/include
Guoxin Pu 246b216df5 image: fix per device targz rootfs wrong suffix and redundant images
In commit d89cb72c23 , a new rootfs type "targz" was introduced, to correctly pack the rootfs AFTER `DEVICE_PACKAGES` installation (unlike the old simple `rootfs.tar.gz`) .

The expected release artifact shall be a single corresponding tar gz release accompanying or relacing the old simple `rootfs.tar.gz`.

However, if one take a look at the v25.12 series release download pages, e.g. [25.12.4/x86/64](https://downloads.openwrt.org/releases/25.12.4/targets/x86/64/), one could see that there're now four release artifacts related to rootfs targz:

- [generic-targz-combined-efi.img.gz](https://downloads.openwrt.org/releases/25.12.4/targets/x86/64/openwrt-25.12.4-x86-64-generic-targz-combined-efi.img.gz)
- [generic-targz-combined.img.gz](https://downloads.openwrt.org/releases/25.12.4/targets/x86/64/openwrt-25.12.4-x86-64-generic-targz-combined.img.gz)
- [generic-targz-rootfs.img.gz](https://downloads.openwrt.org/releases/25.12.4/targets/x86/64/openwrt-25.12.4-x86-64-generic-targz-rootfs.img.gz)
- [rootfs.tar.gz](https://downloads.openwrt.org/releases/25.12.4/targets/x86/64/openwrt-25.12.4-x86-64-rootfs.tar.gz)

It's obvious the new `targz` release actually reuses the same `TARGET_ROOTFS_{TYPE}` handler same as `squashfs`, `ext4` and alike. And the three `generic-targz` img.gz contains the same expected tar gz either as their second partition, or as the whole image. This could be verified by the following script:

```bash
URL_PARENT=https://downloads.openwrt.org/releases/25.12.4/targets/x86/64/openwrt-25.12.4-x86-64-
for TYPE in combined-efi combined rootfs; do
        curl -L "${URL_PARENT}generic-targz-${TYPE}.img.gz" | gzip -cd > "${TYPE}.img"
done
for TYPE in combined-efi combined; do
        INFO=$(sfdisk -d "${TYPE}.img" | sed -n 's/^'"${TYPE}.img"'2 : start= \+\([0-9]\+\), size= \+\([0-9]\+\),.\+.\+$/\1 \2/p')
        dd if="${TYPE}.img" of="${TYPE}.tar.gz" bs=512 skip="${INFO%% *}" count="${INFO##* }"
done
cp rootfs.img rootfs.tar.gz
sha256sum combined-efi.tar.gz combined.tar.gz rootfs.tar.gz
file rootfs.tar.gz
```

Output:
```log
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
100 13.12M 100 13.12M   0      0 194.6M      0                              0
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
100 12.93M 100 12.93M   0      0 190.9M      0                              0
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
100  7.13M 100  7.13M   0      0 257.6M      0                              0
GPT PMBR size mismatch (246304 != 246334) will be corrected by write.
The backup GPT table is corrupt, but the primary appears OK, so that will be used.
The backup GPT table is not on the end of the device.
212992+0 records in
212992+0 records out
109051904 bytes (109 MB, 104 MiB) copied, 0.258064 s, 423 MB/s
212992+0 records in
212992+0 records out
109051904 bytes (109 MB, 104 MiB) copied, 0.261621 s, 417 MB/s
18b98d3562dc3067ae095ee44d4ff3158cf84e89063c3df66c0ef6638922ba71  combined-efi.tar.gz
18b98d3562dc3067ae095ee44d4ff3158cf84e89063c3df66c0ef6638922ba71  combined.tar.gz
18b98d3562dc3067ae095ee44d4ff3158cf84e89063c3df66c0ef6638922ba71  rootfs.tar.gz
rootfs.tar.gz: gzip compressed data, max compression, from Unix, original size modulo 2^32 0
```

The checksum of the extracted, actually expected .tar.gz are all same. And if we peek inside its content, it's indeed what we expected:

```
> tar -tzf rootfs.tar.gz
./
./bin/
./bin/ash
./bin/board_detect
./bin/busybox
./bin/cat
./bin/chgrp
./bin/chmod
./bin/chown
./bin/config_generate
./bin/cp
./bin/date
...
```

A disk image with a `tar.gz` as its second partiton doesn't boot anyway and I doubt if there's any mechanic to make it bootable. So `generic-targz-combined-efi.img.gz` and `generic-targz-combined.img.gz` are not needed at all, and `generic-targz-rootfs.img.gz` shall be renamed to have a `tar.gz` suffix instead.

Therefore work around this by skipping creating images for fs `targz` in the general loop, and only create the rootfs.tar.gz later for `targz` "fs"

This affects both the real builder and imagebuilder. I've tested this with multiple imagebuilders.

Tested with `openwrt-imagebuilder-25.12.4-mvebu-cortexa53.Linux-x86_64`:

```sh
rm -rf bin && make image PROFILE=generic
```

Without the fix:

```
> tree bin/
bin/
└── targets
    └── x86
        └── 64
            ├── openwrt-25.12.4-x86-64-generic.bom.cdx.json
            ├── openwrt-25.12.4-x86-64-generic-ext4-combined-efi.img.gz
            ├── openwrt-25.12.4-x86-64-generic-ext4-combined.img.gz
            ├── openwrt-25.12.4-x86-64-generic-ext4-rootfs.img.gz
            ├── openwrt-25.12.4-x86-64-generic-kernel.bin
            ├── openwrt-25.12.4-x86-64-generic.manifest
            ├── openwrt-25.12.4-x86-64-generic-rootfs.tar.gz
            ├── openwrt-25.12.4-x86-64-generic-squashfs-combined-efi.img.gz
            ├── openwrt-25.12.4-x86-64-generic-squashfs-combined.img.gz
            ├── openwrt-25.12.4-x86-64-generic-squashfs-rootfs.img.gz
            ├── openwrt-25.12.4-x86-64-generic-targz-combined-efi.img.gz
            ├── openwrt-25.12.4-x86-64-generic-targz-combined.img.gz
            ├── openwrt-25.12.4-x86-64-generic-targz-rootfs.img.gz
            ├── profiles.json
            └── sha256sums
```

With the fix:
```
> tree bin/
bin/
└── targets
    └── x86
        └── 64
            ├── openwrt-25.12.4-x86-64-generic.bom.cdx.json
            ├── openwrt-25.12.4-x86-64-generic-ext4-combined-efi.img.gz
            ├── openwrt-25.12.4-x86-64-generic-ext4-combined.img.gz
            ├── openwrt-25.12.4-x86-64-generic-ext4-rootfs.img.gz
            ├── openwrt-25.12.4-x86-64-generic-kernel.bin
            ├── openwrt-25.12.4-x86-64-generic.manifest
            ├── openwrt-25.12.4-x86-64-generic-rootfs.tar.gz
            ├── openwrt-25.12.4-x86-64-generic-squashfs-combined-efi.img.gz
            ├── openwrt-25.12.4-x86-64-generic-squashfs-combined.img.gz
            ├── openwrt-25.12.4-x86-64-generic-squashfs-rootfs.img.gz
            ├── openwrt-25.12.4-x86-64-generic-targz-rootfs.tar.gz
            ├── profiles.json
            └── sha256sums
```

And with `openwrt-imagebuilder-25.12.4-mvebu-cortexa53.Linux-x86_64`:

```sh
rm -rf bin && make image PROFILE=ripe_atlas-v5
```

Without the fix:
```
> tree bin/
bin/
└── targets
    └── mvebu
        └── cortexa53
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5.bom.cdx.json
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5-ext4-sdcard.img.gz
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5.manifest
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5-rootfs.tar.gz
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5-squashfs-sdcard.img.gz
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5-targz-sdcard.img.gz
            ├── profiles.json
            └── sha256sums
```

With the fix:
```
> tree bin/
bin/
└── targets
    └── mvebu
        └── cortexa53
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5.bom.cdx.json
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5-ext4-sdcard.img.gz
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5.manifest
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5-rootfs.tar.gz
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5-squashfs-sdcard.img.gz
            ├── openwrt-25.12.4-mvebu-cortexa53-ripe_atlas-v5-targz-rootfs.tar.gz
            ├── profiles.json
            └── sha256sums
```

Signed-off-by: Guoxin Pu <pugokushin@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23570
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-05-29 13:10:23 +02:00
..
site build: remove ac_cv_header_netinet_sctp_h=no from pre-cached variables 2024-09-22 16:04:09 +02:00
autotools.mk include: autotools: do not symlink files in autoreconf 2024-08-29 20:04:02 +02:00
bpf.mk build: bpf: fix LLVM tool paths with host toolchain 2025-04-09 09:52:21 +02:00
cmake.mk build: pass CPPFLAGS to cmake build 2026-02-17 01:29:57 +01:00
debug.mk build: use SPDX license tags 2021-02-05 14:54:47 +01:00
default-packages.mk imagebuilder: move handling of DEFAULT_PACKAGES into shareable place 2024-11-17 19:29:06 +01:00
depends.mk build: make find_md5 reproducible with AUTOREMOVE 2022-09-30 22:26:51 +02:00
device_table.txt
download.mk treewide: drop CVS support 2026-02-13 15:40:13 +01:00
feeds.mk build: fix apk_package_files wildcard for packages without ABI version 2026-05-22 14:54:34 +02:00
hardened-ld-pie.specs build: add hardened builds with PIE (ASLR) support 2018-01-27 16:46:45 +01:00
hardening.mk toolchain: gcc: add fanalyzer config option 2025-11-23 09:33:15 +01:00
host-build.mk build: add support for host building in a subdirectory 2024-07-27 20:32:20 +02:00
image-commands.mk filogic: add support for D-Link AQUILA PRO AI E30 2026-04-13 01:52:29 +02:00
image.mk image: fix per device targz rootfs wrong suffix and redundant images 2026-05-29 13:10:23 +02:00
kernel-build.mk kernel-build.mk: Fix multi-core build warning. 2024-10-06 13:49:39 +02:00
kernel-defaults.mk kernel: fix lz4 initramfs creation 2026-05-07 18:14:58 +02:00
kernel-version.mk kernel: move kernel version files to linux/generic directory 2025-04-22 19:22:44 +02:00
kernel.mk treewide: remove unused archs leftovers 2026-05-07 10:58:47 +02:00
logo.png include: update logo with better kerning 2021-01-18 09:31:39 -10:00
logo.svg include: update logo with better kerning 2021-01-18 09:31:39 -10:00
meson.mk meson: allow using staging python 2024-12-02 19:30:22 +00:00
netfilter.mk netfilter: remove nf-conntrack6 2026-01-21 22:42:20 +01:00
nls.mk nls.mk: fixup cmake packages 2022-11-27 00:52:06 +01:00
openssl-module.mk openssl: add MODULES_DIR MACRO for provider 2025-11-11 23:58:54 +01:00
optee-os.mk optee-os.mk: override default PATH to not use hostpkg python 2025-03-15 13:43:14 +01:00
package-bin.mk build: allow package to be built for all variants 2021-11-15 00:38:46 +01:00
package-defaults.mk build: handle --root feeds script feature 2025-10-20 13:50:15 +02:00
package-dumpinfo.mk build: remove duplicate MAINTAINER from package-dumpinfo.mk 2024-05-07 22:24:10 +02:00
package-pack.mk build: add additional apk tags 2026-05-17 12:21:08 +02:00
package-seccomp.mk build: use SPDX license tags 2021-02-05 14:54:47 +01:00
package.mk build: set max-page-size linker flag to match target page size 2026-04-08 00:34:59 +02:00
prereq-build.mk prereq-build: add Python 3.13 support 2025-11-12 12:11:15 +01:00
prereq.mk prereq: use staging_dir's compiler 2025-10-20 00:55:06 +02:00
quilt.mk kernel: move .quilt_used to quilt.mk 2025-11-27 20:26:37 +01:00
rootfs.mk treewide: drop CVS support 2026-02-13 15:40:13 +01:00
scan.awk
scan.mk scan.mk: do not silence output of dump phase 2023-11-13 14:01:24 +01:00
shell.sh build: use mkhash to replace various quirky md5sum/openssl calls 2017-01-05 11:09:12 +01:00
subdir.mk kernel-build.mk: add support for compiling only DTS 2024-02-08 19:57:28 +01:00
target.mk treewide: remove unused archs leftovers 2026-05-07 10:58:47 +02:00
toolchain-build.mk toolchain: fix dangling symlink to self in FixupLibdir 2022-07-01 19:17:36 +02:00
toplevel.mk build: depend on tools/zstd for download 2025-12-10 19:04:44 +01:00
trusted-firmware-a.mk include/trusted-firmware-a.mk: support LTS releases 2025-04-06 14:21:07 +03:00
u-boot.mk treewide: update u-boot URL 2026-01-02 18:07:02 +01:00
uclibc++.mk uclibc++: remove 2021-10-24 18:20:50 +02:00
unpack.mk include: use libdeflate's gzip to decompress 2023-01-17 21:40:18 +01:00
verbose.mk verbose.mk: fallback to standard file descriptors 2024-01-05 16:25:14 +01:00
version.mk build: lock versions for special APK packages 2025-02-04 13:48:59 +00:00