R Script Fix
This commit is contained in:
54
scripts/r.sh
54
scripts/r.sh
@@ -32,49 +32,47 @@ elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then
|
||||
|
||||
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
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y gfortran curl tar ca-certificates
|
||||
|
||||
export RIG_HOME="$HOME/.programming/r"
|
||||
export RIG_BIN="$RIG_HOME/bin"
|
||||
export PATH="$RIG_BIN:$PATH"
|
||||
if ! command -v rig >/dev/null 2>&1; then
|
||||
echo -e "${BLUE} LOG:${YELLOW} Installing Rig for Debian/Ubuntu...${NC}"
|
||||
|
||||
DEB_ARCH=$(dpkg --print-architecture)
|
||||
case "$DEB_ARCH" in
|
||||
amd64|arm64)
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED} ERROR:${NC} Unsupported Debian architecture for Rig: $DEB_ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
LATEST_REL_DATA=$(curl -fsSL https://api.github.com/repos/r-lib/rig/releases/latest)
|
||||
RIG_URL=$(echo "$LATEST_REL_DATA" | grep -o "https://[^\"]*r-rig_[^\"]*_${DEB_ARCH}\.deb" | head -n 1)
|
||||
|
||||
if [ ! -f "$RIG_BIN/rig" ]; then
|
||||
echo -e "${BLUE} LOG:${YELLOW} Downloading Rig binary...${NC}"
|
||||
mkdir -p "$RIG_BIN"
|
||||
|
||||
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)
|
||||
|
||||
if [ -z "$RIG_URL" ]; then
|
||||
echo -e "${RED} ERROR:${NC} Could not find Rig download URL."
|
||||
echo -e "${RED} ERROR:${NC} Could not find Rig .deb download URL for architecture: $DEB_ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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)
|
||||
|
||||
if [ -f "$FOUND_BIN" ]; then
|
||||
mv "$FOUND_BIN" "$RIG_BIN/rig"
|
||||
chmod +x "$RIG_BIN/rig"
|
||||
else
|
||||
rm -rf "$TEMP_EXTRACT"; exit 1
|
||||
fi
|
||||
rm -rf "$TEMP_EXTRACT"
|
||||
TEMP_DEB=$(mktemp --suffix=.deb)
|
||||
curl -fLsS "$RIG_URL" -o "$TEMP_DEB"
|
||||
sudo apt-get install -y "$TEMP_DEB"
|
||||
rm -f "$TEMP_DEB"
|
||||
fi
|
||||
|
||||
TARGET_VER="release"
|
||||
if ! "$RIG_BIN/rig" list | grep -q "release"; then
|
||||
if ! rig list | grep -q "release"; then
|
||||
echo -e "${BLUE} LOG:${YELLOW} Installing R (${TARGET_VER})...${NC}"
|
||||
sudo "$RIG_BIN/rig" add "$TARGET_VER" --without-cran-mirror
|
||||
sudo "$RIG_BIN/rig" default "$TARGET_VER"
|
||||
sudo rig add "$TARGET_VER" --without-cran-mirror
|
||||
sudo rig default "$TARGET_VER"
|
||||
fi
|
||||
|
||||
R_BIN="$RIG_BIN/rig run"
|
||||
R_BIN="rig run"
|
||||
fi
|
||||
|
||||
echo -e "${BLUE} LOG:${YELLOW} Installing 'renv' package globally...${NC}"
|
||||
|
||||
$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."
|
||||
echo -e "${GREEN} SUCCESS:${NC} R setup completed."
|
||||
|
||||
Reference in New Issue
Block a user