openwrt/package/system/apk/Makefile
Eric Fahlgren 5d85657f6d apk-tools: implement compression of on-device scripts.tar
Default behavior for apk was to create an uncompressed scripts.tar
file.  Due to the structure of tar files, with fixed block
size and null padding, this file becomes very large on OpenWrt
installations where there are typically two scripts per package.
This could cause the raw tar file to easily grow to over 500KB,
whereas the compressed file is generally around 20-30KB.

When stored in the /rom partition of a squashfs device, the file
is compressed and this is not an issue.  But, as soon as you add
or delete a package, the scripts.tar file is fully expanded into
the /overlay partition and can cause issues on small-flash devices.

This issue was addressed in an upstream commit by detecting
whether the scripts.tar file is compressed (its name must be
exactly 'scripts.tar.gz'), and then retaining that compression by
reading/writing the file using a compressed stream.

This commit applies a cherrypicked patch for the upstream commit, and
compresses the scripts.tar during construction of the device rootfs.

Fixes: https://github.com/openwrt/openwrt/issues/17108
Link: 012cdcfdf9
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/20795
Signed-off-by: Robert Marko <robimarko@gmail.com>
2025-11-18 17:25:06 +01:00

97 lines
2.3 KiB
Makefile

include $(TOPDIR)/rules.mk
PKG_NAME:=apk
PKG_RELEASE:=2
PKG_SOURCE_URL=https://gitlab.alpinelinux.org/alpine/apk-tools.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2025-10-07
PKG_SOURCE_VERSION:=6ffc65c63004b8d991ead4ea0f3d80e05b06b977
PKG_MIRROR_HASH:=388e0210247a49099f49e783ff3d0753bed26bbb91acec2dd2d5722aca5daf6f
PKG_VERSION=3.0.0_pre$(subst -,,$(PKG_SOURCE_DATE))
PKG_MAINTAINER:=Paul Spooren <mail@aparcar.org>
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE
PKG_INSTALL:=2
HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST)
HOST_BUILD_DEPENDS:=lua/host
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/meson.mk
define Package/apk/default
SECTION:=base
CATEGORY:=Base system
TITLE:=apk package manager
DEPENDS:=+zlib +wget
URL:=$(PKG_SOURCE_URL)
PROVIDES:=apk
endef
define Package/apk-mbedtls
$(Package/apk/default)
TITLE += (mbedtls)
DEPENDS +=+libmbedtls
DEFAULT:=y if USE_APK
VARIANT:=mbedtls
DEFAULT_VARIANT:=1
CONFLICTS:=apk-openssl
endef
define Package/apk-openssl
$(Package/apk/default)
TITLE += (openssl)
DEPENDS +=+libopenssl
VARIANT:=openssl
endef
MESON_HOST_VARS+=VERSION=$(PKG_VERSION)
MESON_VARS+=VERSION=$(PKG_VERSION)
MESON_COMMON_ARGS = \
-Db_lto=true \
-Dcompressed-help=false \
-Ddocs=disabled \
-Dhelp=enabled \
-Dlua_version=5.1 \
-Ddefault_library=static \
-Durl_backend=wget \
-Dzstd=false \
-Dpython=disabled \
-Dtests=disabled
MESON_HOST_ARGS += \
$(MESON_COMMON_ARGS) \
-Dcrypto_backend=openssl
MESON_ARGS += \
$(MESON_COMMON_ARGS) \
-Dcrypto_backend=$(BUILD_VARIANT)
define Package/apk/conffiles
/etc/apk/repositories.d/customfeeds.list
endef
Package/apk-mbedtls/conffiles = $(Package/apk/conffiles)
Package/apk-openssl/conffiles = $(Package/apk/conffiles)
define Package/apk/default/install
$(INSTALL_DIR) $(1)/lib/apk/db
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/apk $(1)/usr/bin/apk
$(INSTALL_DIR) $(1)/etc/apk/repositories.d
$(INSTALL_DATA) ./files/customfeeds.list $(1)/etc/apk/repositories.d/customfeeds.list
endef
Package/apk-mbedtls/install = $(Package/apk/default/install)
Package/apk-openssl/install = $(Package/apk/default/install)
$(eval $(call BuildPackage,apk-mbedtls))
$(eval $(call BuildPackage,apk-openssl))
$(eval $(call HostBuild))