[Buildroot] [PATCH 1/1] package/apk-tools: new package

Thomas Petazzoni thomas.petazzoni at bootlin.com
Mon Aug 1 22:16:29 UTC 2022


Hello,

Thanks for your contribution.

On Wed, 11 May 2022 04:45:08 -0700
TIAN Yuanhao <tianyuanhao3 at 163.com> wrote:

> Alpine Package Keeper (apk) is a package manager developed for Alpine
> Linux.
> 
> Signed-off-by: TIAN Yuanhao <tianyuanhao3 at 163.com>
> ---
> 
> I did read [1] before I submitted this patch.
> 
> I need a package manager in an embedded system and I found there are
> some Buildroot based projects having similar things like [2] and [3].
> Given the popularity of Alpine Linux in containers, I would like to
> choose apk as the package manager.
> 
> There is a performance comparison of package managers at [4].
> 
> An interesting finding is that OpenWrt seems to be planning to switch
> from opkg to apk [5].
> 
> In conclusion, I think Buildroot should have apk.
> 
> [1]: http://patchwork.ozlabs.org/project/buildroot/patch/1426736888-29437-5-git-send-email-steven@uplinklabs.net/
> [2]: https://github.com/batocera-linux/batocera.linux/blob/5.27/package/batocera/utils/pacman/pacman.mk
> [3]: https://github.com/gportay/linux-distros-br2-external/blob/master/package/apk-tools/apk-tools.mk
> [4]: https://michael.stapelberg.ch/posts/2019-08-17-linux-package-managers-are-slow/#measurements
> [5]: https://github.com/openwrt/openwrt/pull/4294

Thanks for your contribution and this argumentation. I will need some
feedback from other Buildroot maintainers before we can merge this
patch.

Could you describe a bit more how you are going to use it in the
context of Buildroot (which, as a reminder, doesn't support generate
binary packages) ?


> diff --git a/package/apk-tools/Config.in b/package/apk-tools/Config.in
> new file mode 100644
> index 0000000000..a7926a7c70
> --- /dev/null
> +++ b/package/apk-tools/Config.in
> @@ -0,0 +1,12 @@
> +config BR2_PACKAGE_APK_TOOLS
> +	bool "apk-tools"
> +	depends on !BR2_STATIC_LIBS # unconditionally shared
> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5 # compound literals

Then you need a Config.in "comment", look at how other packages do this.

> +	depends on BR2_USE_MMU # fork()
> +	select BR2_PACKAGE_OPENSSL
> +	select BR2_PACKAGE_ZLIB
> +	help
> +	  Alpine Package Keeper (apk) is a package manager developed for
> +	  Alpine Linux.
> +
> +	  https://gitlab.alpinelinux.org/alpine/apk-tools
> diff --git a/package/apk-tools/apk-tools.hash b/package/apk-tools/apk-tools.hash
> new file mode 100644
> index 0000000000..a9ec2fb2ce
> --- /dev/null
> +++ b/package/apk-tools/apk-tools.hash
> @@ -0,0 +1,3 @@
> +# Locally calculated
> +sha256  6362d8a14bb0460f15a041754148344cbfc0a953461c702717e0d263d054db4d  apk-tools-v2.12.9.tar.bz2
> +sha256  b3c87315aae4c9f276c37168f2655dd8bd990544d7a0bbfb929664155c7ab257  LICENSE
> diff --git a/package/apk-tools/apk-tools.mk b/package/apk-tools/apk-tools.mk
> new file mode 100644
> index 0000000000..b92092cd73
> --- /dev/null
> +++ b/package/apk-tools/apk-tools.mk
> @@ -0,0 +1,53 @@
> +################################################################################
> +#
> +# apk-tools
> +#
> +################################################################################
> +
> +# Regenerate help.h when changing the version number
> +APK_TOOLS_VERSION = 2.12.9
> +APK_TOOLS_SITE = https://gitlab.alpinelinux.org/alpine/apk-tools/-/archive/v$(APK_TOOLS_VERSION)
> +APK_TOOLS_SOURCE = apk-tools-v$(APK_TOOLS_VERSION).tar.bz2
> +APK_TOOLS_LICENSE = GPL-2.0
> +APK_TOOLS_LICENSE_FILES = LICENSE
> +
> +APK_TOOLS_DEPENDENCIES = host-pkgconf openssl zlib
> +
> +APK_TOOLS_MAKE_OPTS = \
> +	CROSS_COMPILE="$(TARGET_CROSS)" \
> +	LUA=no \
> +	SCDOC=: \
> +	V=1 \

V=1 should probably be conditional on the $(QUIET) variable.

> +	cmd_genhelp=:

I think we prefer to use /bin/true instead of : in such situations.

> +
> +ifeq ($(BR2_SHARED_LIBS),y)
> +APK_TOOLS_MAKE_OPTS += \
> +	PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)"
> +else
> +APK_TOOLS_MAKE_OPTS += \
> +	PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY) --static" \

This should not be needed, in the BR2_STATIC_LIBS case, pkg-config
already uses --static.

> +	STATIC=y

Isn't this forcing static linking? Your Config.in prevents
BR2_STATIC_LIBS=y configuration, so in the else clause of
BR2_SHARED_LIBS, you only have BR2_SHARED_STATIC_LIBS=y, a case where
we want to link dynamically but (ideally) build/install both shared and
static libraries (even though clearly many of our packages do not
comply with this).

> +endif
> +
> +define APK_TOOLS_CONFIGURE_CMDS
> +	$(SED) 's/#\S\+\s\(APK_DEFAULT_ARCH\)\s.*/#define \1 $(BR2_ARCH)/' \
> +		$(@D)/src/apk_defines.h
> +	# Copy the pre-generated help.h so we don't need host-lua
> +	$(INSTALL) -D -m 644 $(APK_TOOLS_PKGDIR)/help.h $(@D)/src/help.h

Please add host-lua as a dependency. This pre-generated help.h is
really horrible :-/

> +define APK_TOOLS_BUILD_CMDS
> +	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
> +		$(APK_TOOLS_MAKE_OPTS)
> +endef
> +
> +define APK_TOOLS_INSTALL_TARGET_CMDS
> +	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) install \
> +		$(APK_TOOLS_MAKE_OPTS) \
> +		DESTDIR=$(TARGET_DIR)
> +	# Prepare an empty apk database
> +	$(INSTALL) -D -m 644 /dev/null $(TARGET_DIR)/etc/apk/world

What are you trying to do here? Seems weird to install /dev/null.

Best regards,

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com



More information about the buildroot mailing list