Skip to content

Instantly share code, notes, and snippets.

@inejge inejge/rustup
Created Aug 30, 2016

Embed
What would you like to do?
rustup/rustc etc proxy for distro installs
#!/bin/sh
SYSRUST_DIR=/usr/lib/rust
SYSRUSTUP_DIR=/usr/lib/rustup
exename=$(basename "$0")
have_sysrustup=no
[ -x "$SYSRUSTUP_DIR/rustup" ] && have_sysrustup=yes
have_mrsetup=no
mrhome="$HOME/.multirust"
[ -n "$RUSTUP_HOME" ] && mrhome="$RUSTUP_HOME"
while [ -d "$mrhome" ]; do
[ -f "$mrhome/settings.toml" ] || break
[ -d "$mrhome/toolchains" ] || break
n_toolch=$(find "$mrhome/toolchains" -mindepth 1 -maxdepth 1 \! -type f | wc -l)
[ $n_toolch -gt 0 ] || break
have_mrsetup=yes
break
done
want_sysrust=no
[ -n "$USE_SYSTEM_RUST" ] && want_sysrust=yes
is_rustup=no
[ "$exename" = rustup ] && is_rustup=yes
[ $is_rustup = yes -a $have_mrsetup = no ] && {
[ "$1" = "init" ] && {
set -e
"$SYSRUSTUP_DIR/rustup" toolchain link system "$SYSRUST_DIR"
exec "$SYSRUSTUP_DIR/rustup" toolchain default system
}
echo >&2 "rustup(system): no user configuration found, run \`rustup init' to create one"
exit 1
}
[ $is_rustup = yes ] && exec "$SYSRUSTUP_DIR/rustup" "$@"
unset nextexe
if [ $want_sysrust = yes -o $have_sysrustup = no -o $have_mrsetup = no ]; then
nextexe="$SYSRUST_DIR/bin/$exename"
else
nextexe="$SYSRUSTUP_DIR/$exename"
fi
exec "$nextexe" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.