Skip to content

Commit

Permalink
Merge pull request #70 from ethanwhite/fix-minicran
Browse files Browse the repository at this point in the history
Fix miniCRAN macOS repository creation
  • Loading branch information
garezana committed Nov 6, 2023
2 parents 0feab5b + c71e079 commit fbfbaf5
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions offlinedatasci/miniCran.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ args = commandArgs(trailingOnly = TRUE)
package_list = strsplit(args[2]," ")[[1]]
pth = file.path(args[1], "miniCRAN")

repo = c("https://cran.rstudio.com")
repo = c("https://cloud.r-project.org/")

install_minicran = FALSE
if (!require("miniCRAN")) {
install.packages("miniCRAN")
library("miniCRAN")
install_minicran = TRUE
} else if (packageVersion('miniCRAN') <= "0.2.16") {
install_minicran = TRUE
}

# Currently installing from ethanwhite's fork, thus requiring remotes, because the current
# R release for macOS doesn't work on the released version of miniCRAN
if (install_minicran) {
if (!require("remotes")) {
install.packages("remotes")
}
remotes::install_github("ethanwhite/miniCRAN")
}
types = c("source", "win.binary", "mac.binary")

library(miniCRAN)

types = c("source", "win.binary", "mac.binary.big-sur-x86_64", "mac.binary.big-sur-arm64")

for (type in types) {
repo_bin_path <- miniCRAN:::repoBinPath(path = pth, type = type, Rversion = R.version)
Expand All @@ -21,7 +36,7 @@ for (type in types) {
DC_pkg_tree = pkgDep(package_list, repos = repo, type = type, suggests = FALSE, Rversion = R.version)
local_cran_avail = pkgAvail(repos = pth, type = type, Rversion = R.version)[, "Version"]
pkgs_to_download = DC_pkg_tree[!DC_pkg_tree %in% names(local_cran_avail)]
if (length(pkgs_to_download) ==0) {
if (length(pkgs_to_download) == 0) {
cat("Repository already exists, checking updates for", type, "\n")
updatePackages(path = pth, repos = repo, type = type, ask = FALSE)

Expand All @@ -31,4 +46,3 @@ for (type in types) {
makeRepo(pkgs_to_download, path = pth, repos = repo, type = type)
}
}

0 comments on commit fbfbaf5

Please sign in to comment.