This commit is contained in:
MangoPig
2025-12-05 19:01:00 +00:00
parent afd6481ec6
commit cf670488ac
9 changed files with 211 additions and 89 deletions

View File

@@ -1,23 +1,38 @@
#!/bin/bash
set -e
# Path: scripts/rust.sh
BLUE='\033[1;34m'
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
NC='\033[0m'
# 1. Define Custom Paths
export RUSTUP_HOME="$HOME/.programming/rust/multirust"
export CARGO_HOME="$HOME/.programming/rust/cargo"
echo -e "${BLUE} LOG:${YELLOW} Setting up Rust (Rustup)...${NC}"
# 1. Install Rustup
if ! command -v rustup &> /dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# 2. Install Rustup (if missing)
if [ ! -f "$CARGO_HOME/bin/rustup" ]; then
echo -e "${BLUE} LOG:${YELLOW} Installing Rustup to custom path...${NC}"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
else
echo -e "${GREEN} LOG: Rustup already installed in custom path.${NC}"
fi
# 2. Source Environment
[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
# 3. Source Environment
if [ -f "$CARGO_HOME/env" ]; then
source "$CARGO_HOME/env"
fi
# 3. Update to Stable
# 4. Verify and Update
if command -v cargo &> /dev/null; then
echo -e "${BLUE} LOG:${YELLOW} Updating toolchain...${NC}"
rustup default stable
rustup update
echo -e "${GREEN} LOG: Rust setup complete.$(cargo --version)${NC}"
else
echo -e "${RED} ERROR: Cargo not found in PATH. Check CARGO_HOME.${NC}"
exit 1
fi