Skip to content

Commit 5570961

Browse files
author
urbaneks
committed
support custom binaries in contrib.url
git-svn-id: https://svn.r-project.org/R/trunk@89369 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 2583600 commit 5570961

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/library/utils/R/packages.R

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -928,18 +928,28 @@ contrib.url <- function(repos, type = getOption("pkgType"))
928928

929929
ver <- paste(R.version$major,
930930
strsplit(R.version$minor, ".", fixed=TRUE)[[1L]][1L], sep = ".")
931-
mac.path <- "macosx"
932-
if (substr(type, 1L, 11L) == "mac.binary.") {
933-
mac.path <- paste(mac.path, substring(type, 12L), sep = "/")
934-
type <- "mac.binary"
931+
.contrib.path <- function(type, ver) {
932+
## <os>.binary[.<build>] where build has to match [[:alnum:]_-]+
933+
m <- regexec("^([[:lower:]]+)[.]binary(|[.]([[:alnum:]_-]+))$", type)
934+
935+
if (length(m) && length(m[[1]]) == 4) { ## binary spec?
936+
m <- m[[1]]
937+
l <- attr(m, "match.length")
938+
os <- substr(type, m[2], m[2] + l[2] - 1L)
939+
## for historical reasons mac/win have different directory names
940+
os <- switch(os, mac = "macosx", win = "windows", os)
941+
942+
if (l[3] > 0) ## have build name ?
943+
paste("bin", os, substr(type, m[4], m[4] + l[4] - 1L), "contrib", ver, sep = "/")
944+
else
945+
paste("bin", os, "contrib", ver, sep = "/")
946+
} else if (isTRUE(type == "source"))
947+
"src/contrib"
948+
else
949+
stop("invalid 'type'")
935950
}
936-
res <- switch(type,
937-
"source" = paste(gsub("/$", "", repos), "src", "contrib", sep = "/"),
938-
"mac.binary" = paste(gsub("/$", "", repos), "bin", mac.path, "contrib", ver, sep = "/"),
939-
"win.binary" = paste(gsub("/$", "", repos), "bin", "windows", "contrib", ver, sep = "/"),
940-
stop("invalid 'type'")
941-
)
942-
res
951+
952+
paste(gsub("/$", "", repos), .contrib.path(type, ver), sep = "/")
943953
}
944954

945955
.getMirrors <- function(url, local.file, all, local.only)

0 commit comments

Comments
 (0)