Skip to content

Commit 952111c

Browse files
authored
Merge pull request #330 from phlg/r_package_manager_refactor
R repositories : moving to "/bin/linux"-style URLs when using PACKAGE_MANAGER_URL
2 parents e4be62b + e4f68fb commit 952111c

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

base/scripts/onyxia-set-repositories.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,29 @@ if command -v uv &>/dev/null; then
2626
fi
2727

2828
# R configuration
29-
3029
if command -v R &>/dev/null; then
3130
if [[ -n "$R_REPOSITORY" ]] || [[ -n "$PACKAGE_MANAGER_URL" ]]; then
3231
echo "configuration r (add local repository)"
3332

34-
echo '# https://docs.rstudio.com/rspm/admin/serving-binaries/#binaries-r-configuration-linux' >> ${R_HOME}/etc/Rprofile.site
35-
echo 'options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"])))' >> ${R_HOME}/etc/Rprofile.site
33+
# When the PACKAGE_MANAGER_URL variable is set, overwrite the Rprofile.site originating from the rocker image
34+
# (but still keep the UserAgent setting in case some internal repositories need it)
35+
if [[ -n "$PACKAGE_MANAGER_URL" ]]; then
36+
echo '# Rocker default configuration removed by /opt/onyxia-set-repositories.sh' > ${R_HOME}/etc/Rprofile.site
37+
38+
echo '# https://docs.rstudio.com/rspm/admin/serving-binaries/#binaries-r-configuration-linux' >> ${R_HOME}/etc/Rprofile.site
39+
echo 'options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"])))' >> ${R_HOME}/etc/Rprofile.site
40+
fi
41+
3642
echo '# Proxy repository for R' >> ${R_HOME}/etc/Rprofile.site
3743
echo 'local({' >> ${R_HOME}/etc/Rprofile.site
3844
echo ' r <- getOption("repos")' >> ${R_HOME}/etc/Rprofile.site
3945

4046
if [[ -n "$PACKAGE_MANAGER_URL" ]]; then
41-
UBUNTU_CODENAME=$(cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2)
42-
echo " r[\"PackageManager\"] <- \"${PACKAGE_MANAGER_URL}/${UBUNTU_CODENAME}/latest\"" >> ${R_HOME}/etc/Rprofile.site
47+
48+
UBUNTU_CODENAME=$(cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2)
49+
# Using "/bin/linux" style URLS for PACKAGE_MANAGER_URL allows easier management for local package managers (eg: Nexus)
50+
# See also : https://docs.posit.co/rspm/admin/serving-binaries.html#using-linux-binary-packages
51+
echo " r[\"PackageManager\"] <- sprintf(\"${PACKAGE_MANAGER_URL}/latest/bin/linux/${UBUNTU_CODENAME}-%s/%s\", R.version[\"arch\"], substr(getRversion(), 1, 3))" >> ${R_HOME}/etc/Rprofile.site
4352
fi
4453

4554
if [[ -n "$R_REPOSITORY" ]]; then

0 commit comments

Comments
 (0)