[Rd] Suggestion: Make CRAN source URLs immutable

Iñaki Ucar iuc@r @ending from fedor@project@org
Sat Nov 3 12:37:37 CET 2018


On Sat, 3 Nov 2018 at 11:54, Joris Meys <jorismeys using gmail.com> wrote:
>
> FWIW, you can get the URL and extract the link with extension from there. Archived packages are always tarballs, so that makes the following possible:
>
> url <- "https://cran.r-project.org/package=httr&version=1.3.0"
>
> library(RCurl)
>
> pkgurl <- gsub(".*(https://cran.+\\.tar.gz).*",
>                "\\1",
>                getURL(url))
>
> install.packages(pkgurl, type = "source", repos = NULL)

The proper way to do this would be to fetch just the headers and
extract the location field:

$ URL="https://cran.r-project.org/package=httr&version=1.3.0"
$ curl -sI $URL | awk '/^Location:/{print $2}'
https://cran.r-project.org/src/contrib/Archive/httr/httr_1.3.0.tar.gz

But that's not the point. I'm talking about RPM packaging, and the
point is, as I said, that the tool that expands and downloads sources
from specfiles simply doesn't do that, because it can't trust an
extension sent from a remote server. We need to provide it explicitly
in the URL.

--
Iñaki Úcar



More information about the R-devel mailing list