diff -Nru r-cran-downloader-0.3/debian/changelog r-cran-downloader-0.4/debian/changelog --- r-cran-downloader-0.3/debian/changelog 2014-10-01 07:39:08.000000000 +0000 +++ r-cran-downloader-0.4/debian/changelog 2016-12-12 12:54:28.000000000 +0000 @@ -1,3 +1,25 @@ +r-cran-downloader (0.4-1) unstable; urgency=medium + + * Team upload + + [ Sebastian Gibb ] + * New upstream release. + * debian/control: + - Use secure canonical URL in Homepage. + - Use secure https URLs in Vcs-Git and Vcs-Browser. + - Set Standards-Version to 3.9.8. + + [ Andreas Tille ] + * cme fix dpkg-control + * Architecture: all + * Convert to dh-r + * debhelper 10 + * Update d/copyright + * d/watch: version=4 + * Add autopkgtest + + -- Andreas Tille Mon, 12 Dec 2016 13:54:28 +0100 + r-cran-downloader (0.3-3) unstable; urgency=low [ The Debichem Group ] @@ -8,7 +30,7 @@ [ Filippo Rusconi ] * Upload. - + -- Filippo Rusconi Wed, 01 Oct 2014 09:38:58 +0200 r-cran-downloader (0.3-2) unstable; urgency=low diff -Nru r-cran-downloader-0.3/debian/compat r-cran-downloader-0.4/debian/compat --- r-cran-downloader-0.3/debian/compat 2014-10-01 07:39:08.000000000 +0000 +++ r-cran-downloader-0.4/debian/compat 2016-12-12 12:54:28.000000000 +0000 @@ -1 +1 @@ -9 +10 diff -Nru r-cran-downloader-0.3/debian/control r-cran-downloader-0.4/debian/control --- r-cran-downloader-0.3/debian/control 2014-10-01 07:39:08.000000000 +0000 +++ r-cran-downloader-0.4/debian/control 2016-12-12 12:54:28.000000000 +0000 @@ -1,17 +1,23 @@ Source: r-cran-downloader -Section: gnu-r -Priority: optional Maintainer: The Debichem Group Uploaders: Filippo Rusconi -Build-Depends: debhelper (>= 9), cdbs, r-base-dev (>= 2.15.0), r-cran-digest -Standards-Version: 3.9.5 -Homepage: http://cran.r-project.org/web/packages/downloader/index.html -Vcs-Git: git://anonscm.debian.org/debichem/packages/r-cran-downloader.git -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=debichem/packages/r-cran-downloader.git +Section: gnu-r +Priority: optional +Build-Depends: debhelper (>= 10), + dh-r, + r-base-dev, + r-cran-digest +Standards-Version: 3.9.8 +Vcs-Browser: https://anonscm.debian.org/cgit/debichem/packages/r-cran-downloader.git +Vcs-Git: https://alioth.debian.org/anonscm/git/debichem/packages/r-cran-downloader.git +Homepage: https://cran.r-project.org/package=downloader Package: r-cran-downloader -Architecture: any -Depends: r-cran-digest, ${misc:Depends}, ${R:Depends} +Architecture: all +Depends: ${misc:Depends}, + ${R:Depends} +Recommends: ${R:Recommends} +Suggests: ${R:Suggests} Description: GNU R package for downloading files over http and https This package provides a wrapper for the download.file function, making it possible to download files over https on Windows, Mac OS X, and other diff -Nru r-cran-downloader-0.3/debian/copyright r-cran-downloader-0.4/debian/copyright --- r-cran-downloader-0.3/debian/copyright 2014-10-01 07:39:08.000000000 +0000 +++ r-cran-downloader-0.4/debian/copyright 2016-12-12 12:54:28.000000000 +0000 @@ -1,10 +1,10 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: downloader Upstream-Contact: Winston Chang -Source: http://cran.r-project.org/web/packages/downloader/index.html +Source: https://cran.r-project.org/package=downloader Files: * -Copyright: 2012, 2013 Winston Chang +Copyright: 2012-2015 Winston Chang License: GPL-2 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ Files: debian/* -Copyright: 2013 Sebastian Gibb +Copyright: 2013-2016 Sebastian Gibb License: GPL-3 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff -Nru r-cran-downloader-0.3/debian/docs r-cran-downloader-0.4/debian/docs --- r-cran-downloader-0.3/debian/docs 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-downloader-0.4/debian/docs 2016-12-12 12:54:28.000000000 +0000 @@ -0,0 +1,3 @@ +tests +debian/README.test +debian/tests/run-unit-test diff -Nru r-cran-downloader-0.3/debian/README.test r-cran-downloader-0.4/debian/README.test --- r-cran-downloader-0.3/debian/README.test 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-downloader-0.4/debian/README.test 2016-12-12 12:54:28.000000000 +0000 @@ -0,0 +1,8 @@ +Notes on how this package can be tested. +──────────────────────────────────────── + +This package can be tested by executing + + sh run-unit-test + +in order to confirm its integrity. diff -Nru r-cran-downloader-0.3/debian/rules r-cran-downloader-0.4/debian/rules --- r-cran-downloader-0.3/debian/rules 2014-10-01 07:39:08.000000000 +0000 +++ r-cran-downloader-0.4/debian/rules 2016-12-12 12:54:28.000000000 +0000 @@ -1,15 +1,11 @@ #!/usr/bin/make -f -# -*- makefile -*- -# debian/rules file for the Debian/GNU Linux r-cran-downloader package -# Copyright 2013 by Sebastian Gibb -include /usr/share/R/debian/r-cran.mk +%: + dh $@ --buildsystem R -DEB_DH_ALWAYS_EXCLUDE := README.md -DEB_INSTALL_DOCS_ALL := -DEB_INSTALL_CHANGELOGS_ALL := NEWS +override_dh_installchangelogs: + dh_installchangelogs NEWS get-orig-source: ## download newest version from CRAN uscan --no-conf --force-download --no-symlink --destdir ../tarballs - diff -Nru r-cran-downloader-0.3/debian/tests/control r-cran-downloader-0.4/debian/tests/control --- r-cran-downloader-0.3/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-downloader-0.4/debian/tests/control 2016-12-12 12:54:28.000000000 +0000 @@ -0,0 +1,3 @@ +Tests: run-unit-test +Depends: @, r-cran-testthat +Restrictions: allow-stderr diff -Nru r-cran-downloader-0.3/debian/tests/run-unit-test r-cran-downloader-0.4/debian/tests/run-unit-test --- r-cran-downloader-0.3/debian/tests/run-unit-test 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-downloader-0.4/debian/tests/run-unit-test 2016-12-12 12:54:28.000000000 +0000 @@ -0,0 +1,13 @@ +#!/bin/sh -e + +oname=downloader +pkg=r-cran-`echo $oname | tr '[A-Z]' '[a-z]'` + +if [ "$ADTTMP" = "" ] ; then + ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX` + trap "rm -rf $ADTTMP" 0 INT QUIT ABRT PIPE TERM +fi +cd $ADTTMP +cp -a /usr/share/doc/${pkg}/tests/* $ADTTMP +find . -type f -name "*.gz" -exec gunzip \{\} \; +LC_ALL=C R --no-save < test-all.R diff -Nru r-cran-downloader-0.3/debian/watch r-cran-downloader-0.4/debian/watch --- r-cran-downloader-0.3/debian/watch 2014-10-01 07:39:08.000000000 +0000 +++ r-cran-downloader-0.4/debian/watch 2016-12-12 12:54:28.000000000 +0000 @@ -1,3 +1,3 @@ -version=3 +version=4 http://cran.r-project.org/src/contrib/downloader_([\d\.]*).tar.gz diff -Nru r-cran-downloader-0.3/DESCRIPTION r-cran-downloader-0.4/DESCRIPTION --- r-cran-downloader-0.3/DESCRIPTION 2013-05-01 05:23:57.000000000 +0000 +++ r-cran-downloader-0.4/DESCRIPTION 2015-07-09 12:47:41.000000000 +0000 @@ -1,21 +1,20 @@ Package: downloader Maintainer: Winston Chang Author: Winston Chang -Version: 0.3 +Version: 0.4 License: GPL-2 -Title: A package for downloading files over http and https -Description: This package provides a wrapper for the download.file - function, making it possible to download files over https on - Windows, Mac OS X, and other Unix-like platforms. The RCurl - package provides this functionality (and much more) but can be - difficult to install because it must be compiled with external - dependencies. This package has no external dependencies, so it - is much easier to install. +Title: Download Files over HTTP and HTTPS +Description: Provides a wrapper for the download.file function, + making it possible to download files over HTTPS on Windows, Mac OS X, and + other Unix-like platforms. The 'RCurl' package provides this functionality + (and much more) but can be difficult to install because it must be compiled + with external dependencies. This package has no external dependencies, so + it is much easier to install. URL: https://github.com/wch/downloader -Imports: digest +Imports: utils, digest Suggests: testthat -Collate: 'download.r' 'downloader-package.r' 'source_url.r' 'sha_url.r' -Packaged: 2013-05-01 03:58:23 UTC; winston +BugReports: https://github.com/wch/downloader/issues NeedsCompilation: no +Packaged: 2015-07-09 01:22:22 UTC; winston Repository: CRAN -Date/Publication: 2013-05-01 07:23:57 +Date/Publication: 2015-07-09 14:47:41 diff -Nru r-cran-downloader-0.3/man/downloader.Rd r-cran-downloader-0.4/man/downloader.Rd --- r-cran-downloader-0.3/man/downloader.Rd 2012-12-12 23:13:05.000000000 +0000 +++ r-cran-downloader-0.4/man/downloader.Rd 2015-07-08 01:29:24.000000000 +0000 @@ -1,15 +1,16 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/downloader-package.r \docType{package} \name{downloader} \alias{downloader} \alias{downloader-package} \title{downloader: a package for making it easier to download files over https} \description{ - This package provides a wrapper for the download.file - function, making it possible to download files over https - on Windows, Mac OS X, and other Unix-like platforms. The - RCurl package provides this functionality (and much more) - but can be difficult to install because it must be - compiled with external dependencies. This package has no - external dependencies, so it is much easier to install. +This package provides a wrapper for the download.file function, +making it possible to download files over https on Windows, Mac OS X, and +other Unix-like platforms. The RCurl package provides this functionality +(and much more) but can be difficult to install because it must be compiled +with external dependencies. This package has no external dependencies, so +it is much easier to install. } diff -Nru r-cran-downloader-0.3/man/download.Rd r-cran-downloader-0.4/man/download.Rd --- r-cran-downloader-0.3/man/download.Rd 2013-02-05 17:38:08.000000000 +0000 +++ r-cran-downloader-0.4/man/download.Rd 2015-07-08 01:29:24.000000000 +0000 @@ -1,40 +1,38 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/download.r \name{download} \alias{download} \title{Download a file, using http, https, or ftp} \usage{ - download(url, ...) +download(url, ...) } \arguments{ - \item{url}{The URL to download.} +\item{url}{The URL to download.} - \item{...}{Other arguments that are passed to - \code{\link{download.file}}.} +\item{...}{Other arguments that are passed to \code{\link{download.file}}.} } \description{ - This is a wrapper for \code{\link{download.file}} and - takes all the same arguments. The only difference is - that, if the protocol is https, it changes some settings - to make it work. How exactly the settings are changed - differs among platforms. +This is a wrapper for \code{\link{download.file}} and takes all the same +arguments. The only difference is that, if the protocol is https, it changes +some settings to make it work. How exactly the settings are changed differs +among platforms. } \details{ - This function also should follow http redirects on all - platforms, which is something that does not happen by - default when \code{curl} is used, as on Mac OS X. +This function also should follow http redirects on all platforms, which is +something that does not happen by default when \code{curl} is used, as on Mac +OS X. - With Windows, it calls \code{setInternet2}, which tells R - to use the \code{internet2.dll}. Then it downloads the - file by calling \code{\link{download.file}} using the - \code{"internal"} method. +With Windows, it either uses the \code{"wininet"} method (for R 3.2) or uses +the \code{"internal"} method after first ensuring that \code{setInternet2}, +is active (which tells R to use the \code{internet2.dll}). - On other platforms, it will try to use \code{wget}, then - \code{curl}, and then \code{lynx} to download the file. - Typically, Linux platforms will have \code{wget} - installed, and Mac OS X will have \code{curl}. +On other platforms, it will try to use \code{libcurl}, \code{wget}, then +\code{curl}, and then \code{lynx} to download the file. R 3.2 will typically +have the \code{libcurl} method and for previous versions of R Linux platforms +will have \code{wget} installed, and Mac OS X will have \code{curl}. - Note that for many (perhaps most) types of files, you - will want to use \code{mode="wb"} so that the file is - downloaded in binary mode. +Note that for many (perhaps most) types of files, you will want to use +\code{mode="wb"} so that the file is downloaded in binary mode. } \examples{ \dontrun{ @@ -44,7 +42,7 @@ } } \seealso{ - \code{\link{download.file}} for more information on the - arguments that can be used with this function. +\code{\link{download.file}} for more information on the arguments + that can be used with this function. } diff -Nru r-cran-downloader-0.3/man/sha_url.Rd r-cran-downloader-0.4/man/sha_url.Rd --- r-cran-downloader-0.3/man/sha_url.Rd 2013-05-01 03:56:16.000000000 +0000 +++ r-cran-downloader-0.4/man/sha_url.Rd 2015-07-09 01:21:31.000000000 +0000 @@ -1,30 +1,35 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/sha_url.r \name{sha_url} \alias{sha_url} \title{Download a file from a URL and find a SHA-1 hash of it} \usage{ - sha_url(url, cmd = TRUE) +sha_url(url, cmd = TRUE) } \arguments{ - \item{url}{The URL of the file to find a hash of.} +\item{url}{The URL of the file to find a hash of.} - \item{cmd}{If \code{TRUE} (the default), print out a - command for sourcing the URL with - \code{\link{source_url}()}, including the hash.} +\item{cmd}{If \code{TRUE} (the default), print out a command for sourcing the + URL with \code{\link{source_url}()}, including the hash.} } \description{ - This will download a file and find a SHA-1 hash of it, - using \code{\link{digest}()}. The primary purpose of this - function is to provide an easy way to find the value of - \code{sha} which can be passed to - \code{\link{source_url}()}. +This will download a file and find a SHA-1 hash of it, using +\code{\link{digest}()}. The primary purpose of this function is to provide +an easy way to find the value of \code{sha} which can be passed to +\code{\link{source_url}()}. } \examples{ \dontrun{ # Get the SHA hash of a file. It will print the text below and return -# the hash as a string -sha_url("https://gist.github.com/wch/dae7c106ee99fe1fdfe7/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r") +# the hash as a string. This is a very long URL; break it up so it can be +# seen more easily in the examples. +test_url <- paste0("https://gist.github.com/wch/dae7c106ee99fe1fdfe7", + "/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r") +sha_url(test_url) # Command for sourcing the URL: -# downloader::source_url("https://gist.github.com/wch/dae7c106ee99fe1fdfe7/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r", sha="9b8ff5213e32a871d6cb95cce0bed35c53307f61") +# downloader::source_url("https://gist.github.com/wch/dae7c106ee99fe1fdfe7 +# /raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r", +# sha="9b8ff5213e32a871d6cb95cce0bed35c53307f61") # [1] "9b8ff5213e32a871d6cb95cce0bed35c53307f61" } } diff -Nru r-cran-downloader-0.3/man/source_url.Rd r-cran-downloader-0.4/man/source_url.Rd --- r-cran-downloader-0.3/man/source_url.Rd 2013-05-01 03:56:16.000000000 +0000 +++ r-cran-downloader-0.4/man/source_url.Rd 2015-07-09 01:21:31.000000000 +0000 @@ -1,62 +1,65 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/source_url.r \name{source_url} \alias{source_url} \title{Download an R file from a URL and source it} \usage{ - source_url(url, sha = NULL, ..., prompt = TRUE, - quiet = FALSE) +source_url(url, sha = NULL, ..., prompt = TRUE, quiet = FALSE) } \arguments{ - \item{url}{The URL to download.} +\item{url}{The URL to download.} - \item{sha}{A SHA-1 hash of the file at the URL.} +\item{sha}{A SHA-1 hash of the file at the URL.} - \item{prompt}{Prompt the user if no value for \code{sha} - is provided.} +\item{...}{Other arguments that are passed to \code{\link{source}()}.} - \item{quiet}{If \code{FALSE} (the default), print out - status messages about checking SHA.} +\item{prompt}{Prompt the user if no value for \code{sha} is provided.} - \item{...}{Other arguments that are passed to - \code{\link{source}()}.} +\item{quiet}{If \code{FALSE} (the default), print out status messages about +checking SHA.} } \description{ - This will download a file and source it. Because it uses - the \code{\link{download}()} function, it can handle - https URLs. +This will download a file and source it. Because it uses the +\code{\link{download}()} function, it can handle https URLs. } \details{ - By default, \code{source_url()} checks the SHA-1 hash of - the file. If it differs from the expected value, it will - throw an error. The default expectation is that a hash is - provided; if not, \code{source_url()} will prompt the - user, asking if they are sure they want to continue, - unless \code{prompt=FALSE} is used. In other words, if - you use \code{prompt=FALSE}, it will run the remote code - without checking the hash, and without asking the user. - - The purpose of checking the hash is to ensure that the - file has not changed. If a \code{source_url} command with - a hash is posted in a public forum, then others who - source the URL (with the hash) are guaranteed to run the - same code every time. This means that the author doesn't - need to worry about the security of the server hosting - the file. It also means that the users don't have to - worry about the file being replaced with a damaged or - maliciously-modified version. - - To find the hash of a local file, use - \code{\link{digest}()}. For a simple way to find the hash - of a remote file, use \code{\link{sha_url}()}. +By default, \code{source_url()} checks the SHA-1 hash of the file. If it +differs from the expected value, it will throw an error. The default +expectation is that a hash is provided; if not, \code{source_url()} will +prompt the user, asking if they are sure they want to continue, unless +\code{prompt=FALSE} is used. In other words, if you use \code{prompt=FALSE}, +it will run the remote code without checking the hash, and without asking +the user. + +The purpose of checking the hash is to ensure that the file has not changed. +If a \code{source_url} command with a hash is posted in a public forum, then +others who source the URL (with the hash) are guaranteed to run the same +code every time. This means that the author doesn't need to worry about the +security of the server hosting the file. It also means that the users don't +have to worry about the file being replaced with a damaged or +maliciously-modified version. + +To find the hash of a local file, use \code{\link{digest}()}. For a simple +way to find the hash of a remote file, use \code{\link{sha_url}()}. } \examples{ \dontrun{ # Source the a sample file -downloader::source_url("https://gist.github.com/wch/dae7c106ee99fe1fdfe7/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r", - sha="9b8ff5213e32a871d6cb95cce0bed35c53307f61") + +# This is a very long URL; break it up so it can be seen more easily in the +# examples. +test_url <- paste0("https://gist.github.com/wch/dae7c106ee99fe1fdfe7", + "/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r") +downloader::source_url(test_url, + sha = "9b8ff5213e32a871d6cb95cce0bed35c53307f61") + +# Find the hash of a file +downloader::sha_url(test_url) } } \seealso{ - \code{\link{source}()} for more information on the - arguments that can be used with this function. +\code{\link{source}()} for more information on the arguments + that can be used with this function. The \code{\link{sha_url}()} function + can be used to find the SHA-1 hash of a remote file. } diff -Nru r-cran-downloader-0.3/MD5 r-cran-downloader-0.4/MD5 --- r-cran-downloader-0.3/MD5 2013-05-01 05:23:57.000000000 +0000 +++ r-cran-downloader-0.4/MD5 2015-07-09 12:47:41.000000000 +0000 @@ -1,15 +1,15 @@ -80e4cbda3b1a0336c6ba7d0f329b5dca *DESCRIPTION -4a0dc8018d8913ec0d00a5bfc9a2caea *NAMESPACE -14176d8c318701239b9b6759e01f324d *NEWS -d4dc41f688c23edc6a3a2b75ca5c88b5 *R/download.r +4dfdf8b343119e2e138980b3297c7673 *DESCRIPTION +3628fb18c1e260b2ab16f58df07da7a1 *NAMESPACE +dad3d7600527fe5e0abfaf2655f741a1 *NEWS +277477bb3ee86166b64697932f895018 *R/download.r de21e78821c43a2c90f2cfb9fec2dc6d *R/downloader-package.r -940c51690b21750f42c30cae06ff83e6 *R/sha_url.r -c07bfa9c90d8a83779bede4e7757403d *R/source_url.r +91dd3acb776aa923270c99e737ed5581 *R/sha_url.r +eb7e970f16ac9134e791ea619d39f356 *R/source_url.r 6faf10fe18d73cd9b260a08156583f02 *README.md 445bb9feecafd409496db71611f9a17c *inst/tests/test-download.r 9ae6c32f1be586c0e9444c3daa6e1059 *inst/tests/test-sha.r -2c54a48219328c36dcf8cf44576d9a08 *man/download.Rd -e8d6670ce5c1569ee4165d4043d056df *man/downloader.Rd -948dc04ca3c272481874b3eebbac9a62 *man/sha_url.Rd -e2633d9081627558442eed6e492461a0 *man/source_url.Rd +0634e47e5cdae1aa4395f34eb40f340e *man/download.Rd +d519e8ec62892b654d83487b15eefd41 *man/downloader.Rd +69b351b86555ff0cd47ff8139ea03df2 *man/sha_url.Rd +f9ee45459506c8d46bb0e13102777a9d *man/source_url.Rd 760b5bb5a5b44be51e89cde3827cb738 *tests/test-all.R diff -Nru r-cran-downloader-0.3/NAMESPACE r-cran-downloader-0.4/NAMESPACE --- r-cran-downloader-0.3/NAMESPACE 2013-02-21 01:36:15.000000000 +0000 +++ r-cran-downloader-0.4/NAMESPACE 2015-07-08 01:29:24.000000000 +0000 @@ -1,4 +1,7 @@ +# Generated by roxygen2 (4.1.1): do not edit by hand + export(download) export(sha_url) export(source_url) importFrom(digest,digest) +importFrom(utils,download.file) diff -Nru r-cran-downloader-0.3/NEWS r-cran-downloader-0.4/NEWS --- r-cran-downloader-0.3/NEWS 2013-05-01 03:56:57.000000000 +0000 +++ r-cran-downloader-0.4/NEWS 2015-07-08 01:29:24.000000000 +0000 @@ -1,3 +1,8 @@ +Version 0.4 +-------------------------------------------------------------------------------- + +* Use new R 3.2 download methods ("wininet" and "libcurl") when available. + Version 0.3 -------------------------------------------------------------------------------- diff -Nru r-cran-downloader-0.3/R/download.r r-cran-downloader-0.4/R/download.r --- r-cran-downloader-0.3/R/download.r 2013-02-21 01:53:49.000000000 +0000 +++ r-cran-downloader-0.4/R/download.r 2015-07-08 01:29:24.000000000 +0000 @@ -1,23 +1,24 @@ #' Download a file, using http, https, or ftp -#' -#' This is a wrapper for \code{\link{download.file}} and takes all the same -#' arguments. The only difference is that, if the protocol is https, it changes -#' some settings to make it work. How exactly the settings are changed -#' differs among platforms. -#' -#' This function also should follow http redirects on all platforms, which is -#' something that does not happen by default when \code{curl} is used, as on -#' Mac OS X. -#' -#' With Windows, it calls \code{setInternet2}, which tells R to use the -#' \code{internet2.dll}. Then it downloads the file by calling -#' \code{\link{download.file}} using the \code{"internal"} method. -#' -#' On other platforms, it will try to use \code{wget}, then \code{curl}, and -#' then \code{lynx} to download the file. Typically, Linux platforms will have -#' \code{wget} installed, and Mac OS X will have \code{curl}. -#' -#' Note that for many (perhaps most) types of files, you will want to use +#' +#' This is a wrapper for \code{\link{download.file}} and takes all the same +#' arguments. The only difference is that, if the protocol is https, it changes +#' some settings to make it work. How exactly the settings are changed differs +#' among platforms. +#' +#' This function also should follow http redirects on all platforms, which is +#' something that does not happen by default when \code{curl} is used, as on Mac +#' OS X. +#' +#' With Windows, it either uses the \code{"wininet"} method (for R 3.2) or uses +#' the \code{"internal"} method after first ensuring that \code{setInternet2}, +#' is active (which tells R to use the \code{internet2.dll}). +#' +#' On other platforms, it will try to use \code{libcurl}, \code{wget}, then +#' \code{curl}, and then \code{lynx} to download the file. R 3.2 will typically +#' have the \code{libcurl} method and for previous versions of R Linux platforms +#' will have \code{wget} installed, and Mac OS X will have \code{curl}. +#' +#' Note that for many (perhaps most) types of files, you will want to use #' \code{mode="wb"} so that the file is downloaded in binary mode. #' #' @param url The URL to download. @@ -34,30 +35,54 @@ #' "downloader.zip", mode = "wb") #' } #' +#' @importFrom utils download.file download <- function(url, ...) { # First, check protocol. If http or https, check platform: if (grepl('^https?://', url)) { - - # If Windows, call setInternet2, then use download.file with defaults. + + # Check whether we are running R 3.2 + isR32 <- getRversion() >= "3.2" + + # Windows if (.Platform$OS.type == "windows") { - - # If we directly use setInternet2, R CMD CHECK gives a Note on Mac/Linux - seti2 <- `::`(utils, 'setInternet2') - - # Store initial settings, and restore on exit - internet2_start <- seti2(NA) - on.exit(suppressWarnings(seti2(internet2_start))) - - # Needed for https. Will get warning if setInternet2(FALSE) already run - # and internet routines are used. But the warnings don't seem to matter. - suppressWarnings(seti2(TRUE)) - download.file(url, ...) - + + if (isR32) { + method <- "wininet" + } else { + + # If we directly use setInternet2, R CMD CHECK gives a Note on Mac/Linux + seti2 <- `::`(utils, 'setInternet2') + + # Check whether we are already using internet2 for internal + internet2_start <- seti2(NA) + + # If not then temporarily set it + if (!internet2_start) { + # Store initial settings, and restore on exit + on.exit(suppressWarnings(seti2(internet2_start))) + + # Needed for https. Will get warning if setInternet2(FALSE) already run + # and internet routines are used. But the warnings don't seem to matter. + suppressWarnings(seti2(TRUE)) + } + + method <- "internal" + } + + # download.file will complain about file size with something like: + # Warning message: + # In download.file(url, ...) : downloaded length 19457 != reported length 200 + # because apparently it compares the length with the status code returned (?) + # so we supress that + suppressWarnings(download.file(url, method = method, ...)) + } else { - # If non-Windows, check for curl/wget/lynx, then call download.file with + # If non-Windows, check for libcurl/curl/wget/lynx, then call download.file with # appropriate method. - - if (nzchar(Sys.which("wget")[1])) { + + if (isR32 && capabilities("libcurl")) { + method <- "libcurl" + } else if (nzchar(Sys.which("wget")[1])) { method <- "wget" } else if (nzchar(Sys.which("curl")[1])) { method <- "curl" diff -Nru r-cran-downloader-0.3/R/sha_url.r r-cran-downloader-0.4/R/sha_url.r --- r-cran-downloader-0.3/R/sha_url.r 2013-04-01 18:19:58.000000000 +0000 +++ r-cran-downloader-0.4/R/sha_url.r 2015-07-09 01:21:31.000000000 +0000 @@ -13,10 +13,15 @@ #' @examples #' \dontrun{ #' # Get the SHA hash of a file. It will print the text below and return -#' # the hash as a string -#' sha_url("https://gist.github.com/wch/dae7c106ee99fe1fdfe7/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r") +#' # the hash as a string. This is a very long URL; break it up so it can be +#' # seen more easily in the examples. +#' test_url <- paste0("https://gist.github.com/wch/dae7c106ee99fe1fdfe7", +#' "/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r") +#' sha_url(test_url) #' # Command for sourcing the URL: -#' # downloader::source_url("https://gist.github.com/wch/dae7c106ee99fe1fdfe7/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r", sha="9b8ff5213e32a871d6cb95cce0bed35c53307f61") +#' # downloader::source_url("https://gist.github.com/wch/dae7c106ee99fe1fdfe7 +#' # /raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r", +#' # sha="9b8ff5213e32a871d6cb95cce0bed35c53307f61") #' # [1] "9b8ff5213e32a871d6cb95cce0bed35c53307f61" #' } #' diff -Nru r-cran-downloader-0.3/R/source_url.r r-cran-downloader-0.4/R/source_url.r --- r-cran-downloader-0.3/R/source_url.r 2013-05-01 03:55:42.000000000 +0000 +++ r-cran-downloader-0.4/R/source_url.r 2015-07-09 01:21:31.000000000 +0000 @@ -30,14 +30,23 @@ #' @param ... Other arguments that are passed to \code{\link{source}()}. #' #' @seealso \code{\link{source}()} for more information on the arguments -#' that can be used with this function. +#' that can be used with this function. The \code{\link{sha_url}()} function +#' can be used to find the SHA-1 hash of a remote file. #' #' @export #' @examples #' \dontrun{ #' # Source the a sample file -#' downloader::source_url("https://gist.github.com/wch/dae7c106ee99fe1fdfe7/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r", -#' sha="9b8ff5213e32a871d6cb95cce0bed35c53307f61") +#' +#' # This is a very long URL; break it up so it can be seen more easily in the +#' # examples. +#' test_url <- paste0("https://gist.github.com/wch/dae7c106ee99fe1fdfe7", +#' "/raw/db0c9bfe0de85d15c60b0b9bf22403c0f5e1fb15/test.r") +#' downloader::source_url(test_url, +#' sha = "9b8ff5213e32a871d6cb95cce0bed35c53307f61") +#' +#' # Find the hash of a file +#' downloader::sha_url(test_url) #' } #' #'