Skip to content

Commit

Permalink
osbuilder:rootfs: support to unpack pause image to rootfs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
5 people committed Feb 7, 2024
1 parent 3da211b commit 9699a00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions tools/osbuilder/rootfs-builder/rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ AGENT_SOURCE_BIN=${AGENT_SOURCE_BIN:-""}
AGENT_TARBALL=${AGENT_TARBALL:-""}
COCO_GUEST_COMPONENTS_TARBALL=${COCO_GUEST_COMPONENTS_TARBALL:-""}
CONFIDENTIAL_GUEST="${CONFIDENTIAL_GUEST:-no}"
PAUSE_IMAGE_TARBALL=${PAUSE_IMAGE_TARBALL:-""}

lib_file="${script_dir}/../scripts/lib.sh"
source "$lib_file"
Expand Down Expand Up @@ -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).
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.
Default value: <${script_name} path>/rootfs-<DISTRO-name>
Expand Down Expand Up @@ -796,6 +803,11 @@ EOF
[ -x "${init}" ] || [ -L "${init}" ] || die "/sbin/init is not installed in ${ROOTFS_DIR}"
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
info "Installing the Confidential Containers guest components tarball"
tar xvJpf ${COCO_GUEST_COMPONENTS_TARBALL} -C ${ROOTFS_DIR}
Expand Down
6 changes: 4 additions & 2 deletions tools/packaging/guest-image/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ build_initrd() {
AGENT_TARBALL="${AGENT_TARBALL}" \
AGENT_INIT="yes" \
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}"
(
cd "${install_dir}"
Expand All @@ -65,7 +66,8 @@ build_image() {
ROOTFS_BUILD_DEST="${builddir}/rootfs-image" \
AGENT_TARBALL="${AGENT_TARBALL}" \
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}"
if [ -e "root_hash.txt" ]; then
cp root_hash.txt "${install_dir}/"
Expand Down

0 comments on commit 9699a00

Please sign in to comment.