osbuilder: install rust before sourcing cargo env

Otherwise we cannot find it.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2020-08-21 23:19:34 +08:00
parent 7b5ab58689
commit cf1b72d6c6
2 changed files with 12 additions and 17 deletions

View File

@ -26,7 +26,8 @@ build_rootfs() {
check_root
mkdir -p "${ROOTFS_DIR}"
cp -a -r /bin /etc /lib /sbin /usr /var ${ROOTFS_DIR}
rm -rf ${ROOTFS_DIR}/var/tmp
cp -a -r -f /bin /etc /lib /sbin /usr /var ${ROOTFS_DIR}
mkdir -p ${ROOTFS_DIR}{/root,/proc,/dev,/home,/media,/mnt,/opt,/run,/srv,/sys,/tmp}
echo "${MIRROR}/${OS_VERSION}/main" > ${ROOTFS_DIR}/etc/apk/repositories

View File

@ -347,7 +347,7 @@ build_rootfs_distro()
if [ -z "${USE_DOCKER}" ] && [ -z "${USE_PODMAN}" ]; then
#Generate an error if the local Go version is too old
echo "build directly"
info "build directly"
build_rootfs ${ROOTFS_DIR}
else
if [ -n "${USE_DOCKER}" ]; then
@ -382,6 +382,7 @@ build_rootfs_distro()
else
docker_run_args+=" --env AGENT_SOURCE_BIN=${AGENT_SOURCE_BIN}"
docker_run_args+=" -v ${AGENT_SOURCE_BIN}:${AGENT_SOURCE_BIN}"
docker_run_args+=" -v ${GOPATH_LOCAL}:${GOPATH_LOCAL} --env GOPATH=${GOPATH_LOCAL}"
fi
docker_run_args+=" $(docker_extra_args $distro)"
@ -538,21 +539,14 @@ 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
test -r "${HOME}/.cargo/env" && source "${HOME}/.cargo/env" || true
# rust agent needs x86_64-unknown-linux-musl
bash ${script_dir}/../../../ci/install_rust.sh
agent_pkg="${RUST_AGENT_PKG}"
agent_dir="${script_dir}/../../../src/agent/"
# For now, rust-agent doesn't support seccomp yet.
SECCOMP="no"
fi
# rust agent needs x86_64-unknown-linux-musl
rustup show | grep x86_64-unknown-linux-musl > /dev/null || bash ${script_dir}/../../../ci/install_rust.sh
test -r "${HOME}/.cargo/env" && source "${HOME}/.cargo/env"
agent_pkg="${RUST_AGENT_PKG}"
agent_dir="${script_dir}/../../../src/agent/"
# For now, rust-agent doesn't support seccomp yet.
SECCOMP="no"
info "Build agent"
pushd "${agent_dir}"