mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-05 19:47:53 +00:00
ci: remove sudo and make sure image is owed by user
The image build needs special handling since we're doing a lot of privileged operations. Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
This commit is contained in:
parent
f093c4c190
commit
a48c084e13
@ -201,6 +201,8 @@ build_with_container() {
|
|||||||
--env DEBUG="${DEBUG}" \
|
--env DEBUG="${DEBUG}" \
|
||||||
--env ARCH="${ARCH}" \
|
--env ARCH="${ARCH}" \
|
||||||
--env TARGET_ARCH="${TARGET_ARCH}" \
|
--env TARGET_ARCH="${TARGET_ARCH}" \
|
||||||
|
--env USER="$(id -u)" \
|
||||||
|
--env GROUP="$(id -g)" \
|
||||||
-v /dev:/dev \
|
-v /dev:/dev \
|
||||||
-v "${script_dir}":"/osbuilder" \
|
-v "${script_dir}":"/osbuilder" \
|
||||||
-v "${script_dir}/../scripts":"/scripts" \
|
-v "${script_dir}/../scripts":"/scripts" \
|
||||||
@ -609,9 +611,6 @@ set_dax_header() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
[ "$(id -u)" -eq 0 ] || die "$0: must be run as root"
|
|
||||||
[ "$#" -eq 0 ] && usage && return 0
|
|
||||||
|
|
||||||
# variables that can be overwritten by environment variables
|
# variables that can be overwritten by environment variables
|
||||||
local agent_bin="${AGENT_BIN:-kata-agent}"
|
local agent_bin="${AGENT_BIN:-kata-agent}"
|
||||||
local agent_init="${AGENT_INIT:-no}"
|
local agent_init="${AGENT_INIT:-no}"
|
||||||
@ -678,6 +677,8 @@ main() {
|
|||||||
fi
|
fi
|
||||||
# insert at the beginning of the image the MBR + DAX header
|
# insert at the beginning of the image the MBR + DAX header
|
||||||
set_dax_header "${image}" "${img_size}" "${fs_type}" "${nsdax_bin}"
|
set_dax_header "${image}" "${img_size}" "${fs_type}" "${nsdax_bin}"
|
||||||
|
|
||||||
|
chown "${USER}:${GROUP}" "${image}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
@ -73,7 +73,7 @@ OK "init is installed"
|
|||||||
OK "Agent is installed"
|
OK "Agent is installed"
|
||||||
|
|
||||||
# initramfs expects /init
|
# initramfs expects /init
|
||||||
ln -sf /sbin/init "${ROOTFS}/init"
|
sudo ln -sf /sbin/init "${ROOTFS}/init"
|
||||||
|
|
||||||
info "Creating ${IMAGE_DIR}/${IMAGE_NAME} based on rootfs at ${ROOTFS}"
|
info "Creating ${IMAGE_DIR}/${IMAGE_NAME} based on rootfs at ${ROOTFS}"
|
||||||
( cd "${ROOTFS}" && find . | cpio -H newc -o | gzip -9 ) > "${IMAGE_DIR}"/"${IMAGE_NAME}"
|
( cd "${ROOTFS}" && sudo find . | sudo cpio -H newc -o | gzip -9 ) > "${IMAGE_DIR}"/"${IMAGE_NAME}"
|
||||||
|
@ -36,7 +36,7 @@ build_initrd() {
|
|||||||
info "Build initrd"
|
info "Build initrd"
|
||||||
info "initrd os: $os_name"
|
info "initrd os: $os_name"
|
||||||
info "initrd os version: $os_version"
|
info "initrd os version: $os_version"
|
||||||
sudo -E PATH="$PATH" make initrd \
|
make initrd \
|
||||||
DISTRO="$os_name" \
|
DISTRO="$os_name" \
|
||||||
DEBUG="${DEBUG:-}" \
|
DEBUG="${DEBUG:-}" \
|
||||||
OS_VERSION="${os_version}" \
|
OS_VERSION="${os_version}" \
|
||||||
@ -59,7 +59,7 @@ build_image() {
|
|||||||
info "Build image"
|
info "Build image"
|
||||||
info "image os: $os_name"
|
info "image os: $os_name"
|
||||||
info "image os version: $os_version"
|
info "image os version: $os_version"
|
||||||
sudo -E PATH="${PATH}" make image \
|
make image \
|
||||||
DISTRO="${os_name}" \
|
DISTRO="${os_name}" \
|
||||||
DEBUG="${DEBUG:-}" \
|
DEBUG="${DEBUG:-}" \
|
||||||
USE_DOCKER="1" \
|
USE_DOCKER="1" \
|
||||||
|
Loading…
Reference in New Issue
Block a user