Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit adc1141

Browse files
committed
Merge pull request #46 from alexcrichton/cargo
Add cargo installation by default to rustup.sh
2 parents 4337974 + e872e70 commit adc1141

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

rustup.sh

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ BOOL_OPTIONS=""
255255
VAL_OPTIONS=""
256256

257257
flag uninstall "only uninstall from the installation prefix"
258+
opt cargo 1 "install cargo with rust"
258259

259260
if [ $HELP -eq 1 ]
260261
then
@@ -384,6 +385,24 @@ case $HOST_TRIPLE in
384385

385386
esac
386387

388+
# Is this a triple we have cargo nightlies for?
389+
if [ -z "${CFG_DISABLE_CARGO}" ]; then
390+
case $HOST_TRIPLE in
391+
x86_64-unknown-linux-gnu)
392+
CARGO_PLATFORM=linux
393+
;;
394+
395+
x86_64-apple-darwin)
396+
CARGO_PLATFORM=mac
397+
;;
398+
399+
*)
400+
warn "rustup.sh can't install cargo for $HOST_TRIPLE"
401+
CFG_DISABLE_CARGO=1
402+
403+
esac
404+
fi
405+
387406
msg "host triple: ${HOST_TRIPLE}"
388407

389408
PACKAGE_NAME=rust-nightly
@@ -395,20 +414,39 @@ LOCAL_TARBALL="${TMP_DIR}/${TARBALL_NAME}"
395414
LOCAL_INSTALL_DIR="${TMP_DIR}/${PACKAGE_NAME_AND_TRIPLE}"
396415
LOCAL_INSTALL_SCRIPT="${LOCAL_INSTALL_DIR}/install.sh"
397416

417+
CARGO_PACKAGE_NAME=cargo-nightly
418+
CARGO_PACKAGE_NAME_AND_TRIPLE="${CARGO_PACKAGE_NAME}-${CARGO_PLATFORM}"
419+
CARGO_TARBALL_NAME="${CARGO_PACKAGE_NAME_AND_TRIPLE}.tar.gz"
420+
CARGO_REMOTE_TARBALL="http://static.rust-lang.org/cargo-dist/${CARGO_TARBALL_NAME}"
421+
CARGO_LOCAL_TARBALL="${TMP_DIR}/${CARGO_TARBALL_NAME}"
422+
CARGO_LOCAL_INSTALL_DIR="${TMP_DIR}/${CARGO_PACKAGE_NAME}"
423+
CARGO_LOCAL_INSTALL_SCRIPT="${CARGO_LOCAL_INSTALL_DIR}/install.sh"
424+
398425
rm -Rf "${TMP_DIR}"
399426
need_ok "failed to remove temporary installation directory"
400427

401428
mkdir -p "${TMP_DIR}"
402429
need_ok "failed to create create temporary installation directory"
403430

404-
msg "downloading installer"
431+
msg "downloading rust installer"
405432
"${CFG_CURL}" "${REMOTE_TARBALL}" > "${LOCAL_TARBALL}"
406433
if [ $? -ne 0 ]
407434
then
408435
rm -Rf "${TMP_DIR}"
409436
err "failed to download installer"
410437
fi
411438

439+
if [ -z "${CFG_DISABLE_CARGO}" ]; then
440+
msg "downloading cargo installer"
441+
"${CFG_CURL}" "${CARGO_REMOTE_TARBALL}" > "${CARGO_LOCAL_TARBALL}"
442+
if [ $? -ne 0 ]
443+
then
444+
rm -Rf "${TMP_DIR}"
445+
err "failed to download cargo installer"
446+
fi
447+
fi
448+
449+
412450
(cd "${TMP_DIR}" && tar xzf "${TARBALL_NAME}")
413451
if [ $? -ne 0 ]
414452
then
@@ -429,5 +467,21 @@ then
429467
err "failed to install Rust"
430468
fi
431469

470+
if [ -z "${CFG_DISABLE_CARGO}" ]; then
471+
(cd "${TMP_DIR}" && tar xzf "${CARGO_TARBALL_NAME}")
472+
if [ $? -ne 0 ]
473+
then
474+
rm -Rf "${TMP_DIR}"
475+
err "failed to unpack cargo installer"
476+
fi
477+
478+
sh "${CARGO_LOCAL_INSTALL_SCRIPT}" "${MAYBE_UNINSTALL}"
479+
if [ $? -ne 0 ]
480+
then
481+
rm -Rf "${TMP_DIR}"
482+
err "failed to install Cargo"
483+
fi
484+
fi
485+
432486
rm -Rf "${TMP_DIR}"
433487
need_ok "couldn't rm temporary installation directory"

0 commit comments

Comments
 (0)