container-base: make CONTAINER_SHELL a conditional image install

In some scenarios (and package managers), packages post install
scripts may have references to /bin/sh.

The package manager doesn't know if the scripts will run on the
build host or target, so we get a calculated redepnds on /bin/sh

base-files and base-passwd fall into this category of having
post installs, but no need for /bin/sh on the target.

If you know what you are installing, and want the smallest
container possible, this package will satisfy the dependency when
assembling the rootfs.

To enable it, put the following in a configuration file (local.conf
or otherwise):

    PACKAGE_EXTRA_ARCHS_append = " container-dummy-provides"

This image will detect if the dummy provides arch is set, and will
automatically install the providing recipe, otherwise, busybox is
installed.

If you have a custom shell or want a different behaviour, the
CONTAINER_SHELL variable can be overriden.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Bruce Ashfield 2020-09-30 12:33:43 -04:00
parent e9a8756758
commit afef7f0635

View File

@ -18,8 +18,20 @@ IMAGE_INSTALL = " \
base-files \
base-passwd \
netbase \
${CONTAINER_SHELL} \
"
# If the following is configured in local.conf (or the distro):
# PACKAGE_EXTRA_ARCHS_append = " container-dummy-provides"
#
# it has been explicitly # indicated that we don't want or need a shell, so we'll
# add the dummy provides.
#
# This is required, since there are postinstall scripts in base-files and base-passwd
# that reference /bin/sh and we'll get a rootfs error if there's no shell or no dummy
# provider.
CONTAINER_SHELL ?= "${@bb.utils.contains('PACKAGE_EXTRA_ARCHS', 'container-dummy-provides', 'container-dummy-provides', 'busybox', d)}"
# Allow build with or without a specific kernel
IMAGE_CONTAINER_NO_DUMMY = "1"