-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
2,236 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,17 +23,19 @@ Imports: callr (>= 3.3.1), cli (>= 3.6.0), curl, desc (>= 1.4.3), | |
pkgcache (>= 2.2.0), processx (>= 3.4.2), ps, R6, stats, utils, | ||
zip (>= 2.3.0) | ||
Suggests: asciicast (>= 2.2.0.9000), codetools, covr, debugme, fansi, | ||
fs, glue, htmlwidgets, mockery, pak, pingr (>= 2.0.0), | ||
rmarkdown, rstudioapi, spelling, svglite, testthat (>= 3.2.0), | ||
tibble, webfakes (>= 1.1.5.9000), withr (>= 2.1.1) | ||
fs, gh, gitcreds, glue, htmlwidgets, mockery, pak, pingr (>= | ||
2.0.0), rmarkdown, rstudioapi, spelling, svglite, testthat (>= | ||
3.2.0), tibble, webfakes (>= 1.1.5.9000), withr (>= 2.1.1), | ||
Remotes: r-lib/pkgcache | ||
Config/Needs/builder: gh, pkgsearch, withr (>= 2.1.1) | ||
Config/Needs/coverage: r-lib/asciicast, covr | ||
Config/Needs/website: r-lib/asciicast, pkgdown (>= 2.0.2), | ||
tidyverse/tidytemplate | ||
Config/testthat/edition: 3 | ||
Encoding: UTF-8 | ||
RoxygenNote: 7.3.1.9000 | ||
NeedsCompilation: no | ||
Packaged: 2024-04-23 21:39:51 UTC; gaborcsardi | ||
Packaged: 2024-08-01 16:40:26 UTC; gaborcsardi | ||
Author: Gábor Csárdi [aut, cre], | ||
Posit Software, PBC [cph, fnd] | ||
Maintainer: Gábor Csárdi <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
#' Create a binary package from an installed package | ||
#' | ||
#' The built package will be in the current working directory. | ||
#' | ||
#' This function is currently experimental. | ||
#' | ||
#' @param pkg Package name. | ||
#' @param library Library path. | ||
#' @param flavor Platform flavor. Defaults to the `PKG_BUILD_FLAVOR` | ||
#' environment variable. If not `NULL` or an empty string, then it is | ||
#' appended to the platform string with a dash. | ||
#' @param build_number An integer number that is added to the file name, | ||
#' after the version number, to be able to have multiple builds for the | ||
#' same package version. | ||
#' @return Path to the built package. | ||
#' | ||
#' @export | ||
#' @keywords internal | ||
|
||
pkg_build <- function(pkg, library = .libPaths()[1], | ||
flavor = Sys.getenv("PKG_BUILD_FLAVOR"), | ||
build_number = 1L) { | ||
pkgdir <- file.path(library, pkg) | ||
if (!dir.exists(pkgdir)) { | ||
throw(pkg_error( | ||
"Cannot find package {.pkg {pkg}} in library at {.path {library}}." | ||
)) | ||
} | ||
platform <- pkgcache::current_r_platform() | ||
if (nzchar(flavor %||% "")) { | ||
platform <- paste0(platform, "-", flavor) | ||
} | ||
meta <- c( | ||
RemoteBuildPlatform = platform, | ||
GraphicsAPIVersion = pkgcache::get_graphics_api_version(), | ||
InternalsId = pkgcache::get_internals_id() | ||
) | ||
add_metadata(pkgdir, meta) | ||
dsc <- desc::desc(file = pkgdir) | ||
version <- dsc$get_field("Version") | ||
rversion <- get_minor_r_version(getRversion()) | ||
|
||
sys <- sysname() | ||
if (sys == "windows") { | ||
install_md5_sums(pkg) | ||
fn <- paste0( | ||
pkg, "_", version, "_", | ||
"b", build_number, "_", | ||
"R", rversion, | ||
if (nzchar(flavor %||% "")) paste0("_", flavor), | ||
".zip" | ||
) | ||
zip::zip(fn, pkgdir, mode = "cherry-pick") | ||
|
||
} else { | ||
ext <- if (sys == "mac") ".tgz" else ".tar.gz" | ||
fn <- paste0( | ||
pkg, "_", version, "_", | ||
"b", build_number, "_", | ||
"R", rversion, "_", | ||
platform, | ||
ext | ||
) | ||
ffn <- file.path(normalizePath("."), fn) | ||
old <- getwd() | ||
on.exit(setwd(old), add = TRUE) | ||
setwd(dirname(pkgdir)) | ||
utils::tar(ffn, pkg, compression = "gzip", compression_level = 9) | ||
} | ||
|
||
fn | ||
} | ||
|
||
install_md5_sums <- function(pkgdir) { | ||
old <- getwd() | ||
on.exit(setwd(old), add = TRUE) | ||
|
||
setwd(pkgdir) | ||
fns <- setdiff(dir(".", recursive = TRUE), "MD5") | ||
md5 <- cli::hash_file_md5(fns) | ||
writeLines( | ||
paste0(md5, " *", fns), | ||
"MD5" | ||
) | ||
} |
Oops, something went wrong.