[openwrt/openwrt] include: rootfs: fix APK compressed scripts tarball support

LEDE Commits lede-commits at lists.infradead.org
Wed Nov 19 04:51:07 PST 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/f4ff823435edd5343c54d01cb717dcadb12eaf13

commit f4ff823435edd5343c54d01cb717dcadb12eaf13
Author: Robert Marko <robimarko at gmail.com>
AuthorDate: Wed Nov 19 13:46:29 2025 +0100

    include: rootfs: fix APK compressed scripts tarball support
    
    APK will generate the compressed scripts.tar by default, however we rely
    on using TAR support for updating the tarball on the fly and this does not
    work when tarball is compressed and will cause the following errors:
    staging_dir/host/bin/tar: Cannot update compressed archives
    Try /staging_dir/host/bin/tar --help' or
    staging_dir/host/bin/tar --usage' for more information.
    
    So, lets simply decompress the scripts.tar.gz before usage and then
    compress it after we are done.
    
    Fixes: 5d85657f6dbb ("apk-tools: implement compression of on-device scripts.tar")
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 include/rootfs.mk | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/rootfs.mk b/include/rootfs.mk
index ebf4e40683..02fa3b13d7 100644
--- a/include/rootfs.mk
+++ b/include/rootfs.mk
@@ -78,7 +78,8 @@ define prepare_rootfs
 		cd $(1); \
 		if [ -n "$(CONFIG_USE_APK)" ]; then \
 			IPKG_POSTINST_PATH=./lib/apk/db/*.post-install; \
-			$(STAGING_DIR_HOST)/bin/tar -C ./lib/apk/db/ -xzf ./lib/apk/db/scripts.tar.gz --wildcards "*.post-install"; \
+			$(STAGING_DIR_HOST)/bin/gzip -d ./lib/apk/db/scripts.tar; \
+			$(STAGING_DIR_HOST)/bin/tar -C ./lib/apk/db/ -xf ./lib/apk/db/scripts.tar --wildcards "*.post-install"; \
 		else \
 			IPKG_POSTINST_PATH=./usr/lib/opkg/info/*.postinst; \
 		fi; \
@@ -89,8 +90,9 @@ define prepare_rootfs
 				echo "postinst script $$script has failed with exit code $$ret" >&2; \
 				exit 1; \
 			fi; \
-			[ -n "$(CONFIG_USE_APK)" ] && $(STAGING_DIR_HOST)/bin/tar --delete -zf ./lib/apk/db/scripts.tar.gz $$(basename $$script); \
+			[ -n "$(CONFIG_USE_APK)" ] && $(STAGING_DIR_HOST)/bin/tar --delete -f ./lib/apk/db/scripts.tar $$(basename $$script); \
 		done; \
+		[ -n "$(CONFIG_USE_APK)" ] && $(STAGING_DIR_HOST)/bin/gzip -f -9n -S ".gz" ./lib/apk/db/scripts.tar; \
 		if [ -z "$(CONFIG_USE_APK)" ]; then \
 			$(if $(IB),,awk -i inplace \
 				'/^Status:/ { \




More information about the lede-commits mailing list