Title: Tools for 'CRAN'-Like Repositories
Version: 1.0.3
Author: Gábor Csárdi
Maintainer: Gábor Csárdi <csardi.gabor@gmail.com>
Description: A set of functions to manage 'CRAN'-like repositories efficiently.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
URL: https://github.com/r-hub/cranlike
BugReports: https://github.com/r-hub/cranlike/issues
RoxygenNote: 7.3.1
Imports: DBI, debugme, desc (≥ 1.1.0), RSQLite, tools, utils
Suggests: covr, mockery, testthat, withr, zip
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2024-04-24 20:51:36 UTC; gaborcsardi
Repository: CRAN
Date/Publication: 2024-04-24 21:00:02 UTC

Tools for CRAN-like Repositories

Description

A set of functions to manage CRAN-like repositories efficiently.

See Also

Useful links:


Add R packages to the package database

Description

The files must exist in the directory. If the package database does not exist, then it will be created.

Usage

add_PACKAGES(files, dir = ".", fields = NULL, xcolumns = NULL)

Arguments

files

Files to add, only the file names, without the path. You can use base::basename() to chop off the path.

dir

Package directory.

fields

Fields to use in the database if the database is created.

xcolumns

Extra scalar columns to add to the database. Should be a named list of character scalars or NULL for no extra columns.

See Also

Other PACKAGES manipulation: remove_PACKAGES(), update_PACKAGES()


Create an empty package database

Description

Create an empty package database if it does not exist. It also updates the PACKAGES* files from the new (empty) database.

Usage

create_empty_PACKAGES(dir = ".", fields = NULL, xcolumns = NULL)

Arguments

dir

Character vector describing the location of the repository (directory including source or binary packages) to generate the ‘PACKAGES’, ‘PACKAGES.gz’ and ‘PACKAGES.rds’ files from and write them to.

fields

a character vector giving the fields to be used in the ‘PACKAGES’, ‘PACKAGES.gz’ and ‘PACKAGES.rds’ files in addition to the default ones, or NULL (default).

The default corresponds to the fields needed by available.packages: "Package", "Version", "Priority", "Depends", "Imports", "LinkingTo", "Suggests", "Enhances", "OS_type", "License" and "Archs", and those fields will always be included, plus the file name in field "File" if addFile = TRUE and the path to the subdirectory in field "Path" if subdirectories are used.

xcolumns

Extra scalar columns to add to the database. Should be a named list of character scalars or NULL for no extra columns.


List all packages and versions in a CRAN-like repository

Description

List all packages and versions in a CRAN-like repository

Usage

package_versions(dir = ".", xcolumns = character())

Arguments

dir

Path to the repository.

xcolumns

Extra columns to include in the result.

Value

Data frame with at least three columns: Package, Version, MD5sum.


Remove package from a package database

Description

The files will be first removed from the database, and then from the directory.

Usage

remove_PACKAGES(files, dir = ".")

Arguments

files

Files to remove. They must still exist at the time this function is called.

dir

Package directory.

See Also

Other PACKAGES manipulation: add_PACKAGES(), update_PACKAGES()


Create or update PACKAGES* files for a CRAN-like repository

Description

This function is similar to tools::write_PACKAGES(), with some differences:

Usage

update_PACKAGES(
  dir = ".",
  fields = NULL,
  type = c("source", "mac.binary", "win.binary"),
  xcolumns = NULL
)

Arguments

dir

Character vector describing the location of the repository (directory including source or binary packages) to generate the ‘PACKAGES’, ‘PACKAGES.gz’ and ‘PACKAGES.rds’ files from and write them to.

fields

a character vector giving the fields to be used in the ‘PACKAGES’, ‘PACKAGES.gz’ and ‘PACKAGES.rds’ files in addition to the default ones, or NULL (default).

The default corresponds to the fields needed by available.packages: "Package", "Version", "Priority", "Depends", "Imports", "LinkingTo", "Suggests", "Enhances", "OS_type", "License" and "Archs", and those fields will always be included, plus the file name in field "File" if addFile = TRUE and the path to the subdirectory in field "Path" if subdirectories are used.

type

Type of packages: currently source ‘.tar.{gz,bz2,xz}’ archives, and macOS or Windows binary (‘.tgz’ or ‘.zip’, respectively) packages are supported. Defaults to "win.binary" on Windows and to "source" otherwise.

xcolumns

Extra scalar columns to add to the database. Should be a named list of character scalars or NULL for no extra columns.

Details

update_PACKAGES uses a SQLite database to aid updating PACKAGES* files quickly. It this database does not exist, then it will be created based on the existing PACKAGES* files. If no PACKAGES* files exist, either, then these will be created via tools::write_PACKAGES().

See Also

Other PACKAGES manipulation: add_PACKAGES(), remove_PACKAGES()


Perform a DB query, without explicit locking

Description

This is for read operations. They can also be called from within a transaction. In this case the database handle will be reused.

Usage

with_db(db_file, expr)

Arguments

db_file

File of the DB.

expr

Expression to evaluate, it can refer to the connection handle as db.


Perform a DB query, with locking

Description

This creates a transaction, and an exclusive lock. It always creates a new DB connection, and closes it on exit.

Usage

with_db_lock(db_file, expr)

Arguments

db_file

File of the DB.

expr

Expression to evaluate, it can refer to the connection handle as db.