refactor: migrate package installation from pak to uvr

bincraft dropped pak in favour of uvr, so the pipelines, helper scripts
and images in this repo move with it.

- add local/uvr-install.sh as the single replacement for pak::pak(); it
  bootstraps a pinned uvr, mints a throwaway project under TMPDIR and
  runs `uvr add --no-install` + `uvr sync --library`, because `uvr add`
  refuses to run outside a project and only `sync` honours --library
- install bincraft via its Forgejo spec (forgejo::codefloe.com/rpkgs/
  bincraft@<tag>) instead of a git:: URL, keeping the git ls-remote tag
  resolution
- pass UVR_R_BIN/UVR_TARGET_LIB from install-bincraft.R so the
  per-R-minor passes target their own R and library
- replace R_PKG_CACHE_DIR with UVR_CACHE_DIR/UVR_PACKAGES_DIR on the
  persistent volume, preserving the amd64-off/arm64-on split
- drop trim_pkgcache_metadata() and its test; uvr's cache does not grow
  the way pkgcache's _metadata dir did
- let uvr install system requirements from its vendored
  r-system-requirements rules, replacing pak::sysreqs_db_update()
- migrate the shiny app image, the alpine reprex and the CRAN loading
  test; ship uvr-install.sh in the build-one image
- track the uvr pin with renovate
This commit is contained in:
Patrick Schratz 2026-07-31 12:16:32 +00:00
commit f3c18b6805
No known key found for this signature in database
GPG key ID: 62050D5BC68AB6DC

View file

@ -1,68 +0,0 @@
source(file.path("..", "r-minor-helpers.R"))
# Build a fake _metadata dir under a temp R_PKG_CACHE_DIR. Each entry's mtime is
# set to `age_secs` in the past so we can exercise the age gate deterministically.
make_meta <- function(patched = 0L, pkgs = 0L, keep_repos = TRUE, age_secs = 3600) {
root <- tempfile("pkgcache-")
meta <- file.path(root, "R", "pkgcache", "_metadata")
dir.create(meta, recursive = TRUE)
old <- Sys.time() - age_secs
mk_dir <- function(p) { dir.create(p); Sys.setFileTime(p, old); p }
mk_file <- function(p) { writeLines("x", p); Sys.setFileTime(p, old); p }
for (i in seq_len(patched)) mk_dir(file.path(meta, sprintf("patched-%03d", i)))
for (i in seq_len(pkgs)) mk_file(file.path(meta, sprintf("pkgs-%03d.rds", i)))
if (keep_repos) {
mk_dir(file.path(meta, "CRAN-075c426938"))
mk_dir(file.path(meta, "BioCsoft-1ac964ed6c"))
mk_file(file.path(meta, "bioc-sysreqs.dcf.gz"))
mk_dir(file.path(root, "R", "pkgcache", "pkg")) # downloads, must survive
}
root
}
n_churn <- function(root) {
meta <- file.path(root, "R", "pkgcache", "_metadata")
length(Sys.glob(file.path(meta, "patched-*"))) +
length(Sys.glob(file.path(meta, "pkgs-*.rds")))
}
test_that("empty cache_dir is a no-op", {
expect_identical(trim_pkgcache_metadata("", keep = 5L, min_age_secs = 0), 0L)
})
test_that("missing _metadata dir is a no-op", {
expect_identical(
trim_pkgcache_metadata(tempfile("absent-"), keep = 5L, min_age_secs = 0),
0L
)
})
test_that("fewer than keep entries removes nothing", {
root <- make_meta(patched = 2L, pkgs = 2L)
expect_identical(trim_pkgcache_metadata(root, keep = 20L, min_age_secs = 0), 0L)
expect_identical(n_churn(root), 4L)
})
test_that("trims down to keep newest, leaving churn == keep", {
root <- make_meta(patched = 30L, pkgs = 30L) # 60 churn entries, all old
removed <- trim_pkgcache_metadata(root, keep = 20L, min_age_secs = 0)
expect_identical(removed, 40L)
expect_identical(n_churn(root), 20L)
})
test_that("entries younger than min_age_secs are protected", {
root <- make_meta(patched = 30L, pkgs = 0L, keep_repos = FALSE, age_secs = 60)
# keep=5 would drop 25, but all are 60s old < 600s gate -> nothing removed
expect_identical(trim_pkgcache_metadata(root, keep = 5L, min_age_secs = 600), 0L)
expect_identical(n_churn(root), 30L)
})
test_that("stable repo dirs and pkg downloads are never touched", {
root <- make_meta(patched = 30L, pkgs = 30L)
trim_pkgcache_metadata(root, keep = 0L, min_age_secs = 0)
meta <- file.path(root, "R", "pkgcache", "_metadata")
expect_true(dir.exists(file.path(meta, "CRAN-075c426938")))
expect_true(dir.exists(file.path(meta, "BioCsoft-1ac964ed6c")))
expect_true(file.exists(file.path(meta, "bioc-sysreqs.dcf.gz")))
expect_true(dir.exists(file.path(root, "R", "pkgcache", "pkg")))
})