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 <alex.lyn@antgroup.com>
This commit is contained in:
Alex Lyn
2026-06-16 15:30:30 +08:00
parent b084c0df36
commit 562c9acdb2
3 changed files with 10 additions and 3 deletions

View File

@@ -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

View File

@@ -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 "$@"

View File

@@ -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}" \