Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# pkgcache (development version)

* pkgcache now detects the `macos.binary.arm64` package type that R-devel
(4.7.0) uses on macOS arm64, and looks for binaries in
`bin/macos/arm64/contrib/<x.y>`, where CRAN now serves them.

* Binary packages from a PPM `manylinux` repository now have the correct
platform, e.g. `aarch64-unknown-linux-gnu-manylinux-2.28`. Similarly,
`ppm_platforms()` now reports the correct glibc version of `manylinux`
Expand Down
16 changes: 15 additions & 1 deletion R/platform.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
#' - `aarch64-apple-darwin23-mac.binary.sonoma-arm64`: macOS Sonoma on
#' arm64. (This is the same as `aarch64-apple-darwin23`, which pkgcache
#' already knows about, so `current_r_platform()` uses the shorter form.)
#' - `aarch64-apple-darwin23-macos.binary.arm64`: macOS on arm64, as built
#' by R-devel (4.7.0). Unlike the `mac.binary.*` types above this one is
#' kept in the platform name, because its binaries live in
#' `bin/macos/arm64/contrib/<x.y>`.
#'
#' A package type on its own, without a platform triple, is not a valid
#' platform name.
Expand Down Expand Up @@ -214,6 +218,16 @@ pkg_type_system_for_os <- function(os) {
)
}

# All `<system>` names a package type may use for an OS name. macOS has two:
# `macosx` for the classic `mac.binary*` types, and `macos` for the
# `macos.binary.*` types that R-devel (4.7.0) uses on arm64, which serve
# binaries from `bin/macos/<build>/contrib/<x.y>`.

pkg_type_systems_for_os <- function(os) {
sys <- pkg_type_system_for_os(os)
if (!is.na(sys) && sys == "macosx") c("macosx", "macos") else sys
}

# The custom package type of the current R, or NULL

current_r_custom_pkg_type <- function(os) {
Expand All @@ -222,7 +236,7 @@ current_r_custom_pkg_type <- function(os) {
return(NULL)
}
pt <- parse_pkg_type(type)
if (!identical(pt$system, pkg_type_system_for_os(os))) {
if (!pt$system %in% pkg_type_systems_for_os(os)) {
return(NULL)
}
type
Expand Down
4 changes: 4 additions & 0 deletions man/current_r_platform.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions tests/testthat/test-platform.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ test_that("current_r_custom_pkg_type", {
# the package type must belong to the platform
expect_null(current_r_custom_pkg_type("darwin23"))
expect_null(current_r_custom_pkg_type(NA_character_))

# R-devel (4.7.0) on macOS arm64, `<system>` is `macos`, not `macosx`
fake(
current_r_custom_pkg_type,
"current_r_pkg_type",
"macos.binary.arm64"
)
expect_equal(
current_r_custom_pkg_type("darwin23"),
"macos.binary.arm64"
)
expect_null(current_r_custom_pkg_type("mingw32"))
expect_null(current_r_custom_pkg_type(NA_character_))
})

test_that("pkg_type_systems_for_os", {
# macOS accepts both the classic and the R-devel spelling
expect_equal(pkg_type_systems_for_os("darwin23"), c("macosx", "macos"))
expect_equal(pkg_type_systems_for_os("darwin17.0"), c("macosx", "macos"))
expect_equal(pkg_type_systems_for_os("mingw32"), "windows")
expect_equal(pkg_type_systems_for_os("linux-gnu"), "linux")
expect_equal(pkg_type_systems_for_os(NA_character_), NA_character_)
})

test_that("default_platforms", {
Expand Down Expand Up @@ -227,6 +249,14 @@ test_that("get_all_package_dirs, custom binary package types", {
)$contriburl,
"bin/macosx/sonoma-arm64/contrib/4.7"
)
# R-devel (4.7.0) on macOS arm64 moved to `bin/macos/arm64`
expect_equal(
get_all_package_dirs(
"aarch64-apple-darwin23-macos.binary.arm64",
"4.7.0"
)$contriburl,
"bin/macos/arm64/contrib/4.7"
)
# a package type without a `<build>` part
expect_equal(
get_all_package_dirs(
Expand Down