rootfs: remove RUST_SRC_PATH

If user wants to use customized rust-agent, they could use
AGENT_SOURCE_BIN to pass the static binary.
The rust-agent is always statically linked with musl.

Fixes: #411

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
This commit is contained in:
Penny Zheng 2020-03-10 13:57:47 +08:00
parent 41aaa36e6f
commit a390a360db
2 changed files with 5 additions and 16 deletions

View File

@ -17,7 +17,6 @@ GO_AGENT_PKG=${GO_AGENT_PKG:-github.com/kata-containers/agent}
RUST_AGENT_PKG=${RUST_AGENT_PKG:-github.com/kata-containers/kata-containers}
RUST_AGENT=${RUST_AGENT:-no}
RUST_VERSION="null"
RUST_SRC_PATH=${RUST_SRC_PATH:-${HOME}/rust}
CMAKE_VERSION=${CMAKE_VERSION:-"null"}
MUSL_VERSION=${MUSL_VERSION:-"null"}
AGENT_BIN=${AGENT_BIN:-kata-agent}
@ -107,9 +106,6 @@ RUST_AGENT When set to "yes", build kata-agent from kata-rust-agent ins
RUST_AGENT_PKG URL of the Git repository hosting the agent package.
Default value: ${RUST_AGENT_PKG}
RUST_SRC_PATH Path of the source code
Default value: ${RUST_SRC_PATH}
AGENT_VERSION Version of the agent to include in the rootfs.
Default value: ${AGENT_VERSION:-<not set>}
@ -281,7 +277,6 @@ check_env_variables()
if [ -z "${AGENT_SOURCE_BIN}" ]; then
[ "$RUST_AGENT" == "yes" -o "$RUST_AGENT" == "no" ] || die "RUST_AGENT($RUST_AGENT) is invalid (must be yes or no)"
mkdir -p ${RUST_SRC_PATH} || :
fi
[ -n "${KERNEL_MODULES_DIR}" ] && [ ! -d "${KERNEL_MODULES_DIR}" ] && die "KERNEL_MODULES_DIR defined but is not an existing directory"
@ -392,7 +387,7 @@ build_rootfs_distro()
if [ "$RUST_AGENT" == "no" ]; then
docker_run_args+=" --env GO_AGENT_PKG=${GO_AGENT_PKG}"
else
docker_run_args+=" --env RUST_AGENT_PKG=${RUST_AGENT_PKG} -v ${RUST_SRC_PATH}:${RUST_SRC_PATH} --env RUST_SRC_PATH=${RUST_SRC_PATH}"
docker_run_args+=" --env RUST_AGENT_PKG=${RUST_AGENT_PKG}"
fi
docker_run_args+=" --env RUST_AGENT=${RUST_AGENT} -v ${GOPATH_LOCAL}:${GOPATH_LOCAL} --env GOPATH=${GOPATH_LOCAL}"
else
@ -405,9 +400,6 @@ build_rootfs_distro()
# Relabel volumes so SELinux allows access (see docker-run(1))
if command -v selinuxenabled > /dev/null && selinuxenabled ; then
SRC_VOL=("${GOPATH_LOCAL}")
if [ "${RUST_AGENT}" == "yes" ]; then
SRC_VOL+=("${RUST_SRC_PATH}")
fi
for volume_dir in "${script_dir}" \
"${ROOTFS_DIR}" \
@ -570,12 +562,9 @@ EOT
# looks like $HOME is resolved to empty when
# container is started
source "${HOME}/.cargo/env"
local -r agent_dir="$(basename ${RUST_AGENT_PKG})/src/agent"
pushd "${RUST_SRC_PATH}"
if [ ! -d ${RUST_SRC_PATH}/${agent_dir} ]; then
git clone https://${RUST_AGENT_PKG}.git
fi
cd ${agent_dir}
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

View File

@ -199,7 +199,7 @@ create_summary_file()
if [ "${RUST_AGENT}" == "no" ]; then
agent_version=$("$agent" --version|awk '{print $NF}')
else
local -r agentdir="${RUST_SRC_PATH}/$(basename ${RUST_AGENT_PKG} .git)/src/agent"
local -r agentdir="${GOPATH}/src/${RUST_AGENT_PKG}/src/agent"
agent_version=$(cat ${agentdir}/VERSION)
fi