osbuilder:rootfs: support to unpack pause image to rootfs

This env ver will serve us to pass the pause image tarball to the rootfs builder, which will then just
unpack the content into the rootfs.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
Co-authored-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
Co-authored-by: Wang, Arron <arron.wang@intel.com>
Co-authored-by: stevenhorsman <steven@uk.ibm.com>
Co-authored-by: Jakob Naucke <jakob.naucke@ibm.com>
This commit is contained in:
ChengyuZhu6 2024-02-06 19:40:51 +08:00
parent 53183cba31
commit 42ef6bdcae
2 changed files with 16 additions and 2 deletions

View File

@ -32,6 +32,7 @@ AGENT_SOURCE_BIN=${AGENT_SOURCE_BIN:-""}
AGENT_TARBALL=${AGENT_TARBALL:-""} AGENT_TARBALL=${AGENT_TARBALL:-""}
COCO_GUEST_COMPONENTS_TARBALL=${COCO_GUEST_COMPONENTS_TARBALL:-""} COCO_GUEST_COMPONENTS_TARBALL=${COCO_GUEST_COMPONENTS_TARBALL:-""}
CONFIDENTIAL_GUEST="${CONFIDENTIAL_GUEST:-no}" CONFIDENTIAL_GUEST="${CONFIDENTIAL_GUEST:-no}"
PAUSE_IMAGE_TARBALL=${PAUSE_IMAGE_TARBALL:-""}
lib_file="${script_dir}/../scripts/lib.sh" lib_file="${script_dir}/../scripts/lib.sh"
source "$lib_file" source "$lib_file"
@ -176,6 +177,12 @@ KERNEL_MODULES_DIR Path to a directory containing kernel modules to include in
LIBC libc the agent is built against (gnu or musl). LIBC libc the agent is built against (gnu or musl).
Default value: ${LIBC} (varies with architecture) Default value: ${LIBC} (varies with architecture)
PAUSE_IMAGE_TARBALL Path to the kata-static-pause-image.tar.xz tarball to be unpacked inside the
rootfs.
If set, the tarball will be unpacked onto the rootfs.
Default value: <not set>
ROOTFS_DIR Path to the directory that is populated with the rootfs. ROOTFS_DIR Path to the directory that is populated with the rootfs.
Default value: <${script_name} path>/rootfs-<DISTRO-name> Default value: <${script_name} path>/rootfs-<DISTRO-name>
@ -796,6 +803,11 @@ EOF
[ -x "${init}" ] || [ -L "${init}" ] || die "/sbin/init is not installed in ${ROOTFS_DIR}" [ -x "${init}" ] || [ -L "${init}" ] || die "/sbin/init is not installed in ${ROOTFS_DIR}"
OK "init is installed" OK "init is installed"
if [ -n "${PAUSE_IMAGE_TARBALL}" ] ; then
info "Installing the pause image tarball"
tar xvJpf ${PAUSE_IMAGE_TARBALL} -C ${ROOTFS_DIR}
fi
if [ -n "${COCO_GUEST_COMPONENTS_TARBALL}" ] ; then if [ -n "${COCO_GUEST_COMPONENTS_TARBALL}" ] ; then
info "Installing the Confidential Containers guest components tarball" info "Installing the Confidential Containers guest components tarball"
tar xvJpf ${COCO_GUEST_COMPONENTS_TARBALL} -C ${ROOTFS_DIR} tar xvJpf ${COCO_GUEST_COMPONENTS_TARBALL} -C ${ROOTFS_DIR}

View File

@ -45,7 +45,8 @@ build_initrd() {
AGENT_TARBALL="${AGENT_TARBALL}" \ AGENT_TARBALL="${AGENT_TARBALL}" \
AGENT_INIT="yes" \ AGENT_INIT="yes" \
AGENT_POLICY="${AGENT_POLICY:-}" \ AGENT_POLICY="${AGENT_POLICY:-}" \
COCO_GUEST_COMPONENTS_TARBALL="${COCO_GUEST_COMPONENTS_TARBALL:-}" COCO_GUEST_COMPONENTS_TARBALL="${COCO_GUEST_COMPONENTS_TARBALL:-}" \
PAUSE_IMAGE_TARBALL="${PAUSE_IMAGE_TARBALL:-}"
mv "kata-containers-initrd.img" "${install_dir}/${artifact_name}" mv "kata-containers-initrd.img" "${install_dir}/${artifact_name}"
( (
cd "${install_dir}" cd "${install_dir}"
@ -65,7 +66,8 @@ build_image() {
ROOTFS_BUILD_DEST="${builddir}/rootfs-image" \ ROOTFS_BUILD_DEST="${builddir}/rootfs-image" \
AGENT_TARBALL="${AGENT_TARBALL}" \ AGENT_TARBALL="${AGENT_TARBALL}" \
AGENT_POLICY="${AGENT_POLICY:-}" \ AGENT_POLICY="${AGENT_POLICY:-}" \
COCO_GUEST_COMPONENTS_TARBALL="${COCO_GUEST_COMPONENTS_TARBALL:-}" COCO_GUEST_COMPONENTS_TARBALL="${COCO_GUEST_COMPONENTS_TARBALL:-}" \
PAUSE_IMAGE_TARBALL="${PAUSE_IMAGE_TARBALL:-}"
mv -f "kata-containers.img" "${install_dir}/${artifact_name}" mv -f "kata-containers.img" "${install_dir}/${artifact_name}"
if [ -e "root_hash.txt" ]; then if [ -e "root_hash.txt" ]; then
cp root_hash.txt "${install_dir}/" cp root_hash.txt "${install_dir}/"