Skip to content

Commit

Permalink
install.R() - can now deal with a file name such as "R-3.2.4revised-w…
Browse files Browse the repository at this point in the history
…in.exe" ( Fix #50 ?)
  • Loading branch information
talgalili committed Mar 20, 2016
1 parent 7048d7a commit cb17d1b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: installr
Type: Package
Title: Using R to Install Stuff (Such As: R, Rtools, RStudio, Git, and More!)
Version: 0.17.4
Date: 2016-03-19
Version: 0.17.5
Date: 2016-03-20
Authors@R: c(person("Tal", "Galili", role = c("aut", "cre", "cph"), email =
"tal.galili@gmail.com", comment = "http://www.r-statistics.com"),
person("Barry", "Rowlingson", role = "ctb", email =
Expand Down
6 changes: 6 additions & 0 deletions NEWS
@@ -1,3 +1,9 @@
installr 0.17.5 (2016-03-20)
---------------------------
BUG FIXES:
* install.R() - can now deal with a file name such as "R-3.2.4revised-win.exe"


installr 0.17.4 (2016-03-19)
---------------------------
BUG FIXES:
Expand Down
2 changes: 1 addition & 1 deletion R/install.R
Expand Up @@ -158,7 +158,7 @@ install.URL <- function(exe_URL, keep_install_file = FALSE, wait = TRUE, downloa
# input: a url of an .exe file to install
# output: it runs the .exe file (for installing something)
exe_filename <- file.path(download_dir, file.name.from.url(exe_URL)) # the name of the zip file MUST be as it was downloaded...
tryCatch(curl::curl_download(exe_URL, destfile=exe_filename, mode = 'wb'),
tryCatch(curl::curl_download(exe_URL, destfile=exe_filename, quiet = FALSE, mode = 'wb'),
error = function(e) {
cat("\nExplanation of the error: You didn't enter a valid .EXE URL. \nThis is likely to have happened because there was a change in the software download page, and the function you just ran no longer works. \n\n This is often caused by a change in the URL of the installer file in the download page of the software (making our function unable to know what to download). \n\n Please e-mail: tal.galili@gmail.com and let me know this function needs updating/fixing - thanks!\n")
return(invisible(FALSE))
Expand Down
16 changes: 8 additions & 8 deletions R/updateR.R
Expand Up @@ -273,7 +273,7 @@ browse.latest.R.NEWS <- function(
#' install.R()
#' }
install.R <- function(page_with_download_url = "https://cran.rstudio.com/bin/windows/base/",
pat = "R-[0-9.]+-win.exe",
pat = "R-[0-9.]+.+-win\\.exe",
to_checkMD5sums = TRUE,
keep_install_file = FALSE,
download_dir = tempdir(),
Expand All @@ -282,12 +282,12 @@ install.R <- function(page_with_download_url = "https://cran.rstudio.com/bin/win
# I'm using the rsudio cran since it redirects to other servers wourld wide.
# here there is a question on how to do it with the different mirrors. (maybe to add it as an option?)
# this might be a good time for the "find the best mirror" function.
page <- readLines(page_with_download_url, warn = FALSE)
### pat <- "R-[0-9.]+-win.exe"; # moved to the function's parameters list.
target_line <- grep(pat, page, value = TRUE);
m <- regexpr(pat, target_line);
exe_filename <- regmatches(target_line, m)
URL <- paste(page_with_download_url, exe_filename, sep = '')

# stringr::str_extract("R-3.2.4revised-win.exe", pat)
page <- readLines(page_with_download_url, warn = FALSE)
filename <- na.omit(stringr::str_extract(page, pat))[1]

URL <- paste(page_with_download_url, filename, sep = '')

# add command line arguments for silent mode
if(silent){
Expand All @@ -296,7 +296,7 @@ install.R <- function(page_with_download_url = "https://cran.rstudio.com/bin/win
installer_option <- NULL
}

did_R_install <- install.URL(URL, keep_install_file = keep_install_file,download_dir=download_dir, installer_option = installer_option, ...)
did_R_install <- install.URL(URL, keep_install_file = keep_install_file, download_dir=download_dir, installer_option = installer_option, ...)
if(!did_R_install) return(FALSE)

# checks the MD5sums from the new R installation:
Expand Down
2 changes: 1 addition & 1 deletion man/install.R.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cb17d1b

Please sign in to comment.