@@ -33,17 +33,7 @@ KATA_ARTIFACT_NEW_NAME="kata-static.tar.xz"
3333KATA_PATCH_DIR=" patch/${KATA_CONTAINERS_TAG} "
3434KATA_BOOT_COMPONENT_DIR=" ${KATA_ARTIFACT_DIR} /opt/kata/share/kata-containers"
3535KATA_ARTIFACT_KERNEL_NAME=" vmlinux.container"
36- KATA_ARTIFACT_TOOTFS_NAME=" kata-containers.img"
37-
38-
39- KATA_KEEPLIST_FILE_LIST=( " VERSION" " containerd-shim-kata-v2" " kata-agent-ctl" " kata-collect-data.sh" " kata-ctl" " kata-manager"
40- " kata-manager.sh" " kata-monitor" " kata-runtime" " kata-trace-forwarder" " qemu-system-x86_64" " stratovirt" " fdt.h" " libfdt.h"
41- " libfdt_env.h" " libfdt.a" " libfdt.pc" " virtiofsd" " oci_config.json" " configuration.toml" " configuration-qemu.toml"
42- " genpolicy-settings.json" " rules.rego" " root_hash.txt" " bios-256k.bin" " efi-virtio.rom" " kvmvapic.bin" " linuxboot_dma.bin"
43- " pvh.bin" " versions.yaml" )
44-
45- KATA_DELETE_FILE_LIST=(" runtime-rs" " share/defaults/kata-containers/runtime-rs" " share/kata-qemu/qemu/firmware" " share/kata-qemu-snp-experimental"
46- " lib/kata-qemu-snp-experimental" " share/ovmf" )
36+ KATA_ARTIFACT_ROOTFS_NAME=" kata-containers.img"
4737
4838check_file_exists () {
4939 local file=" ${1} "
@@ -82,26 +72,12 @@ echo "INFO: Extracting Kata artifacts"
8272mkdir -p " ${KATA_ARTIFACT_DIR} "
8373tar -xf " ${KATA_ARTIFACT_FILE_NAME} " -C " ${KATA_ARTIFACT_DIR} "
8474
85- # Iterate over files and symlinks in the directory and remove the files not in the keeplist
86- find " ${KATA_ARTIFACT_DIR} " -type f -o -type l | while read -r item; do
87- base_item=$( basename " $item " )
88- if [[ ! " ${KATA_KEEPLIST_FILE_LIST[@]} " =~ " ${base_item} " ]]; then
89- # echo "INFO: Deleting: $item (not in keeplist)"
90- rm -rf " $item "
91- fi
92- done
93-
94- # iterate over the delete file list and remove the files
95- pushd " ${KATA_ARTIFACT_DIR} /opt/kata"
96- for file in " ${KATA_DELETE_FILE_LIST[@]} " ; do
97- echo " INFO: Removing ${file} "
98- rm -rf " ${file} "
99- done
100- popd
101-
10275# check if the boot component directory exists
10376check_dir_exists " ${KATA_BOOT_COMPONENT_DIR} "
10477
78+ # create bm-agents group if it does not exist
79+ getent group bm-agents > /dev/null || groupadd -g 500 bm-agents
80+
10581# copy edge microvisor kernel to the kata artifacts
10682echo " INFO: Copying edge microvisor kernel to the Kata artifacts"
10783cp " ${EDGE_MICROVISOR_SRC} /${EDGE_MICROVISOR_KERNEL} " " ${KATA_BOOT_COMPONENT_DIR} "
@@ -117,7 +93,29 @@ cp "${EDGE_MICROVISOR_SRC}/${EDGE_MICROVISOR_ROOTFS}" "${KATA_BOOT_COMPONENT_DIR
11793# change symlink to point to the new kernel and rootfs
11894echo " INFO: Change symlink to point to the new kernel and rootfs"
11995ln -sf " ${EDGE_MICROVISOR_KERNEL} " " ${KATA_BOOT_COMPONENT_DIR} /${KATA_ARTIFACT_KERNEL_NAME} "
120- ln -sf " ${EDGE_MICROVISOR_ROOTFS} " " ${KATA_BOOT_COMPONENT_DIR} /${KATA_ARTIFACT_TOOTFS_NAME} "
96+ ln -sf " ${EDGE_MICROVISOR_ROOTFS} " " ${KATA_BOOT_COMPONENT_DIR} /${KATA_ARTIFACT_ROOTFS_NAME} "
97+
98+ # Iterate over all files, directories, clean up unwanted files and directories and set permission and onwership
99+ chmod 750 " ${KATA_ARTIFACT_DIR} /opt/kata"
100+ chown root:bm-agents " ${KATA_ARTIFACT_DIR} /opt/kata"
101+
102+ pushd " ${KATA_ARTIFACT_DIR} /opt/kata"
103+ for file in $( find . -type f -o -type d -o -type l | sed ' s|^\./||' ) ; do
104+ match=$( awk -v search=" $file " ' $0 ~ search { print $0; found=1; exit } END { if (!found) print ""; exit }' ../../../kata_keeplist.txt)
105+ if [[ -n " $match " ]]; then
106+ chown $( echo " $match " | awk ' {print $2}' ) " $file "
107+ chmod $( echo " $match " | awk ' {print $3}' ) " $file "
108+ else
109+ if [[ " $file " == * " $EDGE_MICROVISOR_KERNEL " * ]]; then
110+ chown root:bm-agents " $file " && chmod 640 " $file "
111+ elif [[ " $file " == * " $EDGE_MICROVISOR_KERNEL_CONFIG " * ]]; then
112+ chown root:root " $file " && chmod 600 " $file "
113+ else
114+ rm -rf " $file "
115+ fi
116+ fi
117+ done
118+ popd
121119
122120# retar the artifacts
123121echo " INFO: Retar the artifacts"
0 commit comments