From c1fbdc0da63270dcd601f55486a6047754359a10 Mon Sep 17 00:00:00 2001 From: hadley Date: Tue, 12 Jul 2011 08:26:42 -0500 Subject: [PATCH] Fix binary building bugs --- DESCRIPTION | 1 + NEWS | 3 ++- R/build.r | 12 +++++++----- R/os.r | 10 ++++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 R/os.r diff --git a/DESCRIPTION b/DESCRIPTION index 6c6c30025..ec01f8e0a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,3 +37,4 @@ Collate: 'test.r' 'utils.r' 'vignettes.r' + 'os.r' diff --git a/NEWS b/NEWS index faae61fee..bc51a3b22 100644 --- a/NEWS +++ b/NEWS @@ -17,7 +17,8 @@ * `build` is now exported, and defaults to building in the package's parent directory. It also gains a new `binary` parameter controls whether a binary - or a source version (with no vignettes or manuals) is built. + or a source version (with no vignettes or manuals) is built. Confusingly, + binary packages are built with `R CMD INSTALL`. * `install_github` now allows you to specify which branch to download diff --git a/R/build.r b/R/build.r index 3f2e8676d..5a247d1a8 100644 --- a/R/build.r +++ b/R/build.r @@ -16,13 +16,15 @@ build <- function(pkg = NULL, path = NULL, binary = FALSE) { } if (binary) { - options <- "--binary" + cmd <- paste("CMD install ", shQuote(pkg$path), " --build", sep = "") + ext <- if (os() == "win") "zip" else "tgz" } else { - options <- "--no-manual --no-vignettes" + cmd <- paste("CMD build ", shQuote(pkg$path), + " --no-manual --no-vignettes", sep = "") + ext <- "tar.gz" } - - R(paste("CMD build ", shQuote(pkg$path), " ", options, sep = ""), path) + R(cmd, path) - targz <- paste(pkg$package, "_", pkg$version, ".tar.gz", sep = "") + targz <- paste(pkg$package, "_", pkg$version, ".", ext, sep = "") file.path(path, targz) } \ No newline at end of file diff --git a/R/os.r b/R/os.r new file mode 100644 index 000000000..0ba59f8ac --- /dev/null +++ b/R/os.r @@ -0,0 +1,10 @@ +os <- function() { + os <- R.Version()$os + if (length(grep("linux", os)) == 1) { + "lin" + } else if (length(grep("darwin", os)) == 1) { + "mac" + } else { + "win" + } +}