mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-21 23:34:22 +01:00
Create a YAML metadata file inside the rootfs image containing information about the environment: ``` /var/lib/osbuilder/osbuilder.yaml ``` Example contents: ``` --- osbuilder: url: "https://github.com/kata-containers/osbuilder" version: "unknown" rootfs-creation-time: "2018-04-19T16:19:30.254610305+0000Z" description: "osbuilder rootfs" file-format-version: "0.0.1" architecture: "x86_64" base-distro: name: "Centos" version: "7" packages: - "iptables" - "systemd" agent: url: "https://github.com/kata-containers/agent" name: "kata-agent" version: "0.0.1-2ec0b9593845b9a5e0eab5a85b20d74c35a2ca52-dirty" agent-is-init-daemon: "no" ``` This change adds a new `-o` option to `rootfs.sh` for specifying the version of osbuilder to the rootfs builder. Fixes #35. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
80 lines
1.7 KiB
Bash
80 lines
1.7 KiB
Bash
#!/usr/bin/env bats
|
|
#
|
|
# Copyright (c) 2018 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
rootfs_sh="$BATS_TEST_DIRNAME/../rootfs-builder/rootfs.sh"
|
|
image_builder_sh="$BATS_TEST_DIRNAME/../image-builder/image_builder.sh"
|
|
initrd_builder_sh="$BATS_TEST_DIRNAME/../initrd-builder/initrd_builder.sh"
|
|
readonly tmp_dir=$(mktemp -t -d osbuilder-test.XXXXXXX)
|
|
tmp_rootfs="${tmp_dir}/rootfs-osbuilder"
|
|
#FIXME: Remove image size after https://github.com/kata-containers/osbuilder/issues/25 is fixed
|
|
readonly image_size=400
|
|
|
|
|
|
setup()
|
|
{
|
|
export USE_DOCKER=true
|
|
}
|
|
|
|
teardown(){
|
|
# Rootfs is own by root change it to remove it
|
|
sudo rm -rf "${tmp_rootfs}"
|
|
rm -rf "${tmp_dir}"
|
|
}
|
|
|
|
function build_rootfs()
|
|
{
|
|
local file="/var/lib/osbuilder/osbuilder.yaml"
|
|
local full="${tmp_rootfs}${file}"
|
|
|
|
sudo -E ${rootfs_sh} -r "${tmp_rootfs}" "${distro}"
|
|
|
|
yamllint "${full}"
|
|
}
|
|
|
|
function build_image()
|
|
{
|
|
sudo -E ${image_builder_sh} -s ${image_size} -o "${tmp_dir}/image.img" "${tmp_rootfs}"
|
|
}
|
|
|
|
function build_initrd()
|
|
{
|
|
sudo -E ${initrd_builder_sh} -o "${tmp_dir}/initrd-image.img" "${tmp_rootfs}"
|
|
}
|
|
|
|
function build_rootfs_image_initrd()
|
|
{
|
|
distro="$1"
|
|
[ -n "$distro" ]
|
|
build_rootfs $distro
|
|
build_image
|
|
build_initrd
|
|
}
|
|
|
|
@test "Can create fedora image" {
|
|
build_rootfs_image_initrd fedora
|
|
}
|
|
|
|
@test "Can create clearlinux image" {
|
|
build_rootfs_image_initrd clearlinux
|
|
}
|
|
|
|
@test "Can create centos image" {
|
|
build_rootfs_image_initrd centos
|
|
}
|
|
|
|
@test "Can create euleros image" {
|
|
if [ "$TRAVIS" = true ]
|
|
then
|
|
skip "travis timeout, see: https://github.com/kata-containers/osbuilder/issues/46"
|
|
fi
|
|
build_rootfs_image_initrd euleros
|
|
}
|
|
|
|
@test "Can create alpine image" {
|
|
build_rootfs_image_initrd alpine
|
|
}
|