Skip to content

Commit

Permalink
Merge pull request kata-containers#9769 from zvonkok/initrd-image-no-…
Browse files Browse the repository at this point in the history
…sudo

ci: remove sudo and make sure artifacts is owned by user
  • Loading branch information
zvonkok committed Jun 4, 2024
2 parents b556107 + a48c084 commit 6475605
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions tools/osbuilder/image-builder/image_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ build_with_container() {
--env DEBUG="${DEBUG}" \
--env ARCH="${ARCH}" \
--env TARGET_ARCH="${TARGET_ARCH}" \
--env USER="$(id -u)" \
--env GROUP="$(id -g)" \
-v /dev:/dev \
-v "${script_dir}":"/osbuilder" \
-v "${script_dir}/../scripts":"/scripts" \
Expand Down Expand Up @@ -609,9 +611,6 @@ set_dax_header() {
}

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
local agent_bin="${AGENT_BIN:-kata-agent}"
local agent_init="${AGENT_INIT:-no}"
Expand Down Expand Up @@ -678,6 +677,8 @@ main() {
fi
# insert at the beginning of the image the MBR + DAX header
set_dax_header "${image}" "${img_size}" "${fs_type}" "${nsdax_bin}"

chown "${USER}:${GROUP}" "${image}"
}

main "$@"
4 changes: 2 additions & 2 deletions tools/osbuilder/initrd-builder/initrd_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ OK "init is installed"
OK "Agent is installed"

# 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}"
( 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}"
4 changes: 2 additions & 2 deletions tools/packaging/guest-image/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ build_initrd() {
info "Build initrd"
info "initrd os: $os_name"
info "initrd os version: $os_version"
sudo -E PATH="$PATH" make initrd \
make initrd \
DISTRO="$os_name" \
DEBUG="${DEBUG:-}" \
OS_VERSION="${os_version}" \
Expand All @@ -59,7 +59,7 @@ build_image() {
info "Build image"
info "image os: $os_name"
info "image os version: $os_version"
sudo -E PATH="${PATH}" make image \
make image \
DISTRO="${os_name}" \
DEBUG="${DEBUG:-}" \
USE_DOCKER="1" \
Expand Down

0 comments on commit 6475605

Please sign in to comment.