RockScience
RockScience

Reputation: 18620

proper way to maintain and use ARCHIVE in CRAN like repositories

I wish to create a CRAN - like repository for my R packages. I am looking for instance at package miniCran. However I would also need to:

  1. keep and organise as Archive all the previous versions (both source and binaries), so that I can
  2. have a clean and easy way to revert back to a previous package version, stored in archive. Unarchive it basically (=move it out of archive, and update the PACKAGES index file)

Is there a proper way to do that?

Upvotes: 2

Views: 523

Answers (1)

Thomas
Thomas

Reputation: 44565

This is what the drat package is for. The "drat for Package Authors" vignette has a good overview of what you do here. You can create a local drat repository or host one somewhere remotely, like GitHub (which is what drat defaults to). (It's not a mini CRAN but rather an R-compatible repository that allows you to install packages using install.packages().)

Basically, to build a local drat repository you just do something like:

library("drat")
initRepo(name = "drat", basepath = "~/git")
insertPackage("myPkg_0.5.tar.gz", "~/git/drat")

This adds a local package tarball to the local drat repository. The default behavior is to leave all tarballs in one, top-level directory. install.packages() only sees the most recent (i.e., highest-versioned tarball for each package). There's an option, however, to create an Archive directory. The command looks basically the same:

insertPackage("myPkg_0.5.tar.gz", "~/git/drat", action = "archive")

This moves old versions to a CRAN-like Archive folder, leaving only the new release in the main directory.

This doesn't solve your problem of "reverting" the repository package to a previous version, basically because drat follows the CRAN philosophy that you never want to change the repository's history. With the Archive option, you can always install directly from the archive, however, without changing what's in the main drat folder.

Upvotes: 1

Related Questions