diff --git a/tools/osbuilder/rootfs-builder/centos/Dockerfile.in b/tools/osbuilder/rootfs-builder/centos/Dockerfile.in index f5b004daf0..529bd7ba97 100644 --- a/tools/osbuilder/rootfs-builder/centos/Dockerfile.in +++ b/tools/osbuilder/rootfs-builder/centos/Dockerfile.in @@ -34,7 +34,6 @@ RUN yum -y update && yum install -y \ vim \ which +# This will install the proper packages to build Kata components @INSTALL_MUSL@ -# This will install the proper golang to build Kata components -@INSTALL_GO@ @INSTALL_RUST@ diff --git a/tools/osbuilder/rootfs-builder/clearlinux/Dockerfile.in b/tools/osbuilder/rootfs-builder/clearlinux/Dockerfile.in index 0146b168c7..abbc413474 100644 --- a/tools/osbuilder/rootfs-builder/clearlinux/Dockerfile.in +++ b/tools/osbuilder/rootfs-builder/clearlinux/Dockerfile.in @@ -37,7 +37,6 @@ RUN dnf -y update && dnf install -y \ vim \ which -# This will install the proper golang to build Kata components +# This will install the proper packages to build Kata components @INSTALL_MUSL@ -@INSTALL_GO@ @INSTALL_RUST@ diff --git a/tools/osbuilder/rootfs-builder/debian/Dockerfile-aarch64.in b/tools/osbuilder/rootfs-builder/debian/Dockerfile-aarch64.in index 537fc61f15..4395913f9a 100644 --- a/tools/osbuilder/rootfs-builder/debian/Dockerfile-aarch64.in +++ b/tools/osbuilder/rootfs-builder/debian/Dockerfile-aarch64.in @@ -29,7 +29,6 @@ RUN apt-get update && apt-get install -y \ systemd \ tar \ vim -# This will install the proper golang to build Kata components -@INSTALL_GO@ +# This will install the proper packages to build Kata components @INSTALL_MUSL@ @INSTALL_RUST@ diff --git a/tools/osbuilder/rootfs-builder/debian/Dockerfile.in b/tools/osbuilder/rootfs-builder/debian/Dockerfile.in index 27d7957bd9..489940d447 100644 --- a/tools/osbuilder/rootfs-builder/debian/Dockerfile.in +++ b/tools/osbuilder/rootfs-builder/debian/Dockerfile.in @@ -36,6 +36,5 @@ RUN apt-get update && apt-get --no-install-recommends install -y \ vim \ wget -# This will install the proper golang to build Kata components -@INSTALL_GO@ +# This will install the proper packages to build Kata components @INSTALL_RUST@ diff --git a/tools/osbuilder/rootfs-builder/fedora/Dockerfile.in b/tools/osbuilder/rootfs-builder/fedora/Dockerfile.in index 7b914a901f..dac32f5050 100644 --- a/tools/osbuilder/rootfs-builder/fedora/Dockerfile.in +++ b/tools/osbuilder/rootfs-builder/fedora/Dockerfile.in @@ -37,7 +37,6 @@ RUN dnf -y update && dnf install -y \ vim \ which -# This will install the proper golang to build Kata components +# This will install the proper packages to build Kata components @INSTALL_MUSL@ -@INSTALL_GO@ @INSTALL_RUST@ diff --git a/tools/osbuilder/rootfs-builder/gentoo/Dockerfile.in b/tools/osbuilder/rootfs-builder/gentoo/Dockerfile.in index 509d89703f..8a06ff921f 100644 --- a/tools/osbuilder/rootfs-builder/gentoo/Dockerfile.in +++ b/tools/osbuilder/rootfs-builder/gentoo/Dockerfile.in @@ -9,6 +9,5 @@ FROM ${IMAGE_REGISTRY}/gentoo/stage3-amd64:latest # This dockerfile needs to provide all the componets need to build a rootfs # Install any package need to create a rootfs (package manager, extra tools) -# This will install the proper golang to build Kata components -@INSTALL_GO@ +# This will install the proper rust to build Kata components @INSTALL_RUST@ diff --git a/tools/osbuilder/rootfs-builder/rootfs.sh b/tools/osbuilder/rootfs-builder/rootfs.sh index 9fbe49bad1..2b970d8f81 100755 --- a/tools/osbuilder/rootfs-builder/rootfs.sh +++ b/tools/osbuilder/rootfs-builder/rootfs.sh @@ -13,9 +13,6 @@ set -o errtrace script_name="${0##*/}" script_dir="$(dirname $(readlink -f $0))" AGENT_VERSION=${AGENT_VERSION:-} -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:-yes} RUST_VERSION="null" MUSL_VERSION=${MUSL_VERSION:-"null"} AGENT_BIN=${AGENT_BIN:-kata-agent} @@ -23,7 +20,7 @@ AGENT_INIT=${AGENT_INIT:-no} KERNEL_MODULES_DIR=${KERNEL_MODULES_DIR:-""} OSBUILDER_VERSION="unknown" DOCKER_RUNTIME=${DOCKER_RUNTIME:-runc} -GO_VERSION="null" +# this GOPATH is for installing yq from install_yq.sh export GOPATH=${GOPATH:-${HOME}/go} LIBC=${LIBC:-musl} @@ -113,9 +110,6 @@ DISTRO_REPO Use host repositories to install guest packages. DOCKER_RUNTIME Docker runtime to use when USE_DOCKER is set. Default value: runc -GO_AGENT_PKG URL of the Git repository hosting the agent package. - Default value: ${GO_AGENT_PKG} - GRACEFUL_EXIT If set, and if the DISTRO configuration specifies a non-empty BUILD_CAN_FAIL variable, do not return with an error code in case any of the build step fails. @@ -134,12 +128,6 @@ KERNEL_MODULES_DIR Path to a directory containing kernel modules to include in ROOTFS_DIR Path to the directory that is populated with the rootfs. Default value: <${script_name} path>/rootfs- -RUST_AGENT When set to "no", build kata-agent from go agent instead of kata-rust-agent - Default value: "yes" - -RUST_AGENT_PKG URL of the Git repository hosting the agent package. - Default value: ${RUST_AGENT_PKG} - USE_DOCKER If set, build the rootfs inside a container (requires Docker). Default value: @@ -291,17 +279,11 @@ compare_versions() check_env_variables() { - # Fetch the first element from GOPATH as working directory - # as go get only works against the first item in the GOPATH - [ -z "$GOPATH" ] && die "GOPATH not set" + # this will be mounted to container for using yq on the host side. GOPATH_LOCAL="${GOPATH%%:*}" [ "$AGENT_INIT" == "yes" -o "$AGENT_INIT" == "no" ] || die "AGENT_INIT($AGENT_INIT) is invalid (must be yes or no)" - 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)" - fi - [ -n "${KERNEL_MODULES_DIR}" ] && [ ! -d "${KERNEL_MODULES_DIR}" ] && die "KERNEL_MODULES_DIR defined but is not an existing directory" [ -n "${OSBUILDER_VERSION}" ] || die "need osbuilder version" @@ -346,24 +328,18 @@ build_rootfs_distro() mkdir -p ${ROOTFS_DIR} - detect_go_version || - die "Could not detect the required Go version for AGENT_VERSION='${AGENT_VERSION:-master}'." - - echo "Required Go version: $GO_VERSION" - # need to detect rustc's version too? detect_rust_version || - die "Could not detect the required rust version for AGENT_VERSION='${AGENT_VERSION:-master}'." + die "Could not detect the required rust version for AGENT_VERSION='${AGENT_VERSION:-main}'." echo "Required rust version: $RUST_VERSION" detect_musl_version || - die "Could not detect the required musl version for AGENT_VERSION='${AGENT_VERSION:-master}'." + die "Could not detect the required musl version for AGENT_VERSION='${AGENT_VERSION:-main}'." echo "Required musl version: $MUSL_VERSION" if [ -z "${USE_DOCKER}" ] && [ -z "${USE_PODMAN}" ]; then - #Generate an error if the local Go version is too old info "build directly" build_rootfs ${ROOTFS_DIR} else @@ -380,7 +356,7 @@ build_rootfs_distro() REGISTRY_ARG="--build-arg IMAGE_REGISTRY=${IMAGE_REGISTRY}" fi - # setup to install go or rust here + # setup to install rust here generate_dockerfile "${distro_config_dir}" "$container_engine" build \ ${REGISTRY_ARG} \ @@ -396,12 +372,7 @@ build_rootfs_distro() docker_run_args+=" --runtime ${DOCKER_RUNTIME}" if [ -z "${AGENT_SOURCE_BIN}" ] ; then - 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}" - fi - docker_run_args+=" --env RUST_AGENT=${RUST_AGENT} -v ${GOPATH_LOCAL}:${GOPATH_LOCAL} --env GOPATH=${GOPATH_LOCAL}" + docker_run_args+=" -v ${GOPATH_LOCAL}:${GOPATH_LOCAL} --env GOPATH=${GOPATH_LOCAL}" else docker_run_args+=" --env AGENT_SOURCE_BIN=${AGENT_SOURCE_BIN}" docker_run_args+=" -v ${AGENT_SOURCE_BIN}:${AGENT_SOURCE_BIN}" @@ -577,7 +548,6 @@ EOT test -r "${HOME}/.cargo/env" && source "${HOME}/.cargo/env" [ "$ARCH" == "aarch64" ] && OLD_PATH=$PATH && export PATH=$PATH:/usr/local/musl/bin - agent_pkg="${RUST_AGENT_PKG}" agent_dir="${script_dir}/../../../src/agent/" # For now, rust-agent doesn't support seccomp yet. SECCOMP="no" diff --git a/tools/osbuilder/rootfs-builder/suse/Dockerfile.in b/tools/osbuilder/rootfs-builder/suse/Dockerfile.in index c64fb1fa44..70948a4b13 100644 --- a/tools/osbuilder/rootfs-builder/suse/Dockerfile.in +++ b/tools/osbuilder/rootfs-builder/suse/Dockerfile.in @@ -15,7 +15,6 @@ COPY install-packages.sh config.sh / # RUN commands RUN chmod +x /install-packages.sh; /install-packages.sh -# This will install the proper golang to build Kata components +# This will install the proper packages to build Kata components @INSTALL_MUSL@ -@INSTALL_GO@ @INSTALL_RUST@ diff --git a/tools/osbuilder/rootfs-builder/template/Dockerfile.template b/tools/osbuilder/rootfs-builder/template/Dockerfile.template index d8ff345ab1..b881dac439 100644 --- a/tools/osbuilder/rootfs-builder/template/Dockerfile.template +++ b/tools/osbuilder/rootfs-builder/template/Dockerfile.template @@ -13,5 +13,6 @@ FROM ${IMAGE_REGISTRY}/@distro@:@OS_VERSION@ # RUN commands -# This will install the proper golang to build Kata components -@INSTALL_GO@ +# This will install the proper packages to build Kata components +@INSTALL_MUSL@ +@INSTALL_RUST@ diff --git a/tools/osbuilder/rootfs-builder/ubuntu/Dockerfile-aarch64.in b/tools/osbuilder/rootfs-builder/ubuntu/Dockerfile-aarch64.in index 9ebbec084f..50673b230c 100644 --- a/tools/osbuilder/rootfs-builder/ubuntu/Dockerfile-aarch64.in +++ b/tools/osbuilder/rootfs-builder/ubuntu/Dockerfile-aarch64.in @@ -33,7 +33,6 @@ RUN apt-get update && apt-get install -y \ systemd \ tar \ vim -# This will install the proper golang to build Kata components -@INSTALL_GO@ +# This will install the proper packages to build Kata components @INSTALL_MUSL@ @INSTALL_RUST@ diff --git a/tools/osbuilder/rootfs-builder/ubuntu/Dockerfile.in b/tools/osbuilder/rootfs-builder/ubuntu/Dockerfile.in index 13c98dc0d2..07bf30ce89 100644 --- a/tools/osbuilder/rootfs-builder/ubuntu/Dockerfile.in +++ b/tools/osbuilder/rootfs-builder/ubuntu/Dockerfile.in @@ -40,6 +40,6 @@ RUN apt-get update && apt-get --no-install-recommends install -y \ tar \ vim \ wget -# This will install the proper golang to build Kata components -@INSTALL_GO@ + +# This will install the proper packages to build Kata components @INSTALL_RUST@ diff --git a/tools/osbuilder/scripts/lib.sh b/tools/osbuilder/scripts/lib.sh index 5a7e41544d..05930a88e5 100644 --- a/tools/osbuilder/scripts/lib.sh +++ b/tools/osbuilder/scripts/lib.sh @@ -150,6 +150,8 @@ build_rootfs() else DNF="${DNF} --releasever=${OS_VERSION}" fi + + info "install packages for rootfs" $DNF install ${EXTRA_PKGS} ${PACKAGES} } @@ -190,14 +192,8 @@ create_summary_file() local agent="${AGENT_DEST}" [ "$AGENT_INIT" = yes ] && agent="${init}" - local agent_version - if [ "${RUST_AGENT}" == "no" ]; then - agent_version=$("$agent" --version|awk '{print $NF}') - else - local -r agentdir="${script_dir}/../../../" - agent_version=$(cat ${agentdir}/VERSION) - fi - + local -r agentdir="${script_dir}/../../../" + local -r agent_version=$(cat ${agentdir}/VERSION) cat >"$file"<<-EOT --- @@ -241,37 +237,20 @@ generate_dockerfile() local libc=musl case "$(uname -m)" in "ppc64le") - goarch=ppc64le rustarch=powerpc64le muslarch=powerpc64 libc=gnu ;; - - "aarch64") - goarch=arm64 - ;; "s390x") - goarch=s390x libc=gnu ;; *) - goarch=amd64 ;; esac [ -n "${http_proxy:-}" ] && readonly set_proxy="RUN sed -i '$ a proxy="${http_proxy:-}"' /etc/dnf/dnf.conf /etc/yum.conf; true" - curlOptions=("-OL") - [ -n "${http_proxy:-}" ] && curlOptions+=("-x ${http_proxy:-}") - - readonly install_go=" -RUN cd /tmp ; curl ${curlOptions[@]} https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${goarch}.tar.gz -RUN tar -C /usr/ -xzf /tmp/go${GO_VERSION}.linux-${goarch}.tar.gz -ENV GOROOT=/usr/go -ENV PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin -" - # Rust agent # rust installer should set path apropiately, just in case # install musl for compiling rust-agent @@ -327,8 +306,6 @@ RUN . /root/.cargo/env; \ rustup target install ${rustarch}-unknown-linux-${libc} RUN ln -sf /usr/bin/g++ /bin/musl-g++ " - # rust agent still need go to build - # because grpc-sys need go to build pushd "${dir}" dockerfile_template="Dockerfile.in" dockerfile_arch_template="Dockerfile-${architecture}.in" @@ -344,10 +321,8 @@ RUN ln -sf /usr/bin/g++ /bin/musl-g++ # also long double representation problem when building musl-libc if [ "${architecture}" == "ppc64le" ]; then sed \ - -e "s|@GO_VERSION@|${GO_VERSION}|g" \ -e "s|@OS_VERSION@|${OS_VERSION:-}|g" \ -e "s|@INSTALL_MUSL@||g" \ - -e "s|@INSTALL_GO@|${install_go//$'\n'/\\n}|g" \ -e "s|@INSTALL_RUST@|${install_rust//$'\n'/\\n}|g" \ -e "s|@SET_PROXY@|${set_proxy:-}|g" \ "${dockerfile_template}" > Dockerfile @@ -364,10 +339,8 @@ RUN ln -sf /usr/bin/g++ /bin/musl-g++ "${dockerfile_template}" > Dockerfile else sed \ - -e "s|@GO_VERSION@|${GO_VERSION}|g" \ -e "s|@OS_VERSION@|${OS_VERSION:-}|g" \ -e "s|@INSTALL_MUSL@|${install_musl//$'\n'/\\n}|g" \ - -e "s|@INSTALL_GO@|${install_go//$'\n'/\\n}|g" \ -e "s|@INSTALL_RUST@|${install_rust//$'\n'/\\n}|g" \ -e "s|@SET_PROXY@|${set_proxy:-}|g" \ "${dockerfile_template}" > Dockerfile @@ -375,20 +348,6 @@ RUN ln -sf /usr/bin/g++ /bin/musl-g++ popd } -detect_go_version() -{ - info "Detecting go version" - typeset yq=$(command -v yq || command -v ${GOPATH}/bin/yq || echo "${GOPATH}/bin/yq") - if [ ! -f "$yq" ]; then - source "$yq_file" - fi - - info "Get Go version from ${kata_versions_file}" - GO_VERSION="$(cat "${kata_versions_file}" | $yq r -X - "languages.golang.meta.newest-version")" - - [ "$?" == "0" ] && [ "$GO_VERSION" != "null" ] -} - detect_rust_version() { info "Detecting agent rust version" @@ -398,7 +357,7 @@ detect_rust_version() fi info "Get rust version from ${kata_versions_file}" - RUST_VERSION="$(cat "${kata_versions_file}" | $yq r -X - "languages.rust.meta.newest-version")" + RUST_VERSION="$(cat "${kata_versions_file}" | $yq r -X - "languages.rust.meta.newest-version")" [ "$?" == "0" ] && [ "$RUST_VERSION" != "null" ] }