[Buildroot] [PATCH/next 6/6] package/micromamba: new package

Thomas Petazzoni thomas.petazzoni at bootlin.com
Tue Feb 7 16:26:15 UTC 2023


Hello,

On Mon, 28 Nov 2022 12:34:18 +0000
TIAN Yuanhao <tianyuanhao3 at 163.com> wrote:

> Signed-off-by: TIAN Yuanhao <tianyuanhao3 at 163.com>

Thanks for this submission. Could you clarify what is the motivation
for this package? Indeed having a package manager on the target feels a
bit strange in the context of Buildroot. Buildroot is normally there
precisely to generate a ready-to-use rootfs, not a rootfs which then
downloads random stuff from the Internet.

Of course, we do have npm or pip, but really their usage is not
recommended.


> diff --git a/package/micromamba/Config.in b/package/micromamba/Config.in
> new file mode 100644
> index 0000000000..998809f452
> --- /dev/null
> +++ b/package/micromamba/Config.in
> @@ -0,0 +1,43 @@
> +config BR2_PACKAGE_MICROMAMBA_ARCH_SUPPORTS
> +	bool
> +	# See libmamba/include/mamba/core/context.hpp
> +	default y if BR2_arm && (BR2_ARM_CPU_ARMV6 || BR2_ARM_CPU_ARMV7A)
> +	default y if BR2_aarch64
> +	default y if BR2_i386
> +	default y if BR2_powerpc64
> +	default y if BR2_powerpc64le
> +	default y if BR2_s390x
> +	default y if BR2_x86_64
> +	depends on BR2_USE_MMU # fork()

Always a bit annoying to have architecture-specific things in something
that isn't hardware-related in the first place, but OK.

> +config BR2_PACKAGE_MICROMAMBA
> +	bool "micromamba"
> +	depends on BR2_PACKAGE_MICROMAMBA_ARCH_SUPPORTS
> +	depends on BR2_USE_WCHAR # fmt, reproc

libarchive also needs wchar, spdlog as well (through fmt, admittedly)

> +	depends on BR2_INSTALL_LIBSTDCPP
> +	depends on BR2_TOOLCHAIN_HAS_THREADS # pthread
> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8 # C++17 filesystem
> +	select BR2_PACKAGE_LIBARCHIVE
> +	select BR2_PACKAGE_OPENSSL
> +	select BR2_PACKAGE_JSON_FOR_MODERN_CPP
> +	select BR2_PACKAGE_YAML_CPP
> +	select BR2_PACKAGE_SPDLOG
> +	select BR2_PACKAGE_LIBCURL
> +	select BR2_PACKAGE_LIBSOLV
> +	select BR2_PACKAGE_REPROC
> +	select BR2_PACKAGE_TL_EXPECTED
> +	select BR2_PACKAGE_CLI11
> +	select BR2_PACKAGE_FMT
> +	select BR2_PACKAGE_TERMCOLOR

These select should be sorted alphabetically to look a bit nicer.

> +	help
> +	  micromamba is a small, pure-C++ reimplementation of
> +	  mamba/conda. It strives to be a full replacement for mamba and
> +	  conda.
> +
> +	  https://github.com/mamba-org/mamba
> +
> +comment "micromamba needs a toolchain w/ wchar, threads, C++, gcc >= 8"
> +	depends on BR2_PACKAGE_MICROMAMBA_ARCH_SUPPORTS
> +	depends on !BR2_USE_WCHAR || !BR2_INSTALL_LIBSTDCPP || \
> +		!BR2_TOOLCHAIN_HAS_THREADS || \
> +		!BR2_TOOLCHAIN_GCC_AT_LEAST_8
> diff --git a/package/micromamba/micromamba.hash b/package/micromamba/micromamba.hash
> new file mode 100644
> index 0000000000..e584c3bd28
> --- /dev/null
> +++ b/package/micromamba/micromamba.hash
> @@ -0,0 +1,3 @@
> +# Locally calculated
> +sha256  7303d983b49a1a52b302ceae355af1c05afef3a07aa3ad6dd27c36d64c43f991  micromamba-1.0.0.tar.gz
> +sha256  41fd98a468e39d319911bd94f4e65d6ad6a7ea66559dd5aa4112f138ff9b629a  LICENSE
> diff --git a/package/micromamba/micromamba.mk b/package/micromamba/micromamba.mk
> new file mode 100644
> index 0000000000..188864444c
> --- /dev/null
> +++ b/package/micromamba/micromamba.mk
> @@ -0,0 +1,43 @@
> +################################################################################
> +#
> +# micromamba
> +#
> +################################################################################
> +
> +MICROMAMBA_VERSION = 1.0.0
> +MICROMAMBA_SITE = $(call github,mamba-org,mamba,micromamba-$(MICROMAMBA_VERSION))
> +MICROMAMBA_LICENSE = BSD-3-Clause
> +MICROMAMBA_LICENSE_FILES = LICENSE
> +MICROMAMBA_DEPENDENCIES = \
> +	$(BR2_PYTHON3_HOST_DEPENDENCY) \
> +	cli11 \
> +	fmt \
> +	json-for-modern-cpp \
> +	libarchive \
> +	libcurl \
> +	libsolv \
> +	openssl \
> +	reproc \
> +	spdlog \
> +	termcolor \
> +	tl-expected \
> +	yaml-cpp
> +
> +MICROMAMBA_CONF_OPTS = -DBUILD_LIBMAMBA=ON -DBUILD_MICROMAMBA=ON
> +
> +# See libmamba/include/mamba/core/context.hpp
> +ifeq ($(BR2_ARM_CPU_ARMV6),y)
> +MICROMAMBA_CONF_OPTS += -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -D___ARM_ARCH_6__"
> +else ifeq ($(BR2_ARM_CPU_ARMV7A),y)
> +MICROMAMBA_CONF_OPTS += -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -D__ARM_ARCH_7__"
> +endif

This is really a bug in the mamba code, because these defines are
normally provided by the compiler. For example, an ARMv7 compiler
defines:

#define __ARM_ARCH 7
#define __ARM_ARCH_7A__ 1

So mamba could use that instead.

But one could even wonder why it really matters to define a different
MAMBA_PLATFORM name:

#ifdef ___ARM_ARCH_6__
        static const char MAMBA_PLATFORM[] = "linux-armv6l";
#elif __ARM_ARCH_7__
        static const char MAMBA_PLATFORM[] = "linux-armv7l";
#else

It is really crazy that this is the *only* thing that causes mamba to
have an architecture dependency. Why is that even needed in the first
place?

> +
> +ifeq ($(BR2_STATIC_LIBS),y)
> +MICROMAMBA_CONF_OPTS += -DBUILD_STATIC=ON -DMICROMAMBA_LINKAGE=FULL_STATIC
> +else ifeq ($(BR2_SHARED_STATIC_LIBS),y)
> +MICROMAMBA_CONF_OPTS += -DBUILD_SHARED=ON -DBUILD_STATIC=ON
> +else # BR2_SHARED_LIBS
> +MICROMAMBA_CONF_OPTS += -DBUILD_SHARED=ON
> +endif

Please pass BUILD_STATIC=OFF and BUILD_SHARED=OFF explicitly in the
appropriate cases.

Thanks a lot!

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



More information about the buildroot mailing list