Skip to content

Commit 353c651

Browse files
author
urbaneks
committed
.pkg.type helper to classify pkgType to win/mac/custom/source
git-svn-id: https://svn.r-project.org/R/trunk@89686 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 3ae9596 commit 353c651

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/library/tools/R/packages.R

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@
1616
# A copy of the GNU General Public License is available at
1717
# https://www.R-project.org/Licenses/
1818

19+
## from R 4.6.0 on are 4 possible types:
20+
## "source" - .tar.gz, source
21+
## "mac.binary" - .tgz, macOS binary
22+
## "win.binary" - .zip, Windows binary
23+
## "other.binary" - .tar.(bz2|xz|zstd) custom binary
24+
## In the long run the plan is to replace all with custom binaries
25+
## since they cover all OSes and will allow us to remove special cases.
26+
.pkg.type <- function(type) {
27+
if (grepl(".binary", type, fixed=TRUE)) {
28+
## strip build name
29+
type <- gsub("^([[:lower:]]+[.]binary)[.].*", "\\1", type)
30+
## at this point we only care about win, mac or other
31+
if (! type %in% c("win.binary", "mac.binary"))
32+
type <- "other.binary"
33+
} else "source"
34+
}
35+
1936
write_PACKAGES <-
2037
function(dir = ".", fields = NULL, type,
2138
verbose = FALSE, unpacked = FALSE, subdirs = FALSE,
@@ -32,11 +49,7 @@ function(dir = ".", fields = NULL, type,
3249
type <- .Platform$pkgType
3350
}
3451
if (grepl(".binary", type, fixed=TRUE)) {
35-
## strip build name
36-
type <- gsub("^([[:lower:]]+[.]binary)[.].*", "\\1", type)
37-
## at this point we only care about win, mac or other
38-
if (! type %in% c("win.binary", "mac.binary"))
39-
type <- "other.binary"
52+
type <- .pkg.type(type)
4053
} else {
4154
## for compatibility with R < 4.6.0 we handle partial matching
4255
## of c("source", "win.binary", "mac.binary") as it was using match.arg

0 commit comments

Comments
 (0)