Add Ninja to base

This commit is contained in:
MangoPig
2025-12-09 03:29:57 +00:00
parent 69f7a5d4d5
commit f359bb68eb
9 changed files with 20 additions and 89 deletions

View File

@@ -17,45 +17,31 @@ fi
echo -e "${BLUE} LOG:${YELLOW} Detecting R installation strategy for $OS...${NC}"
# ------------------------------------------------------------------
# STRATEGY A: ARCH LINUX (Native Pacman)
# Arch always has the latest R kernel. We don't need Rig.
# ------------------------------------------------------------------
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
echo -e "${BLUE} LOG:${YELLOW} Arch Linux detected. Using system R (Pacman)...${NC}"
# 1. Install R + Build Tools
# gcc-fortran is critical for compiling R packages
# Install R + Build Tools
sudo pacman -S --noconfirm --needed r gcc-fortran curl tar
echo -e "${GREEN} SUCCESS:${NC} R installed via Pacman."
# Define R binary path for the renv step later
R_BIN="R"
# ------------------------------------------------------------------
# STRATEGY B: UBUNTU/DEBIAN (Rig Version Manager)
# These distros have old R versions. We need Rig to get the latest.
# ------------------------------------------------------------------
elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
# 1. Install Deps
echo -e "${BLUE} LOG:${YELLOW} Installing Debian build dependencies...${NC}"
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y gfortran curl tar
# 2. Setup Rig Paths
export RIG_HOME="$HOME/.programming/r"
export RIG_BIN="$RIG_HOME/bin"
export PATH="$RIG_BIN:$PATH"
# 3. Install Rig Binary
if [ ! -f "$RIG_BIN/rig" ]; then
echo -e "${BLUE} LOG:${YELLOW} Downloading Rig binary...${NC}"
mkdir -p "$RIG_BIN"
# Robust URL Fetching
LATEST_REL_DATA=$(curl -s https://api.github.com/repos/r-lib/rig/releases/latest)
RIG_URL=$(echo "$LATEST_REL_DATA" | grep -o 'https://[^"]*rig-linux-[^"]*\.tar\.gz' | head -n 1)
@@ -64,7 +50,6 @@ elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
exit 1
fi
# Extract to temp
TEMP_EXTRACT=$(mktemp -d)
curl -L -s "$RIG_URL" | tar -xz -C "$TEMP_EXTRACT"
FOUND_BIN=$(find "$TEMP_EXTRACT" -name "rig" -type f | head -n 1)
@@ -78,7 +63,6 @@ elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
rm -rf "$TEMP_EXTRACT"
fi
# 4. Install R via Rig
TARGET_VER="release"
if ! "$RIG_BIN/rig" list | grep -q "release"; then
echo -e "${BLUE} LOG:${YELLOW} Installing R (${TARGET_VER})...${NC}"
@@ -86,19 +70,11 @@ elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
sudo "$RIG_BIN/rig" default "$TARGET_VER"
fi
# Define R binary path for the renv step
R_BIN="$RIG_BIN/rig run"
fi
# ------------------------------------------------------------------
# COMMON: RENV (Dependency Management)
# This works the same on both systems.
# ------------------------------------------------------------------
echo -e "${BLUE} LOG:${YELLOW} Installing 'renv' package globally...${NC}"
# We use a small R script to install renv if missing
# Note: On Arch, $R_BIN is just "R". On Ubuntu, it might be "rig run".
$R_BIN -e 'if (!require("renv", quietly=TRUE)) install.packages("renv", repos="https://cloud.r-project.org")'
echo -e "${GREEN} SUCCESS:${NC} R setup completed."