Merge pull request #34 from rstudio/user-agent-2
Add OS info to user agent; set user agent in system Rprofile
This commit is contained in:
commit
cacc3f17bb
1 changed files with 16 additions and 6 deletions
|
|
@ -94,13 +94,23 @@ compile_r() {
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
|
||||||
# Preserve the default HTTP user agent for R 3.6.0 and later
|
# Add OS identifier to the default HTTP user agent.
|
||||||
if _version_is_greater_than ${1} 3.6; then
|
# Set this in the system Rprofile so it works when R is run with --vanilla.
|
||||||
cat <<'EOF' >> /opt/R/${1}/lib/R/etc/Rprofile.site
|
cat <<EOF >> /opt/R/${1}/lib/R/library/base/R/Rprofile
|
||||||
# Set default HTTP user agent
|
## Set the default HTTP user agent
|
||||||
options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os)))
|
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
|
EOF
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for packager script
|
# check for packager script
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue