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
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
`PKGCACHE_HTTP_VERSION` environment variable. Closes
https://github.com/r-lib/pkgcache/issues/140.

* pkgcache now supports the custom binary package types of R 4.6.0 and
later.

* `current_r_platform_data()` gained a `pkg_type` column, for custom binary
package types.

* `current_r_platform()` now handles setting `PKG_CURRENT_PLATFORM` to
a non-Linux platform correctly.

* New `PKG_USE_BIOCONDUCTOR` environment variable and new
`pkg.use_bioconductor` option to opt out from automatic Bioconductor
support.
Expand Down
46 changes: 29 additions & 17 deletions R/cran-app.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dummy_so <- function() {
make_dummy_binary <- function(
data,
path,
platform = get_platform(),
platform = current_r_platform(),
r_version = getRversion()
) {
# Need these files:
Expand Down Expand Up @@ -99,22 +99,32 @@ make_dummy_binary <- function(
asNamespace("tools")$.install_package_description(package, package)
asNamespace("tools")$.install_package_namespace_info(package, package)

if (platform == "windows") {
pkgfile <- paste0(package, "_", data$Version, ".zip")
# The extension is the one pkgcache expects in the repository, incl. the
# `_R_<platform>.tar.gz` form that PPM uses for Linux binaries.
ext <- get_cran_extension(platform)
pkgfile <- paste0(package, "_", data$Version, ext)
if (ext == ".zip") {
zip::zip(pkgfile, package)
} else if (platform == "macos") {
pkgfile <- paste0(package, "_", data$Version, ".tgz")
utils::tar(pkgfile, package)
} else {
# Other binary package, we use .tar.gz like on PPM
pkgfile <- paste0(package, "_", data$Version, ".tar.gz")
utils::tar(pkgfile, package)
}

file.copy(pkgfile, path, overwrite = TRUE)
pkgfile
}

platform_pkg_db_type <- function(platform) {
if (platform == "source") {
return("source")
}
switch(
get_cran_extension(platform),
".zip" = "win.binary",
".tgz" = "mac.binary",
"source"
)
}

standardize_dummy_packages <- function(packages) {
packages <- packages %||%
data.frame(
Expand Down Expand Up @@ -156,13 +166,16 @@ make_dummy_repo_platform <- function(repo, packages = NULL, options = list()) {
mkdirp(repo)

options[["platform"]] <- options[["platform"]] %||% "source"
options[["rversion"]] <- options[["rversion"]] %||% format(getRversion())
options[["r_version"]] <- options[["r_version"]] %||% format(getRversion())
packages <- standardize_dummy_packages(packages)

if (!is.null(options$repo_prefix)) {
repo <- file.path(repo, options$repo_prefix)
}
pkgdirs <- get_all_package_dirs(options[["platform"]], getRversion())
pkgdirs <- get_all_package_dirs(
options[["platform"]],
options[["r_version"]]
)
mkdirp(pkgs_dir <- file.path(repo, pkgdirs$contriburl))

extra <- packages
Expand Down Expand Up @@ -204,20 +217,19 @@ make_dummy_repo_platform <- function(repo, packages = NULL, options = list()) {
fn <- make_dummy_binary(
packages[i, , drop = FALSE],
pkg_dir,
options[["platform"]]
options[["platform"]],
options[["r_version"]]
)
}
extra$file[i] <- fn
}

file.create(file.path(pkgs_dir, "PACKAGES"))

if (grepl("windows", pkgdirs$contriburl)) {
pkg_type <- "win.binary"
} else {
pkg_type <- "source"
}
tools::write_PACKAGES(pkgs_dir, type = pkg_type)
tools::write_PACKAGES(
pkgs_dir,
type = platform_pkg_db_type(options[["platform"]])
)

if (isTRUE(options$no_packages)) {
file.remove(file.path(pkgs_dir, "PACKAGES"))
Expand Down
5 changes: 3 additions & 2 deletions R/metadata-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ cmc__data <- new.env(parent = emptyenv())
#' column is either
#' * `"source"` for source packages,
#' * a platform string, e.g. `x86_64-apple-darwin17.0` for macOS
#' packages compatible with macOS High Sierra or newer.
#' packages compatible with macOS High Sierra or newer,
#' * a platform string with a custom binary package type, e.g.
#' `aarch64-w64-mingw32-windows.binary.clang-aarch64`.
#' * `needscompilation`: Whether the package needs compilation.
#' * `type`: `bioc` or `cran` currently.
#' * `target`: The path of the package file inside the repository.
Expand Down Expand Up @@ -487,7 +489,6 @@ cmc__get_cache_files <- function(self, private, which) {
version = private$cache_version
))

str_platforms <- paste(private$platforms, collapse = "+")
rds_file <- paste0("pkgs-", substr(repo_hash, 1, 10), ".rds")

repo_enc <- rep(repo_encode(private$repos), each = nrow(private$dirs))
Expand Down
5 changes: 4 additions & 1 deletion R/platform-linux.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ current_r_platform_data_linux <- function(raw, etc = "/etc") {
)

cbind(
raw[, setdiff(names(raw), c("distribution", "release")), drop = FALSE],
raw[,
setdiff(names(raw), c("distribution", "release", "pkg_type")),
drop = FALSE
],
parse_linux_platform_info(os, rh)
)
}
Expand Down
Loading