image: Require systemd

Building an image requires systemd to be installed in the rootfs as the
init daemon, so assert that systemd is available.

Updated tests so that alpine is only tested as an initrd (it cannot be
an image as it doesn't use systemd).

Added warning note about alpine to the docs.

Fixes #98.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2018-05-18 11:05:12 +01:00
parent 171eceb426
commit aca45c5820
4 changed files with 26 additions and 7 deletions

View File

@ -16,6 +16,9 @@ $ sudo ./image_builder.sh path/to/rootfs
Where `path/to/rootfs` is the directory populated by `rootfs.sh`. Where `path/to/rootfs` is the directory populated by `rootfs.sh`.
> **Note**: If you are building an image from an Alpine rootfs, see
> the important note [here](rootfs-builder/README.md#rootfs-requirements).
## Further information ## Further information
For more information about usage (including how to adjust the size of the For more information about usage (including how to adjust the size of the

View File

@ -117,6 +117,15 @@ init_path="/sbin/init"
init="${ROOTFS}${init_path}" init="${ROOTFS}${init_path}"
[ -x "${init}" ] || [ -L ${init} ] || die "${init_path} is not installed in ${ROOTFS}" [ -x "${init}" ] || [ -L ${init} ] || die "${init_path} is not installed in ${ROOTFS}"
OK "init is installed" OK "init is installed"
if [ "${AGENT_INIT}" == "no" ]
then
systemd_path="/lib/systemd/systemd"
systemd="${ROOTFS}${systemd_path}"
[ -x "${systemd}" ] || [ -L ${systemd} ] || die "${systemd_path} is not installed in ${ROOTFS}"
OK "init is systemd"
fi
[ "${AGENT_INIT}" == "yes" ] || [ -x "${ROOTFS}/usr/bin/${AGENT_BIN}" ] || \ [ "${AGENT_INIT}" == "yes" ] || [ -x "${ROOTFS}/usr/bin/${AGENT_BIN}" ] || \
die "/usr/bin/${AGENT_BIN} is not installed in ${ROOTFS} die "/usr/bin/${AGENT_BIN} is not installed in ${ROOTFS}
use AGENT_BIN env variable to change the expected agent binary name" use AGENT_BIN env variable to change the expected agent binary name"

View File

@ -41,6 +41,9 @@ The rootfs must provide at least the following components:
When the `AGENT_INIT` environment variable is set to `yes`, use Kata agent as `/sbin/init`. When the `AGENT_INIT` environment variable is set to `yes`, use Kata agent as `/sbin/init`.
> **Note**: `AGENT_INIT=yes` **must** be used for the Alpine distribution
> since it does not use `systemd` as its init daemon.
## Creating a rootfs ## Creating a rootfs
To build a rootfs for your chosen distribution, run: To build a rootfs for your chosen distribution, run:

View File

@ -48,22 +48,26 @@ function build_initrd()
function build_rootfs_image_initrd() function build_rootfs_image_initrd()
{ {
distro="$1" distro="$1"
image="$2"
initrd="$3"
[ -n "$distro" ] [ -n "$distro" ]
build_rootfs $distro build_rootfs $distro
build_image
build_initrd [ "$image" = "yes" ] && build_image
[ "$initrd" = "yes" ] && build_initrd
} }
@test "Can create fedora image" { @test "Can create fedora image" {
build_rootfs_image_initrd fedora build_rootfs_image_initrd fedora yes yes
} }
@test "Can create clearlinux image" { @test "Can create clearlinux image" {
build_rootfs_image_initrd clearlinux build_rootfs_image_initrd clearlinux yes yes
} }
@test "Can create centos image" { @test "Can create centos image" {
build_rootfs_image_initrd centos build_rootfs_image_initrd centos yes yes
} }
@test "Can create euleros image" { @test "Can create euleros image" {
@ -71,9 +75,9 @@ function build_rootfs_image_initrd()
then then
skip "travis timeout, see: https://github.com/kata-containers/osbuilder/issues/46" skip "travis timeout, see: https://github.com/kata-containers/osbuilder/issues/46"
fi fi
build_rootfs_image_initrd euleros build_rootfs_image_initrd euleros yes yes
} }
@test "Can create alpine image" { @test "Can create alpine image" {
build_rootfs_image_initrd alpine build_rootfs_image_initrd alpine no yes
} }