From a54183792753d4df38db27dabdfb4455f78a7f3d Mon Sep 17 00:00:00 2001 From: Greg Lin Date: Wed, 4 Sep 2019 15:39:49 -0500 Subject: [PATCH 1/2] Add OS identifier to the default HTTP user agent --- builder/build.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/builder/build.sh b/builder/build.sh index efe92f5..667b1d0 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -94,13 +94,22 @@ compile_r() { make make install - # Preserve the default HTTP user agent for R 3.6.0 and later - if _version_is_greater_than ${1} 3.6; then - cat <<'EOF' >> /opt/R/${1}/lib/R/etc/Rprofile.site -# Set default HTTP user agent -options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os))) + # Add OS identifier to the default HTTP user agent + cat <> /opt/R/${1}/lib/R/etc/Rprofile.site +## Set the default HTTP user agent +local({ + os_identifier <- if (file.exists("/etc/os-release")) { + os <- readLines("/etc/os-release") + id <- gsub('^ID=|"', "", grep("^ID=", os, value = TRUE)) + version <- gsub('^VERSION_ID=|"', "", grep("^VERSION_ID=", os, value = TRUE)) + sprintf("%s-%s", id, version) + } else { + "${OS_IDENTIFIER}" + } + options(HTTPUserAgent = sprintf("R/%s (%s) R (%s)", getRversion(), os_identifier, + paste(getRversion(), R.version\$platform, R.version\$arch, R.version\$os))) +}) EOF - fi } # check for packager script From 685c8228ba7e735e8e3476489e14d71ad9db9682 Mon Sep 17 00:00:00 2001 From: Greg Lin Date: Wed, 4 Sep 2019 16:13:27 -0500 Subject: [PATCH 2/2] Set the HTTP user agent in the system Rprofile --- builder/build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builder/build.sh b/builder/build.sh index 667b1d0..f714471 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -94,8 +94,9 @@ compile_r() { make make install - # Add OS identifier to the default HTTP user agent - cat <> /opt/R/${1}/lib/R/etc/Rprofile.site + # Add OS identifier to the default HTTP user agent. + # Set this in the system Rprofile so it works when R is run with --vanilla. + cat <> /opt/R/${1}/lib/R/library/base/R/Rprofile ## Set the default HTTP user agent local({ os_identifier <- if (file.exists("/etc/os-release")) {