From 67343a178c111ba986dfb4ea5220284f178907dc Mon Sep 17 00:00:00 2001 From: Penny Zheng Date: Tue, 10 Mar 2020 14:06:33 +0800 Subject: [PATCH] rust-agent: Separate the build up of rust-agent and go-agent Separate the build up of rust-agent and go-agent, hence you only select one as kata-agent. I've added the generation of rust-agent systemd service files into rust-agent Makefile. Therefore, we could use same `make` commands to build go-agent and rust-agent. Fixes: #411 Signed-off-by: Penny Zheng --- rootfs-builder/rootfs.sh | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/rootfs-builder/rootfs.sh b/rootfs-builder/rootfs.sh index f0dd260aa..692321e56 100755 --- a/rootfs-builder/rootfs.sh +++ b/rootfs-builder/rootfs.sh @@ -544,34 +544,31 @@ EOT AGENT_DEST="${AGENT_DIR}/${AGENT_BIN}" if [ -z "${AGENT_SOURCE_BIN}" ] ; then + if [ "$RUST_AGENT" != "yes" ]; then + agent_pkg="${GO_AGENT_PKG}" + agent_dir="${GOPATH_LOCAL}/src/${GO_AGENT_PKG}" + else + # The PATH /.cargo/bin is apparently wrong + # looks like $HOME is resolved to empty when + # container is started + source "${HOME}/.cargo/env" + agent_pkg="${RUST_AGENT_PKG}" + agent_dir="${GOPATH_LOCAL}/src/${RUST_AGENT_PKG}/src/agent" + # For now, rust-agent doesn't support seccomp yet. + SECCOMP="no" + fi + info "Pull Agent source code" - go get -d "${GO_AGENT_PKG}" || true + go get -d "${agent_pkg}" || true OK "Pull Agent source code" info "Build agent" - pushd "${GOPATH_LOCAL}/src/${GO_AGENT_PKG}" + pushd "${agent_dir}" [ -n "${AGENT_VERSION}" ] && git checkout "${AGENT_VERSION}" && OK "git checkout successful" || info "checkout failed!" make clean make INIT=${AGENT_INIT} make install DESTDIR="${ROOTFS_DIR}" INIT=${AGENT_INIT} SECCOMP=${SECCOMP} popd - if [ "$RUST_AGENT" == "yes" ]; then - # build rust agent - info "Build rust agent" - # The PATH /.cargo/bin is apparently wrong - # looks like $HOME is resolved to empty when - # container is started - source "${HOME}/.cargo/env" - git clone https://${RUST_AGENT_PKG}.git - local -r agent_dir="${GOPATH_LOCAL}/src/${RUST_AGENT_PKG}/src/agent" - pushd "${agent_dir}" - # checkout correct version - [ -n "${AGENT_VERSION}" ] && git checkout "${AGENT_VERSION}" && OK "git checkout successful" - make clean - make - make install DESTDIR="${ROOTFS_DIR}" - popd - fi else cp ${AGENT_SOURCE_BIN} ${AGENT_DEST} OK "cp ${AGENT_SOURCE_BIN} ${AGENT_DEST}"