This repository has been archived by the owner on May 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwinbuilder
60 lines (51 loc) · 1.92 KB
/
winbuilder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env Rscript
library(BBmisc)
library(checkmate)
library(devtools)
library(stringr)
#' Builds a package on winbuilder, but sends link to an arbitrary email address.
#
#' Copies the package directory to a temporary directory, changes the maintainer field and
#' then calls devtools::build_win.
#'
#' @param path [\code{character(1)}]\cr
#' Path where package is located on disk.
#' Default is current directory \dQuote{.}.
#' @param user.name [\code{character(1)}]\cr
#' User name for maintainer field. Not really needed.
#' Default is \dQuote{LIB USER}.
#' @param email [\code{character(1)}]\cr
#' Email addresss that winbdulder link should be sent to.
#' Default is to query the user on the R console.
#' @return Nothing.
buildOnWinBuilder = function(path = ".", user.name = "LIB USER", email) {
assertString(path)
assertString(user.name)
if (missing(email)) {
message("Please type in your email address like [email protected] so a link can be send to you:")
# scan does not work with Rscript. argh!
con = file("stdin")
email = readLines(con, 1L)
close(con)
}
assertString(email)
message("The package will be built on winbuilder.\nPLEASE USE THIS METHOD WITH CARE AND DO NOT AUTOMATE IT!")
# copy so we dont change anything inplace
dest.dir = tempdir()
messagef("Copying directory package dir from %s to %s.", path, dest.dir)
file.copy(path, dest.dir, recursive = TRUE)
# trim input and change field and write to disk
email = str_trim(email)
user.name = str_trim(user.name)
maintainer = sprintf("%s <%s>", user.name, email)
messagef("Setting MAINTAINER field to %s.", maintainer)
desc.path = file.path(dest.dir, "DESCRIPTION")
desc = read.dcf(desc.path)
desc[, "Maintainer"] = maintainer
write.dcf(desc, file = desc.path)
# this will also check package and do some safety validation, eg malformed email
build_win(dest.dir)
invisible(NULL)
}
buildOnWinBuilder(".")
# vim: ft = r