mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-30 17:22:33 +00:00
image-builder: Add NSDAX_BIN for passing in compiled nsdax tool
In Fedora we are running the osbuilder scripts on the client machine, to generate an initrd for the running host kernel. In this setup, there's currently a runtime dependency on gcc for compiling the nsdax tool, which is suboptimal. Add NSDAX_BIN environment variable; if specified, image-builder.sh will use that path as the nsdax tool. This let's ship a compiled nsdax tool to users and drop the runtime gcc dependency Fixes: #417 Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
c54e5caf37
commit
4004bd8fbe
@ -88,6 +88,7 @@ Options:
|
|||||||
Extra environment variables:
|
Extra environment variables:
|
||||||
AGENT_BIN: Use it to change the expected agent binary name
|
AGENT_BIN: Use it to change the expected agent binary name
|
||||||
AGENT_INIT: Use kata agent as init process
|
AGENT_INIT: Use kata agent as init process
|
||||||
|
NSDAX_BIN: Use to specify path to pre-compiled 'nsdax' tool.
|
||||||
FS_TYPE: Filesystem type to use. Only xfs and ext4 are supported.
|
FS_TYPE: Filesystem type to use. Only xfs and ext4 are supported.
|
||||||
USE_DOCKER: If set will build image in a Docker Container (requries docker)
|
USE_DOCKER: If set will build image in a Docker Container (requries docker)
|
||||||
DEFAULT: not set
|
DEFAULT: not set
|
||||||
@ -130,6 +131,8 @@ build_with_container() {
|
|||||||
local root_free_space="$5"
|
local root_free_space="$5"
|
||||||
local agent_bin="$6"
|
local agent_bin="$6"
|
||||||
local agent_init="$7"
|
local agent_init="$7"
|
||||||
|
local container_engine="$8"
|
||||||
|
local nsdax_bin="$9"
|
||||||
local container_image_name="image-builder-osbuilder"
|
local container_image_name="image-builder-osbuilder"
|
||||||
local shared_files=""
|
local shared_files=""
|
||||||
|
|
||||||
@ -158,6 +161,7 @@ build_with_container() {
|
|||||||
--env FS_TYPE="${fs_type}" \
|
--env FS_TYPE="${fs_type}" \
|
||||||
--env BLOCK_SIZE="${block_size}" \
|
--env BLOCK_SIZE="${block_size}" \
|
||||||
--env ROOT_FREE_SPACE="${root_free_space}" \
|
--env ROOT_FREE_SPACE="${root_free_space}" \
|
||||||
|
--env NSDAX_BIN="${nsdax_bin}" \
|
||||||
--env DEBUG="${DEBUG}" \
|
--env DEBUG="${DEBUG}" \
|
||||||
-v /dev:/dev \
|
-v /dev:/dev \
|
||||||
-v "${script_dir}":"/osbuilder" \
|
-v "${script_dir}":"/osbuilder" \
|
||||||
@ -411,6 +415,7 @@ set_dax_header() {
|
|||||||
local image="$1"
|
local image="$1"
|
||||||
local img_size="$2"
|
local img_size="$2"
|
||||||
local fs_type="$3"
|
local fs_type="$3"
|
||||||
|
local nsdax_bin="$4"
|
||||||
|
|
||||||
# rootfs start + DAX header size
|
# rootfs start + DAX header size
|
||||||
local rootfs_offset=$((rootfs_start + dax_header_sz))
|
local rootfs_offset=$((rootfs_start + dax_header_sz))
|
||||||
@ -425,9 +430,12 @@ set_dax_header() {
|
|||||||
info "Set DAX metadata"
|
info "Set DAX metadata"
|
||||||
# Set metadata header
|
# Set metadata header
|
||||||
# Issue: https://github.com/kata-containers/osbuilder/issues/240
|
# Issue: https://github.com/kata-containers/osbuilder/issues/240
|
||||||
gcc -O2 "${script_dir}/nsdax.gpl.c" -o "${script_dir}/nsdax"
|
if [ -z "${nsdax_bin}" ] ; then
|
||||||
"${script_dir}/nsdax" "${header_image}" "${dax_header_bytes}" "${dax_alignment_bytes}"
|
nsdax_bin="${script_dir}/nsdax"
|
||||||
rm -f "${script_dir}/nsdax"
|
gcc -O2 "${script_dir}/nsdax.gpl.c" -o "${nsdax_bin}"
|
||||||
|
trap "rm ${nsdax_bin}" EXIT
|
||||||
|
fi
|
||||||
|
"${nsdax_bin}" "${header_image}" "${dax_header_bytes}" "${dax_alignment_bytes}"
|
||||||
sync
|
sync
|
||||||
|
|
||||||
touch "${dax_image}"
|
touch "${dax_image}"
|
||||||
@ -452,6 +460,7 @@ main() {
|
|||||||
local image="${IMAGE:-kata-containers.img}"
|
local image="${IMAGE:-kata-containers.img}"
|
||||||
local block_size="${BLOCK_SIZE:-4096}"
|
local block_size="${BLOCK_SIZE:-4096}"
|
||||||
local root_free_space="${ROOT_FREE_SPACE:-}"
|
local root_free_space="${ROOT_FREE_SPACE:-}"
|
||||||
|
local nsdax_bin="${NSDAX_BIN:-}"
|
||||||
|
|
||||||
while getopts "ho:r:f:" opt
|
while getopts "ho:r:f:" opt
|
||||||
do
|
do
|
||||||
@ -471,6 +480,7 @@ main() {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local container_engine
|
||||||
if [ -n "${USE_DOCKER}" ]; then
|
if [ -n "${USE_DOCKER}" ]; then
|
||||||
container_engine="docker"
|
container_engine="docker"
|
||||||
elif [ -n "${USE_PODMAN}" ]; then
|
elif [ -n "${USE_PODMAN}" ]; then
|
||||||
@ -478,8 +488,11 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$container_engine" ]; then
|
if [ -n "$container_engine" ]; then
|
||||||
build_with_container "${rootfs}" "${image}" "${fs_type}" "${block_size}" \
|
build_with_container "${rootfs}" \
|
||||||
"${root_free_space}" "${agent_bin}" "${agent_init}" "${container_engine}"
|
"${image}" "${fs_type}" "${block_size}" \
|
||||||
|
"${root_free_space}" "${agent_bin}" \
|
||||||
|
"${agent_init}" "${container_engine}" \
|
||||||
|
"${nsdax_bin}"
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -496,7 +509,7 @@ main() {
|
|||||||
"${fs_type}" "${block_size}"
|
"${fs_type}" "${block_size}"
|
||||||
|
|
||||||
# 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}"
|
set_dax_header "${image}" "${img_size}" "${fs_type}" "${nsdax_bin}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user