Skip to content

Commit

Permalink
running Run_shell correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
muschellij2 committed Oct 14, 2021
1 parent 9c71bef commit cc23739
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions R/package-installation-methods.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Opening Reproducible Research (https://o2r.info)
# C# Copyright 2018 Opening Reproducible Research (https://o2r.info)

# pkgs is a data.frame of packages with the columns name, version, and source (either "CRAN" or "github")
# function returns the given Dockerfile object with the required instructions
Expand Down Expand Up @@ -34,7 +34,7 @@ add_install_instructions <- function(base_dockerfile,

if (any(skipable))
addInstruction(base_dockerfile) <- Comment(text = paste0("CRAN packages skipped because they are in the base image: ",
skipped_str))
skipped_str))

# do not add skippable, add all non-CRAN packages
pkgs <- rbind(cran_packages[!skipable,], pkgs[pkgs$source != "CRAN",])
Expand Down Expand Up @@ -89,7 +89,7 @@ add_install_instructions <- function(base_dockerfile,

if (versioned_packages) {
futile.logger::flog.info("Versioned packages enabled, installing 'versions'")
addInstruction(base_dockerfile) <- Run_shell("install2.r", "versions")
addInstruction(base_dockerfile) <- Run_shell(paste("install2.r", "versions"))
}

# 2. add installation instruction for CRAN packages
Expand All @@ -101,7 +101,7 @@ add_install_instructions <- function(base_dockerfile,
} else {
cran_packages <- stringr::str_sort(as.character(unlist(pkgs_cran$name))) # sort, to increase own reproducibility
futile.logger::flog.info("Adding CRAN packages: %s", toString(cran_packages))
addInstruction(base_dockerfile) <- Run_shell("install2.r", cran_packages)
addInstruction(base_dockerfile) <- Run_shell(paste("install2.r", cran_packages))
}
} else futile.logger::flog.debug("No CRAN packages to add.")

Expand All @@ -115,10 +115,15 @@ add_install_instructions <- function(base_dockerfile,
bioc_packages <- stringr::str_sort(as.character(unlist(pkgs_bioc$name))) # sort, to increase own reproducibility
futile.logger::flog.info("Adding Bioconductor packages: %s", toString(bioc_packages))
repos = as.character(BiocManager::repositories())
addInstruction(base_dockerfile) <- Run_shell("install2.r", params = c(sprintf("-r %s -r %s -r %s -r %s",
repos[1], repos[2],
repos[3], repos[4]),
bioc_packages))
addInstruction(base_dockerfile) <- Run_shell(
paste(
"install2.r",
paste(c(sprintf("-r %s -r %s -r %s -r %s",
repos[1], repos[2],
repos[3], repos[4]),
bioc_packages), collapse = " ")
)
)
} else futile.logger::flog.debug("No Bioconductor packages to add.")

# 4. add installation instruction for GitHub packages
Expand Down Expand Up @@ -150,7 +155,7 @@ versioned_install_instructions <- function(pkgs) {
ifelse(!is.na(pkg["version"]),
paste0('versions::install.versions(\'', pkg["name"], '\', \'' , pkg["version"], '\')'),
NA)
},
},
MARGIN = 1)
installInstructions <- installInstructions[!is.na(installInstructions)]

Expand All @@ -161,7 +166,7 @@ versioned_install_instructions <- function(pkgs) {
unversioned <- pkgs_sorted[is.na(pkgs_sorted$version),]
unversioned <- stringr::str_sort(as.character(unlist(unversioned$name))) # sort, to increase own reproducibility
futile.logger::flog.warn("No version information found for packages: %s", toString(unversioned))
instructions <- c(Run_shell("install2.r", unversioned), instructions)
instructions <- c(Run_shell(paste("install2.r", unversioned)), instructions)
}
return(instructions)
}
Expand Down

0 comments on commit cc23739

Please sign in to comment.