From a390a360dbdcef4f4516cf2e837259dd9f29aa06 Mon Sep 17 00:00:00 2001 From: Penny Zheng Date: Tue, 10 Mar 2020 13:57:47 +0800 Subject: [PATCH] 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 --- rootfs-builder/rootfs.sh | 19 ++++--------------- scripts/lib.sh | 2 +- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/rootfs-builder/rootfs.sh b/rootfs-builder/rootfs.sh index 5a5655ec17..f0dd260aaa 100755 --- a/rootfs-builder/rootfs.sh +++ b/rootfs-builder/rootfs.sh @@ -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:-} @@ -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 diff --git a/scripts/lib.sh b/scripts/lib.sh index 9f8aa54dc9..d585da4072 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -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