diff --git a/NEWS.md b/NEWS.md index b85a178..657df4d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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/`, 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` diff --git a/R/platform.R b/R/platform.R index 52f4e72..d56cdc7 100644 --- a/R/platform.R +++ b/R/platform.R @@ -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/`. #' #' A package type on its own, without a platform triple, is not a valid #' platform name. @@ -214,6 +218,16 @@ pkg_type_system_for_os <- function(os) { ) } +# All `` 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//contrib/`. + +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) { @@ -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 diff --git a/man/current_r_platform.Rd b/man/current_r_platform.Rd index d65a1e2..8b7d6c5 100644 --- a/man/current_r_platform.Rd +++ b/man/current_r_platform.Rd @@ -94,6 +94,10 @@ built with clang. \item \code{aarch64-apple-darwin23-mac.binary.sonoma-arm64}: macOS Sonoma on arm64. (This is the same as \code{aarch64-apple-darwin23}, which pkgcache already knows about, so \code{current_r_platform()} uses the shorter form.) +\item \code{aarch64-apple-darwin23-macos.binary.arm64}: macOS on arm64, as built +by R-devel (4.7.0). Unlike the \verb{mac.binary.*} types above this one is +kept in the platform name, because its binaries live in +\verb{bin/macos/arm64/contrib/}. } A package type on its own, without a platform triple, is not a valid diff --git a/tests/testthat/test-platform.R b/tests/testthat/test-platform.R index 9966ffe..e05daff 100644 --- a/tests/testthat/test-platform.R +++ b/tests/testthat/test-platform.R @@ -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, `` 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", { @@ -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 `` part expect_equal( get_all_package_dirs(