Skip to content
Git

Building and Publishing Binaries

Build scenarios depend on your environment and requirements:

  1. Building all (historic) versions of a package
  2. Building a single/latest version of a package

Both scenarios can be executed locally or remotely on a server.

The key function for building is bincraft::build_binary_package(). It has many arguments, making it flexible but also potentially overwhelming.

  1. 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 and arm64 across multiple R versions:

  2. 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.

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 by install.packages())
  • PACKAGES.rds (unclear)
  • PACKAGES.gz (used by pak())
  • PACKAGES.sqlite (used by pak())
  • Meta/archive.rds (used by remotes::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.