Skip to content

Commit

Permalink
Rename RSPM to PPM
Browse files Browse the repository at this point in the history
But still allow the `RSPM@...` form in `repo_add()`, etc.
  • Loading branch information
gaborcsardi committed Feb 21, 2023
1 parent cad5ad4 commit 12eeecf
Show file tree
Hide file tree
Showing 17 changed files with 226 additions and 207 deletions.
2 changes: 1 addition & 1 deletion R/cran-app.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ make_dummy_binary <- function(data, path, platform = get_platform(),
pkgfile <- paste0(package, "_", data$Version, ".tgz")
utils::tar(pkgfile, package)
} else {
# Other binary package, we use .tar.gz like on RSPM
# Other binary package, we use .tar.gz like on PPM
pkgfile <- paste0(package, "_", data$Version, ".tar.gz")
utils::tar(pkgfile, package)
}
Expand Down
8 changes: 4 additions & 4 deletions R/metadata-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ cmc__get_cache_files <- function(self, private, which) {

pkg_path <- file.path(root, "_metadata", repo_enc, pkgs_files)
meta_path <- ifelse(
type == "cran" | name == "rspm",
type == "cran" | name == "rspm" | name == "ppm" | name == "p3m",
file.path(root, "_metadata", repo_enc, pkgs_dirs, "METADATA2.gz"),
NA_character_)
meta_etag <- ifelse(
Expand All @@ -456,7 +456,7 @@ cmc__get_cache_files <- function(self, private, which) {
paste0(cran_metadata_url(), pkgs_dirs, "/METADATA2.gz"),
NA_character_)

bin_url <- rspm_binary_url(mirror, private$r_version)
bin_url <- ppm_binary_url(mirror, private$r_version)
bin_path <- ifelse(
is.na(bin_url),
NA_character_,
Expand Down Expand Up @@ -497,11 +497,11 @@ cmc__get_cache_files <- function(self, private, which) {
res
}

rspm_binary_url <- function(urls, r_version) {
ppm_binary_url <- function(urls, r_version) {
res <- rep(NA_character_, length(urls))

# If multiple R versions are requested, then we give up, and pretend
# that RSPM binaries are source packages
# that PPM binaries are source packages
if (length(r_version) != 1) return(res)

# http://rspm.infra/all/__linux__/bionic/latest ->
Expand Down
4 changes: 2 additions & 2 deletions R/onload.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pkgenv$r_versions <- list(
list(version = "4.2.2", date = "2022-10-31T08:05:54.268400Z")
)

pkgenv$rspm_versions <- c(
pkgenv$ppm_versions <- c(
`2017-10-10T00:00:00Z` = "5", `2017-10-25T00:00:00Z` = "6",
`2017-10-30T00:00:00Z` = "7", `2017-11-01T00:00:00Z` = "8",
`2017-11-03T00:00:00Z` = "9", `2017-11-07T00:00:00Z` = "10",
Expand Down Expand Up @@ -573,7 +573,7 @@ pkgenv$rspm_versions <- c(
`2023-02-13T00:00:00Z` = "16698644", `2023-02-14T00:00:00Z` = "16710885"
)

pkgenv$rspm_distros_cached <-
pkgenv$ppm_distros_cached <-
utils::read.table(header = TRUE, stringsAsFactors = FALSE, textConnection("
name os binary_url distribution release binaries
centos7 linux centos7 centos 7 TRUE
Expand Down
16 changes: 8 additions & 8 deletions R/package-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ package_cache <- R6Class(

extra <- c(list(...), .list)

# updates for unexpected RSPM binaries and sources
# updates for unexpected PPM binaries and sources
# need to update 'path', 'platform', 'sha256'
if (is.list(.headers)) .headers <- .headers[[1]]
.headers <- tolower(.headers)
if ("x-repository-type: rspm" %in% .headers) {
fields <- update_fields_for_rspm_download(path, extra, .headers)
fields <- update_fields_for_ppm_download(path, extra, .headers)
path <- fields$path
extra <- fields$extra
}
Expand Down Expand Up @@ -362,7 +362,7 @@ make_empty_db_data_frame <- function() {
)
}

update_fields_for_rspm_download <- function(path, extra, headers) {
update_fields_for_ppm_download <- function(path, extra, headers) {
res <- list(path = path, extra = extra)
pkg_type <- grep("^x-package-type:", headers, value = TRUE)[1]
if (is.na(pkg_type)) return(res)
Expand All @@ -373,17 +373,17 @@ update_fields_for_rspm_download <- function(path, extra, headers) {
bin_tag <- grep("x-package-binary-tag:", headers, value = TRUE)[1]
if (is.na(bin_tag)) return(res)
bin_tag <- sub("x-package-binary-tag: ?", "", bin_tag)
synchronise(async_get_rspm_distros())
synchronise(async_get_ppm_distros())
rver <- strsplit(bin_tag, "-")[[1]][[1]]
binurl <- strsplit(bin_tag, "-")[[1]][[2]]
if (!binurl %in% pkgenv$rspm_distros$binary_url) return(res)
if (!binurl %in% pkgenv$ppm_distros$binary_url) return(res)

# fix platform if neeeded
if (!is.null(extra$platform) && extra$platform == "source") {
current <- current_r_platform_data()
wdist <- match(binurl, pkgenv$rspm_distros$binary_url)
distro <- pkgenv$rspm_distros$distribution[wdist]
release <- pkgenv$rspm_distros$release[wdist]
wdist <- match(binurl, pkgenv$ppm_distros$binary_url)
distro <- pkgenv$ppm_distros$distribution[wdist]
release <- pkgenv$ppm_distros$release[wdist]
res$extra$platform <- paste0(
current$cpu, "-", current$vendor, "-", current$os, "-",
distro, "-", release
Expand Down
6 changes: 3 additions & 3 deletions R/packages-gz.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ read_packages_file <- function(path, mirror, repodir, platform,
pkgs <- parse_packages(path)
}
meta <- read_metadata_file(meta_path)
bin <- read_rspm_binaries(bin_path)
bin <- read_ppm_binaries(bin_path)
extra <- c(
list(repodir = repodir),
list(...), .list)
Expand Down Expand Up @@ -104,7 +104,7 @@ read_packages_file <- function(path, mirror, repodir, platform,
rep(NA_character_, nrow(pkgs))
}

# RSPM sources are really binaries for the current platform
# PPM sources are really binaries for the current platform
hasbin <- pkgs$package %in% bin$Package
if (length(orig_r_version) == 1 && sum(hasbin) > 0) {
plat <- current_r_platform()
Expand Down Expand Up @@ -154,7 +154,7 @@ read_metadata_file <- function(path) {
}), error = function(e) NULL)
}

read_rspm_binaries <- function(path) {
read_ppm_binaries <- function(path) {
if (is.na(path) || !file.exists(path) || file.size(path) == 0) {
pkgs <- data_frame()
} else {
Expand Down
36 changes: 18 additions & 18 deletions R/ppm.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

async_get_rspm_versions <- function(forget = FALSE, date = NULL) {
async_get_ppm_versions <- function(forget = FALSE, date = NULL) {
tmp1 <- tempfile()
def <- if (forget ||
(!is.null(date) && date < names(pkgenv$rspm_versions[1])) ||
(!is.null(date) && date > last(names(pkgenv$rspm_versions)))) {
(!is.null(date) && date < names(pkgenv$ppm_versions[1])) ||
(!is.null(date) && date > last(names(pkgenv$ppm_versions)))) {
url <- Sys.getenv(
"PKGCACHE_RSPM_TRANSACTIONS_URL",
"PKGCACHE_PPM_TRANSACTIONS_URL",
"https://packagemanager.posit.co/__api__/sources/1/transactions?_limit=10000"
)
tmp <- tempfile()
Expand All @@ -16,10 +16,10 @@ async_get_rspm_versions <- function(forget = FALSE, date = NULL) {
vcapply(resp, function(x) as.character(x$id)),
names = vcapply(resp, function(x) as.character(x$published_to))
)
pkgenv$rspm_versions <- vrs[order(as.Date(names(vrs)))]
pkgenv$ppm_versions <- vrs[order(as.Date(names(vrs)))]
})$
catch(error = function(err) {
warning("Failed to download RSPM versions")
warning("Failed to download PPM versions")
})

} else {
Expand All @@ -28,37 +28,37 @@ async_get_rspm_versions <- function(forget = FALSE, date = NULL) {

def$
finally(function() unlink(tmp1))$
then(function() pkgenv$rspm_versions)
then(function() pkgenv$ppm_versions)
}

async_get_rspm_distros <- function(forget = FALSE, distribution = NULL,
async_get_ppm_distros <- function(forget = FALSE, distribution = NULL,
release = NULL) {
tmp2 <- tempfile()

# is this a known distro?
known <- if (is.null(distribution)) {
TRUE
} else if (is.null(release)) {
distribution %in% pkgenv$rspm_distros_cached$distribution
distribution %in% pkgenv$ppm_distros_cached$distribution
} else {
mch <- which(
distribution == pkgenv$rspm_distros_cached$distribution &
release == pkgenv$rspm_distros_cached$release
distribution == pkgenv$ppm_distros_cached$distribution &
release == pkgenv$ppm_distros_cached$release
)
!is.na(mch)
}

# can we used the cached values? Only if
# * not a forced update, and
# * distro is known, or we already updated.
updated <- !is.null(pkgenv$rspm_distros)
updated <- !is.null(pkgenv$ppm_distros)
cached <- !forget && (known || updated)
def <- if (cached) {
pkgenv$rspm_distros <- pkgenv$rspm_distros_cached
pkgenv$ppm_distros <- pkgenv$ppm_distros_cached
async_constant()
} else {
url <- Sys.getenv(
"PKGCACHE_RSPM_STATUS_URL",
"PKGCACHE_PPM_STATUS_URL",
"https://packagemanager.posit.co/__api__/status"
)
download_file(url, tmp2)$
Expand All @@ -73,15 +73,15 @@ async_get_rspm_distros <- function(forget = FALSE, distribution = NULL,
release = vcapply(stat$distros, "[[", "release"),
binaries = vlapply(stat$distros, "[[", "binaries")
)
pkgenv$rspm_distros <- dst
pkgenv$rspm_distros_cached <- dst
pkgenv$ppm_distros <- dst
pkgenv$ppm_distros_cached <- dst
})$
catch(error = function(err) {
warning("Failed to download RSPM status")
warning("Failed to download PPM status")
})
}

def$
finally(function() unlink(tmp2))$
then(function() pkgenv$rspm_distros)
then(function() pkgenv$ppm_distros)
}
Loading

0 comments on commit 12eeecf

Please sign in to comment.