include: rootfs: fix APK compressed scripts tarball support
authorRobert Marko <[email protected]>
Wed, 19 Nov 2025 12:46:29 +0000 (13:46 +0100)
committerRobert Marko <[email protected]>
Wed, 19 Nov 2025 12:51:04 +0000 (13:51 +0100)
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 <[email protected]>
include/rootfs.mk

index ebf4e406832163b06a87976c433b1fb6b9188bca..02fa3b13d7ead2e3a951f622cf188812f880c4bb 100644 (file)
@@ -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:/ { \