Skip to content
Draft
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
62 changes: 49 additions & 13 deletions scripts/razel.R
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,25 @@ generateWorkspaceMacro <- function(local_repo_dir = NULL,
remote_repos = getOption("repos"),
mirror_repo_url = NULL,
use_only_mirror_repo = FALSE,
use_linux_binaries = TRUE,
fail_fast = FALSE,
...) {
stopifnot(!is.null(local_repo_dir) || !is.null(package_list_csv))
stopifnot(!use_only_mirror_repo || !is.null(mirror_repo_url))
rule_type <- match.arg(rule_type)
stopifnot(!(rule_type == "http_archive" && is.null(build_file_format)))

sys_info <- Sys.info()

pkg_type <- match.arg(pkg_type)
if (getOption("pkgType") == "source") {
pkg_type <- "source"
}

if (sys_info["sysname"] == "Linux" && use_linux_binaries) {
pkg_type <- "both"
}

if (is.null(build_file_format)) {
build_file_format <- NA_character_
}
Expand All @@ -355,13 +362,16 @@ generateWorkspaceMacro <- function(local_repo_dir = NULL,
if (pkg_type == "both") {
r_version <- R.Version()
minor_version <- gsub("\\..*", "", r_version$minor)
sys_info <- Sys.info()
stopifnot(sys_info["sysname"] == "Darwin")
stopifnot(as.integer(sub("\\..*", "", sys_info["release"])) >= 20)
if (sys_info["machine"] == "arm64") {
prefix <- "mac_arm_"
} else {
prefix <- "mac_intel_"
stopifnot(sys_info["sysname"] == "Darwin" || sys_info["sysname"] == "Linux")
if (sys_info["sysname"] == "Darwin") {
stopifnot(as.integer(sub("\\..*", "", sys_info["release"])) >= 20)
if (sys_info["machine"] == "arm64") {
prefix <- "mac_arm_"
} else {
prefix <- "mac_intel_"
}
} else if (sys_info["sysname"] == "Linux"){
prefix <- "linux_"
}
sha256_col <- paste0(prefix, r_version$major, "_", minor_version, "_sha256")
if (sha256_col %in% colnames(repo_pkgs)) {
Expand Down Expand Up @@ -389,17 +399,28 @@ generateWorkspaceMacro <- function(local_repo_dir = NULL,
vecCompareVersion(repo_merged_pkgs[, "Version.binary"], repo_merged_pkgs[, "Version"]) >= 0
}
}

binary_extension <- ".tgz"
if (sys_info["sysname"] == "Linux" && use_linux_binaries) binary_extension <- ".tar.gz"

repo_pkgs <- cbind(repo_pkgs,
Archive = paste0(repo_pkgs$Package, "_", repo_pkgs$Version,
Archive = paste0(repo_pkgs$Package, "_", repo_pkgs$Version,
ifelse(repo_pkgs[, "binary_package_available"],
".tgz", ".tar.gz")),
stringsAsFactors = FALSE)
binary_extension, ".tar.gz")),
stringsAsFactors = FALSE)

linuxBinarySubrepoPath <- function(repo) {
r_version <- R.Version()
repo_r_version <- sprintf("%s.%s",r_version$major, gsub("\\..*", "", r_version$minor))
subrepo_path <- sprintf("/bin/linux/%s", repo_r_version)
return(paste0(repo, subrepo_path))
}

findPackages <- function(repos, suffix) {
mergeWithRemote <- function(type) {
remote_pkgs <- as.data.frame(
available.packages(repos = repos, type = type)[, c("Package", "Repository")],
stringsAsFactors = FALSE)
available.packages(repos = repos, type = type)[, c("Package", "Repository")],
stringsAsFactors = FALSE)
colnames(remote_pkgs) <- c("Package", paste0("Repository", suffix))
if (type == "binary") {
pkg_idx <- which(repo_pkgs[, "binary_package_available"])
Expand All @@ -409,8 +430,23 @@ generateWorkspaceMacro <- function(local_repo_dir = NULL,
merge(repo_pkgs[pkg_idx, ], remote_pkgs, by = "Package", all.x = TRUE, all.y = FALSE)
}

mergeWithRemoteLinuxBinaries <- function() {
linuxBinaryRepos <- sapply(repos, linuxBinarySubrepoPath)
remote_pkgs <- as.data.frame(
available.packages(repos = linuxBinaryRepos, type = "source")[, c("Package", "Repository")],
stringsAsFactors = FALSE)
colnames(remote_pkgs) <- c("Package", paste0("Repository", suffix))
pkg_idx <- which(repo_pkgs[, "binary_package_available"])
merge(repo_pkgs[pkg_idx, ], remote_pkgs, by = "Package", all.x = TRUE, all.y = FALSE)
}

if (pkg_type == "both") {
unordered_df <- rbind(mergeWithRemote("binary"), mergeWithRemote("source"),
if(suffix == ".mirrored" && sys_info["sysname"] == "Linux" && use_linux_binaries){
remoteBinaries <- mergeWithRemoteLinuxBinaries()
} else {
remoteBinaries <- mergeWithRemote("binary")
}
unordered_df <- rbind(remoteBinaries, mergeWithRemote("source"),
make.row.names = FALSE, stringsAsFactors = FALSE)
ordered_df <- unordered_df[match(repo_pkgs[, "Package"], unordered_df[, "Package"]), ]
stopifnot(identical(ordered_df[, "Package"], repo_pkgs[, "Package"]))
Expand Down
11 changes: 10 additions & 1 deletion scripts/repo_management.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ macContribDirs <- function(r_version) {
return(sprintf("/bin/macosx/%scontrib/%s", contrib_prefix, r_version))
}

linuxContribDir <- function(r_version){
return(sprintf("/bin/linux/%s/src/contrib", r_version))
}

# Returns windows binary archive locations of repos based on R version.
winContribDir <- function(r_version) {
stopifnot(r_version %in% getOption("RVersions"))
Expand All @@ -70,7 +74,8 @@ isValidBinRepo <- function(repo, r_version) {
}

bioc_version <- gsub("(.*packages/|/bioc)", "", repo)
return((bioc_version == "3.14" && r_version == "4.1") ||
return((bioc_version == "3.18" && r_version == "4.3") ||
(bioc_version == "3.14" && r_version == "4.1") ||
(bioc_version == "3.13" && r_version == "4.1") ||
(bioc_version == "3.12" && r_version == "4.0") ||
(bioc_version == "3.11" && r_version == "4.0") ||
Expand Down Expand Up @@ -201,12 +206,16 @@ updateRepoIndex <- function(repo_dir) {
tools::write_PACKAGES(paste0(repo_dir, srcContribDir()), type = "source", latestOnly = FALSE)
for (r_version in getOption("RVersions")) {
macDirs <- paste0(repo_dir, macContribDirs(r_version))
linuxDir <- paste0(repo_dir, linuxContribDir(r_version))
winDir <- paste0(repo_dir, winContribDir(r_version))
for (macDir in macDirs) {
if (file.exists(macDir)) {
tools::write_PACKAGES(macDir, type = "mac.binary", latestOnly = FALSE)
}
}
if (file.exists(linuxDir)) {
tools::write_PACKAGES(linuxDir, type = "source", latestOnly = FALSE)
}
if (file.exists(winDir)) {
tools::write_PACKAGES(winDir, type = "win.binary", latestOnly = FALSE)
}
Expand Down
Loading