build-cran-binaries/docker/reprex/alpine.sh
2024-11-01 19:32:07 +01:00

35 lines
1.1 KiB
Shell

docker run --rm -it --platform linux/arm64 alpine sh
apk add --no-cache R R-dev g++
R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/devel/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))'
R -q -e 'pak::pak(c("gert", "purrr"))'
R
package_name <- "DoE.base"
gert::git_clone(sprintf("https://github.com/cran/%s", package_name),
path = sprintf("%s/%s", tempdir(), "tmp1"),
verbose = FALSE
)
# Retrieve all tags
all_tags <- gert::git_tag_list(repo = sprintf("%s/%s", tempdir(), "tmp1"))
# filter out tags that start with R- (= non-valid ones)
all_tags <- all_tags[!grepl("R-", all_tags$name), ]
unlink(sprintf("%s/%s", tempdir(), "tmp1"), force = TRUE, recursive = TRUE)
tag <- all_tags$name
package_name <- rep(package_name, length(tag))
purrr::walk2(package_name[1], tag, \(x, y) {
print(y)
system("git config --global advice.detachedHead false")
system2("git", args = c(
"clone", "-q", sprintf("--branch=%s", tail(y, 1)),
sprintf("https://github.com/cran/%s", x[1]), sprintf("/tmp/%s_%s", x[1], y)
))
pak::local_install_deps(sprintf("/tmp/%s_%s", x[1], y))
})