From 562c9acdb20af570157efbadb028b3a81932e5a4 Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Tue, 16 Jun 2026 15:30:30 +0800 Subject: [PATCH] packaging: Add libdevmapper-dev and GNU target to agent Dockerfile Install libdevmapper-dev and pkg-config in the agent build container so devicemapper-sys can link against libdevmapper. Add the GNU libc rustup target alongside musl since USE_DEVMAPPER forces LIBC=gnu. Forward USE_DEVMAPPER through build.sh and build-static-agent.sh. And you can compile the device mapper in kata-agent as below: ``` $ make LIBC=gnu USE_DEVMAPPER=yes ``` Signed-off-by: Alex Lyn --- tools/packaging/static-build/agent/Dockerfile | 7 ++++++- tools/packaging/static-build/agent/build-static-agent.sh | 5 +++-- tools/packaging/static-build/agent/build.sh | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/packaging/static-build/agent/Dockerfile b/tools/packaging/static-build/agent/Dockerfile index a8cd249f13..689805427a 100644 --- a/tools/packaging/static-build/agent/Dockerfile +++ b/tools/packaging/static-build/agent/Dockerfile @@ -31,12 +31,14 @@ RUN apt-get update && \ g++ \ gcc \ gnupg \ + libdevmapper-dev \ libprotobuf-dev \ libssl-dev \ make \ musl-tools \ openssl \ perl \ + pkg-config \ protobuf-compiler && \ apt-get clean && rm -rf /var/lib/apt/lists/ && \ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${RUST_TOOLCHAIN} @@ -66,4 +68,7 @@ RUN ARCH=$(uname -m); \ "s390x") rust_arch="${ARCH}"; libc="gnu" ;; \ *) echo "Unsupported architecture: ${ARCH}" && exit 1 ;; \ esac; \ - rustup target add "${rust_arch}-unknown-linux-${libc}" + rustup target add "${rust_arch}-unknown-linux-${libc}"; \ + if [ "${libc}" != "gnu" ]; then \ + rustup target add "${rust_arch}-unknown-linux-gnu"; \ + fi diff --git a/tools/packaging/static-build/agent/build-static-agent.sh b/tools/packaging/static-build/agent/build-static-agent.sh index f9211e71b6..6a50106182 100755 --- a/tools/packaging/static-build/agent/build-static-agent.sh +++ b/tools/packaging/static-build/agent/build-static-agent.sh @@ -18,10 +18,11 @@ build_agent_from_source() { /usr/bin/install_libseccomp.sh /opt /opt + # Note: when USE_DEVMAPPER=yes the agent Makefile overrides LIBC=gnu cd src/agent # shellcheck disable=SC2154 - DESTDIR="${DESTDIR}" AGENT_POLICY="${AGENT_POLICY}" INIT_DATA="${INIT_DATA}" make - DESTDIR="${DESTDIR}" AGENT_POLICY="${AGENT_POLICY}" INIT_DATA="${INIT_DATA}" make install + DESTDIR="${DESTDIR}" AGENT_POLICY="${AGENT_POLICY}" INIT_DATA="${INIT_DATA}" USE_DEVMAPPER="${USE_DEVMAPPER:-no}" make + DESTDIR="${DESTDIR}" AGENT_POLICY="${AGENT_POLICY}" INIT_DATA="${INIT_DATA}" USE_DEVMAPPER="${USE_DEVMAPPER:-no}" make install } build_agent_from_source "$@" diff --git a/tools/packaging/static-build/agent/build.sh b/tools/packaging/static-build/agent/build.sh index 639f578264..13d111d855 100755 --- a/tools/packaging/static-build/agent/build.sh +++ b/tools/packaging/static-build/agent/build.sh @@ -31,6 +31,7 @@ docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ --env DESTDIR="${DESTDIR}" \ --env AGENT_POLICY="${AGENT_POLICY:-no}" \ --env INIT_DATA="${INIT_DATA:-yes}" \ + --env USE_DEVMAPPER="${USE_DEVMAPPER:-no}" \ --env LIBSECCOMP_VERSION="${LIBSECCOMP_VERSION}" \ --env LIBSECCOMP_URL="${LIBSECCOMP_URL}" \ --env GPERF_VERSION="${GPERF_VERSION}" \