Skip to content

Commit c57d71e

Browse files
committed
Added cran_mirror option to updateR().
1 parent 98ef844 commit c57d71e

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

DESCRIPTION

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: installr
22
Type: Package
33
Title: Using R to Install Stuff (Such As: R, Rtools, RStudio, Git, and More!)
4-
Version: 0.18.0
5-
Date: 2016-07-03
4+
Version: 0.19.0
5+
Date: 2016-11-05
66
Authors@R: c(person("Tal", "Galili", role = c("aut", "cre", "cph"), email =
77
"tal.galili@gmail.com", comment = "http://www.r-statistics.com"),
88
person("Barry", "Rowlingson", role = "ctb", email =
@@ -26,7 +26,8 @@ Authors@R: c(person("Tal", "Galili", role = c("aut", "cre", "cph"), email =
2626
"https://github.com/BerryBoessenkool", role = "ctb"),
2727
person("Jonathan",
2828
"Godfrey", email = "a.j.godfrey@massey.ac.nz", comment =
29-
"https://github.com/ajrgodfrey", role = "ctb")
29+
"https://github.com/ajrgodfrey", role = "ctb"),
30+
person("Tom", "Allard", email = "tallard@frb.gov", role = "ctb")
3031
)
3132
Description: R is great for installing software. Through the 'installr'
3233
package you can automate the updating of R (on Windows, using updateR())

R/updateR.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ copy.packages.between.libraries <- function(from, to, ask = FALSE, keep_old = TR
683683
#' @param download_dir A character of the directory into which to download the file. (default is \link{tempdir}())
684684
#' @param silent If TRUE - enables silent installation mode.
685685
#' @param setInternet2 logical. Should setInternet2(TRUE) be run. (only relevant for versions of R before 3.3.0)
686+
#' @param cran_mirror URL of your preferred CRAN mirror. (default is https://cran.rstudio.com/)
686687
#' @param ... Other arguments (this is currently not used in any way)
687688
#' @return a TRUE/FALSE value on whether or not R was updated.
688689
#' @seealso \link{check.for.updates.R}, \link{install.R},
@@ -703,7 +704,9 @@ updateR <- function(fast = FALSE,
703704
keep_old_packages, update_packages, start_new_R, quit_R, print_R_versions=TRUE, GUI = TRUE,
704705
to_checkMD5sums = FALSE, keep_install_file = FALSE, download_dir = tempdir(),
705706
silent = FALSE,
706-
setInternet2 = TRUE, ...) {
707+
setInternet2 = TRUE,
708+
cran_mirror = "https://cran.rstudio.com/",
709+
...) {
707710
# this function checks if we have the latest version of R
708711
# IF not - it notifies the user - and leaves.
709712
# If there is a new version - it offers the user to download and install it.
@@ -735,7 +738,8 @@ updateR <- function(fast = FALSE,
735738

736739
old_R_path <- get.installed.R.folders()[1]
737740

738-
there_is_a_newer_version_of_R <- check.for.updates.R(print_R_versions, GUI = GUI)
741+
there_is_a_newer_version_of_R <- check.for.updates.R(print_R_versions, GUI = GUI,
742+
page_with_download_url = paste0(cran_mirror,"bin/windows/base/"))
739743

740744
if(!there_is_a_newer_version_of_R) return(FALSE) # if we have the latest version - we might as well stop now...
741745

@@ -758,7 +762,7 @@ updateR <- function(fast = FALSE,
758762

759763
# if we got this far, the user wants to install the latest version of R (and his current version is old)
760764
cat("Installing the newest version of R,\n please wait for the installer file to be download and executed.\n Be sure to click 'next' as needed...\n")
761-
did_R_install <- install.R(to_checkMD5sums = to_checkMD5sums, keep_install_file = keep_install_file, download_dir = download_dir, silent = silent)
765+
did_R_install <- install.R(to_checkMD5sums = to_checkMD5sums, keep_install_file = keep_install_file, download_dir = download_dir, silent = silent, page_with_download_url = paste0(cran_mirror,"bin/windows/base/"))
762766
if(!did_R_install) return(FALSE)
763767
new_R_path <- get.installed.R.folders()[1]
764768

@@ -811,7 +815,7 @@ your packages to the new R installation.\n")
811815

812816
if(update_packages & copy_packages) { # we should not update packages if we didn't copy them first...
813817
new_Rscript_path <- file.path(new_R_path, "bin/Rscript.exe") # make sure to run the newer R to update the packages.
814-
update_packages_expression <- paste(new_Rscript_path, ' -e " options(repos=structure(c(CRAN=\'https://cran.rstudio.com/\'))); update.packages(checkBuilt=TRUE, ask=FALSE) "')
818+
update_packages_expression <- paste0(new_Rscript_path, ' -e " options(repos=structure(c(CRAN=\'',cran_mirror,'\'))); update.packages(checkBuilt=TRUE, ask=FALSE) "')
815819
# update_packages_expression <- paste(new_Rscript_path, ' -e " setInternet2(TRUE); options(repos=structure(c(CRAN=\'https://cran.rstudio.com/\'))); update.packages(checkBuilt=TRUE, ask=FALSE) "')
816820
# update_packages_expression <- paste(new_Rscript_path, ' -e "date()"')
817821
# update_packages_expression <- paste(new_Rscript_path, ' -e "print(R.version)"')

man/updateR.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)