Skip to content

Commit

Permalink
feat(rust): support beta and nightly (#3785)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Dec 11, 2024
1 parent 3773e04 commit c23e372
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/usr/local/containerbase/tools/v2/rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ function init_tool () {
chown -R "${USER_ID}" "${cargo_home}"
}

function check_tool_requirements () {
if [[ "${TOOL_VERSION}" == "nightly" || "${TOOL_VERSION}" == "beta" ]]; then
# allow beta and nightly versions
return
fi
# Sensitive default that can be overwritten by tools if needed
check_semver "$TOOL_VERSION" "all"
}

function install_tool () {
local versioned_tool_path
local file
Expand Down Expand Up @@ -55,7 +64,7 @@ function install_tool () {
mkdir -p "${TEMP_DIR}/rust"
bsdtar --strip 1 -C "${TEMP_DIR}/rust" -xf "${file}"
versioned_tool_path=$(create_versioned_tool_path)
"${TEMP_DIR}/rust/install.sh" --prefix="$versioned_tool_path" --components=cargo,rust-std-"${arch}"-unknown-linux-gnu,rustc
"${TEMP_DIR}/rust/install.sh" --prefix="$versioned_tool_path" --components="cargo,rust-std-${arch}-unknown-linux-gnu,rustc"
rm -rf "${TEMP_DIR}/rust"
}

Expand Down
28 changes: 28 additions & 0 deletions test/rust/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,38 @@ RUN set -ex; \
ls -la /tmp/containerbase/cache; \
true

#--------------------------------------
# test c: beta
#--------------------------------------
FROM base AS testc

USER 12021

RUN install-tool rust beta

SHELL [ "/bin/sh", "-c" ]
RUN rustc --version
RUN cargo --version

#--------------------------------------
# test d: nightly
#--------------------------------------
FROM base AS testd

USER 12021

RUN install-tool rust nightly

SHELL [ "/bin/sh", "-c" ]
RUN rustc --version
RUN cargo --version

#--------------------------------------
# final
#--------------------------------------
FROM base

COPY --from=testa /.dummy /.dummy
COPY --from=testb /.dummy /.dummy
COPY --from=testc /.dummy /.dummy
COPY --from=testd /.dummy /.dummy

0 comments on commit c23e372

Please sign in to comment.