addOldPackage: Add old package versions to a miniCRAN repository.

Description Usage Arguments Value Note See Also Examples

View source: R/addPackages.R

Description

Will download and add older source package versions. Older binary versions are not normally available on CRAN and should be built from source on the platform for which they are required. As such, specifying type!="source" will likely fail as the download will not be successful.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
addOldPackage(
  pkgs = NULL,
  path = NULL,
  vers = NULL,
  repos = getOption("repos"),
  type = "source",
  Rversion = R.version,
  writePACKAGES = TRUE,
  deps = FALSE,
  quiet = TRUE
)

Arguments

pkgs

Character vector of packages to download

path

Destination download path. This path is the root folder of your new repository.

vers

The package version to install.

repos

URL(s) of the 'contrib' sections of the repositories, e.g. "http://cran.us.r-project.org". Passed to available.packages()

type

Possible values are (currently) "source", "mac.binary" and "win.binary": the binary types can be listed and downloaded but not installed on other platforms. Passed to download.packages().

Rversion

Version of R (only used if type is not source.) Defaults to R.version, but this can be specified as any of the following formats:

  • a character string with the two digit R version, e.g. "3.1"

  • a list with components major and minor

  • the result of getRversion()

  • the result of R.version

writePACKAGES

If TRUE, calls write_PACKAGES() to update the repository PACKAGES file.

deps

logical indicating whether the package dependencies should be added (default TRUE).

quiet

If TRUE, suppress status messages (if any), and the progress bar during download.

Value

Adds the packages, rebuilds the package index, and invisibly returns the number of packages written to the index files.

Note

Dependencies for old package versions cannot be determined automatically and must be specified by the user in pkgs and vers. Thus, deps=FALSE is the default for this function.

See Also

Other update repo functions: addPackage(), checkVersions(), makeRepo(), updatePackages()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo

# Specify list of packages to download
revolution <- c(CRAN = getOption("minicran.mran"))
revolution
pkgs <- c("foreach")
pkgTypes <- c("source", "win.binary")

pdb <- cranJuly2014

## Not run: 
  pdb <- pkgAvail(repos = revolution, type = "source")

## End(Not run)

pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = revolution, type = "source", suggests = FALSE)
pkgList

## Not run: 
  # Create temporary folder for miniCRAN
  dir.create(pth <- file.path(tempdir(), "miniCRAN"))

  # Make repo for source and win.binary
  makeRepo(pkgList, path = pth, repos = revolution, type = pkgTypes)

  # Add other versions of a package (and assume these were added previously)
  oldVers <- data.frame(package = c("foreach", "codetools", "iterators"),
                        version = c("1.4.0", "0.2-7", "1.0.5"),
                        stringsAsFactors = FALSE)
  pkgs <- oldVers$package
  addOldPackage(pkgs, path = pth, vers = oldVers$version, repos = revolution, type = "source")
  # NOTE: older binary versions would need to be build from source

  # List package versions in the miniCRAN repo (produces warning about duplicates)
  pkgVersionsSrc <- checkVersions(pkgs, path = pth, type = "source")
  pkgVersionsBin <- checkVersions(pkgs, path = pth, type = "win.binary")

  # After inspecting package versions, remove old versions
  basename(pkgVersionsSrc) # "foreach_1.4.0.tar.gz"  "foreach_1.4.2.tar.gz"
  basename(pkgVersionsBin) # "foreach_1.4.0.zip"     "foreach_1.4.2.zip"
  file.remove(c(pkgVersionsSrc[1], pkgVersionsBin[1]))

  # Rebuild package index after adding/removing files
  updateRepoIndex(pth, type = pkgTypes, Rversion = R.version)

  pkgAvail(pth, type = "source")

  # Add new packages (from CRAN) to the miniCRAN repo
  addPackage("Matrix", path = pth, repos = revolution, type = pkgTypes)

  # Delete temporary folder
  unlink(pth, recursive = TRUE)

## End(Not run)

miniCRAN documentation built on Sept. 16, 2020, 1:07 a.m.