Skip to content

Commit

Permalink
material -> materials
Browse files Browse the repository at this point in the history
  • Loading branch information
schochastics committed Feb 10, 2023
1 parent 8709e58 commit db7a2d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Description: Resolve the dependency graph of R packages at a specific time point
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
Expand Down
24 changes: 12 additions & 12 deletions R/installation.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@
basic_docker[gran_line:length(basic_docker)])
}

.insert_material_dir <- function(basic_docker){
.insert_materials_dir <- function(basic_docker){
gran_line <- which(basic_docker == "COPY gran.R ./gran.R")
c(basic_docker[1:gran_line],
"COPY material/ ./material/",
"COPY materials/ ./materials/",
basic_docker[(gran_line+1):length(basic_docker)])
}

.generate_pre310_docker <- function(material_dir,r_version, debian_version = "lenny", lib, sysreps_cmd, cache) {
.generate_pre310_docker <- function(materials_dir,r_version, debian_version = "lenny", lib, sysreps_cmd, cache) {
basic_docker <- c(
paste0("FROM debian/eol:", debian_version),
"ENV TZ UTC",
Expand Down Expand Up @@ -257,7 +257,7 @@ export_granlist <- function(granlist, path, granlist_as_comment = TRUE, verbose
#' This function exports the result from [resolve()] to a Docker file. For R version >= 3.1.0, the Dockerfile is based on the versioned Rocker image.
#' For R version < 3.1.0, the Dockerfile is based on Debian and it compiles R from source.
#' @param output_dir where to put the Docker file
#' @param material_dir additional resources (e.g. analysis scripts) to be copied into `output_dir`
#' @param materials_dir additional resources (e.g. analysis scripts) to be copied into `output_dir`
#' @param image character, which versioned Rocker image to use. Can only be "r-ver", "rstudio", "tidyverse", "verse", "geospatial".
#' This applies only to R version <= 3.1
#' @param cache logical, whether to cache the content from CRAN now. Please note that the system requirements are not cached
Expand All @@ -278,7 +278,7 @@ export_granlist <- function(granlist, path, granlist_as_comment = TRUE, verbose
#' }
#' }
#' @export
dockerize <- function(granlist, output_dir, material_dir = NULL, image = c("r-ver", "rstudio", "tidyverse", "verse", "geospatial"),
dockerize <- function(granlist, output_dir, materials_dir = NULL, image = c("r-ver", "rstudio", "tidyverse", "verse", "geospatial"),
granlist_as_comment = TRUE, cache = FALSE, verbose = TRUE, lib = NA,
cran_mirror = "https://cran.r-project.org/", check_cran_mirror = TRUE) {
if (missing(output_dir)) {
Expand All @@ -305,7 +305,7 @@ dockerize <- function(granlist, output_dir, material_dir = NULL, image = c("r-ve
if (utils::compareVersion(granlist$r_version, "3.1") == -1) {
file.copy(system.file("compile_r.sh", package = "gran"), file.path(output_dir, "compile_r.sh"),
overwrite = TRUE)
basic_docker <- .generate_pre310_docker(material_dir, r_version = granlist$r_version,
basic_docker <- .generate_pre310_docker(materials_dir, r_version = granlist$r_version,
sysreps_cmd = sysreps_cmd, lib = lib,
cache = cache)
} else {
Expand All @@ -323,18 +323,18 @@ dockerize <- function(granlist, output_dir, material_dir = NULL, image = c("r-ve
basic_docker <- .insert_cache_dir(basic_docker)
}
}
if(!is.null(material_dir)){
if(!dir.exists(material_dir)){
stop(paste0("The folder ",material_dir," does not exist"),call. = FALSE)
if(!is.null(materials_dir)){
if(!dir.exists(materials_dir)){
stop(paste0("The folder ",materials_dir," does not exist"),call. = FALSE)
} else{
out_mat_dir <- paste0(output_dir,"/material")
out_mat_dir <- paste0(output_dir,"/materials")
if (!dir.exists(out_mat_dir)) {
dir.create(out_mat_dir)
}
file.copy(list.files(material_dir, full.names = TRUE),
file.copy(list.files(materials_dir, full.names = TRUE),
out_mat_dir,
recursive = TRUE)
basic_docker <- .insert_material_dir(basic_docker)
basic_docker <- .insert_materials_dir(basic_docker)
}
}
writeLines(basic_docker, file.path(output_dir, "Dockerfile"))
Expand Down
3 changes: 3 additions & 0 deletions man/dockerize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit db7a2d7

Please sign in to comment.