Skip to content

Commit

Permalink
replace native pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
HenningLorenzen-ext-bayer committed Jul 19, 2024
1 parent 5ef486d commit 5c68c0d
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions R/dock_from_renv.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ pkg_sysreqs_mem <- memoise::memoise(
#' @param repos character. The URL(s) of the repositories to use for `options("repos")`.
#' @param extra_sysreqs character vector. Extra debian system requirements.
#' Will be installed with apt-get install.
#' @param renv_version character. The renv version to use in the generated Dockerfile. By default, it is set to the version specified in the `renv.lock` file.
#' @param renv_version character. The renv version to use in the generated Dockerfile. By default, it is set to the version specified in the `renv.lock` file.
#' If the `renv.lock` file does not specify a renv version,
#' the version of renv bundled with dockerfiler,
#' the version of renv bundled with dockerfiler,
#' specifically `r dockerfiler::renv$initialize();toString(dockerfiler::renv$the$metadata$version)`, will be used.
#' If you set it to `NULL`, the latest available version of renv will be used.
#' @param use_pak boolean. If `TRUE` use pak to deal with dependencies during `renv::restore()`. FALSE by default
Expand Down Expand Up @@ -86,25 +86,25 @@ dock_from_renv <- function(
dock$USER(user)
}
# get renv version

if (missing(renv_version)) {
if (!is.null(lock$Packages$renv$Version)) {
renv_version <- lock$Packages$renv$Version
} else {
renv_version <- dockerfiler::renv$the$metadata$version
}
}
}

message("renv version = ",
message("renv version = ",
ifelse(!is.null(renv_version),renv_version,"the must up to date in the repos")
)


# ici il faut connaire l'image utilisé par l'image.


# distro_args <- list(sysreqs_platform = "ubuntu-22.04")

distro_args <- list(sysreqs_platform = "ubuntu")

install_cmd <- "apt-get install -y"
Expand Down Expand Up @@ -140,27 +140,32 @@ dock_from_renv <- function(
}
)

pkg_sysreqs <- attempt::map_try_catch(

pkg_sysreqs <- unlist(attempt::map_try_catch(
pkg_os,
function(x) {
do.call(
pkg_sysreqs_mem,
x
) |>
pluck("packages") |>
keep_at("system_packages")
keep_at(
pluck(
do.call(pkg_sysreqs_mem, x),
"packages"
),
"system_packages"
)
},
.e = ~ character(0)
) |>
unlist()
))





pkg_installs <- unique(pkg_sysreqs) |>
lapply( function(.x) {paste0(install_cmd, " ", .x)})
pkg_installs <-
lapply(
X = unique(pkg_sysreqs),
FUN = function(.x) {
paste0(install_cmd, " ", .x)
}
)

if (length(unlist(pkg_installs)) == 0) {
cat_bullet(
Expand Down

0 comments on commit 5c68c0d

Please sign in to comment.