miniCRAN
miniCRAN copied to clipboard
Create a 'removePackages' function to easily remove packages from the miniCRAN repo
Please provide more information about the specific nature of your request.
For example:
- What do you want to happen with dependencies and reverse dependencies of the removed package?
- What is the use case for deleting a package, compared to simply recreating the miniCRAN repo?
The workaround is simple:
- Delete the package
- Rebuild the index file
Pull requests welcome.
A use case may happen for instance when one package inside a miniCRAN repo is accepted on CRAN.
Would you consider the following function as a good candidate for a pull request - up to dependencies or reverse dependencies management? (In the end it would better be called deletePackage
rather than removePackage
to avoid any detrimental confusion with remove.packages
)
deletePackage <- function(pkgs = NULL, path = NULL, type = "source", Rversion = R.version) {
a <- pkgAvail(repos=path, type = type, Rversion = Rversion)
w <- which(a[,"Package"] %in% pkgs)
ext <- switch(type, source = ".tar.gz", mac.binary = ".tgz", win.binary = ".zip")
pkgs <- paste(a[w,"Package"], "_", a[w,"Version"], ext, sep = "")
unlink(file.path(path, repoPrefix(type = type, Rversion = R.version), pkgs))
updateRepoIndex(path, type = type, Rversion = Rversion)
invisible(pkgs)
}
@paulponcet the function you are proposing should be vectorized to handle multiple package types, the way addPackage
does (using an lapply
internally for type).
@achubaty Came across this issue looking for the same "remove package" functionality. Would you still be interested in adding that if I vectorize the code above and send a PR?
@tonytonov Vectorizing the code is a good start but Andrie's points above still hold. For me, I would want unused dependencies to also be removed. PRs welcome!
@achubaty @andrie You have probably seen it, but is there any chance you could review the PR in the near future? I'm afraid soon I'll completely forget what I've coded there.