Skip to content

Commit 3d1ead7

Browse files
committed
ensure Makevars has Unix newlines
1 parent c498a25 commit 3d1ead7

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

cleanup

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env sh
22
: "${R_HOME=`R RHOME`}"
3-
"${R_HOME}/bin/Rscript" tools/config.R cleanup
3+
"${R_HOME}/bin/Rscript" tools/config.R cleanup "$@"

cleanup.win

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env sh
2-
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" tools/config.R cleanup
2+
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" tools/config.R cleanup "$@"

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env sh
22
: "${R_HOME=`R RHOME`}"
3-
"${R_HOME}/bin/Rscript" tools/config.R configure
3+
"${R_HOME}/bin/Rscript" tools/config.R configure "$@"

configure.win

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env sh
2-
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" tools/config.R configure
2+
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" tools/config.R configure "$@"

tools/config.R

+14-3
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,26 @@ configure_file <- function(
7777
rhs = "@",
7878
verbose = configure_verbose())
7979
{
80+
# read source file
8081
contents <- readLines(source, warn = FALSE)
82+
83+
# replace defined variables
8184
enumerate(config, function(key, val) {
8285
needle <- paste(lhs, key, rhs, sep = "")
8386
replacement <- val
8487
contents <<- gsub(needle, replacement, contents, fixed = TRUE)
8588
})
8689

8790
ensure_directory(dirname(target))
88-
writeLines(contents, con = target)
8991

92+
# write configured file to target location
93+
# prefer unix newlines for Makevars
94+
mode <- if (target %in% "Makevars") "wb" else "w"
95+
conn <- file(target, open = mode)
96+
on.exit(close(conn), add = TRUE)
97+
writeLines(contents, con = conn)
98+
99+
# copy over source permissions
90100
info <- file.info(source)
91101
Sys.chmod(target, mode = info$mode)
92102

@@ -580,8 +590,9 @@ if (!interactive()) {
580590

581591
# switch working directory to the calling scripts's directory as set
582592
# by the shell, in case the R working directory was set to something else
583-
basedir <- Sys.getenv("PWD", unset = ".")
584-
setwd(basedir)
593+
basedir <- Sys.getenv("PWD", unset = NA)
594+
if (!is.na(basedir))
595+
setwd(basedir)
585596

586597
# report start of execution
587598
package <- Sys.getenv("R_PACKAGE_NAME", unset = "<unknown>")

0 commit comments

Comments
 (0)