Build scenarios
Section titled “Build scenarios”Build scenarios depend on your environment and requirements:
- Building all (historic) versions of a package
- Building a single/latest version of a package
Both scenarios can be executed locally or remotely on a server.
Building binaries
Section titled “Building binaries”The key function for building is bincraft::build_binary_package()
. It has many arguments, making it flexible but also potentially overwhelming.
To build a functional binary, provide the build environment for your target architecture/distribution. The easiest approach is to use containers. This project curates multiple container images for building binaries. These images contain all necessary tools and libraries for each target architecture/distribution.
The following images are available for both
amd64
andarm64
across multiple R versions:To understand the build process in detail, run the following command. This builds a binary for the R-only package
brew
from the CRAN repository. It does so in an Ubuntu 24.04 container without post-processing actions such as uploading or archival.Terminal window docker run --rm devxygmbh/rpkgs-build-env-ubuntu:noble-4.4.3 \R -q -e "bincraft::build_binary_package('brew', archive = FALSE, upload = FALSE, tag = '1.0-10')"
To build from a Git source other than CRAN, set the url
argument in build_binary_package()
. For other arguments, see the function reference.
Creating the package index
Section titled “Creating the package index”After binaries exist in S3, the repository index files must be created. These are used by install.packages()
and related functions to determine which packages are available. Unfortunately, no canonical standard exists across all package installation functions. Therefore, multiple index files must be created:
PACKAGES
(used byinstall.packages()
)PACKAGES.rds
(unclear)PACKAGES.gz
(used bypak()
)PACKAGES.sqlite
(used bypak()
)Meta/archive.rds
(used byremotes::install_version()
)
Fortunately, {bincraft} and its dependencies (specifically {cranlike}) handle this automatically.
Running
upload_package_index(<args>)
creates/updates the files based on S3 bucket contents and uploads them to the appropriate locations.