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 <penny.zheng@arm.com>
This commit is contained in:
Penny Zheng 2020-03-10 14:06:33 +08:00
parent a390a360db
commit 67343a178c

View File

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