Module config

Module config 

Source
Expand description

Configuration file parsing (Lua format).

Bob uses Lua configuration files for maximum flexibility. The configuration defines paths to pkgsrc, packages to build, sandbox setup, and build scripts.

§Configuration File Structure

A configuration file has four main sections:

  • options - General build options (optional)
  • pkgsrc - pkgsrc paths and package list (required)
  • scripts - Build script paths (required)
  • sandboxes - Sandbox configuration (optional)

§Options Section

The options section is optional. All fields have defaults.

FieldTypeDefaultDescription
build_threadsinteger1Number of parallel build sandboxes. Each sandbox builds one package at a time.
scan_threadsinteger1Number of parallel scan processes for dependency discovery.
strict_scanbooleanfalseIf true, abort on scan errors. If false, continue and report failures separately.
log_levelstring“info”Log level: “trace”, “debug”, “info”, “warn”, or “error”. Can be overridden by RUST_LOG env var.

§Pkgsrc Section

The pkgsrc section is required and defines paths to pkgsrc components.

§Required Fields

FieldTypeDescription
basedirstringAbsolute path to the pkgsrc source tree (e.g., /data/pkgsrc).
logdirstringDirectory for all logs. Per-package build logs go in subdirectories. Failed builds leave logs here; successful builds clean up.
makestringAbsolute path to the bmake binary (e.g., /usr/pkg/bin/bmake).

§Optional Fields

FieldTypeDefaultDescription
bootstrapstringnonePath to a bootstrap tarball. Required on non-NetBSD systems. Unpacked into each sandbox before builds.
build_userstringnoneUnprivileged user to run builds as. If set, builds run as this user instead of root.
cachevarstable{}List of pkgsrc variable names to fetch once and cache. These are set in the environment for scans and builds (e.g., {"NATIVE_OPSYS", "NATIVE_OS_VERSION"}).
envfunction or table{}Environment variables for builds. Can be a table of key-value pairs, or a function receiving package metadata and returning a table. See Environment Function.
pkgpathstable{}List of package paths to build (e.g., {"mail/mutt", "www/curl"}). Dependencies are discovered automatically.
save_wrkdir_patternstable{}Glob patterns for files to preserve from WRKDIR on build failure (e.g., {"**/config.log"}).
tarstringtarPath to a tar binary capable of extracting the bootstrap kit. Defaults to tar in PATH.

§Environment Function

The env field can be a function that returns environment variables for each package build. The function receives a pkg table with the following fields:

FieldTypeDescription
pkgnamestringPackage name with version (e.g., mutt-2.2.12).
pkgpathstringPackage path in pkgsrc (e.g., mail/mutt).
all_dependsstringSpace-separated list of all transitive dependency paths.
dependsstringSpace-separated list of direct dependency package names.
scan_dependsstringSpace-separated list of scan-time dependency paths.
categoriesstringPackage categories from CATEGORIES.
maintainerstringPackage maintainer email from MAINTAINER.
bootstrap_pkgstringValue of BOOTSTRAP_PKG if set.
usergroup_phasestringValue of USERGROUP_PHASE if set.
use_destdirstringValue of USE_DESTDIR.
multi_versionstringValue of MULTI_VERSION if set.
pbulk_weightstringValue of PBULK_WEIGHT if set.
pkg_skip_reasonstringValue of PKG_SKIP_REASON if set.
pkg_fail_reasonstringValue of PKG_FAIL_REASON if set.
no_bin_on_ftpstringValue of NO_BIN_ON_FTP if set.
restrictedstringValue of RESTRICTED if set.

§Scripts Section

The scripts section defines paths to build scripts. Relative paths are resolved from the configuration file’s directory.

ScriptRequiredDescription
pre-buildnoExecuted before each package build. Used for per-build sandbox setup (e.g., unpacking bootstrap kit). Receives environment variables listed in Script Environment.
post-buildnoExecuted after each package build completes (success or failure).

§Script Environment

Build scripts receive these environment variables:

VariableDescription
bob_logdirPath to the log directory.
bob_makePath to the bmake binary.
bob_packagesPath to the packages directory.
bob_pkg_dbdirPKG_DBDIR from pkgsrc.
bob_pkg_refcount_dbdirPKG_REFCOUNT_DBDIR from pkgsrc.
bob_pkgtoolsPath to the pkg tools directory.
bob_pkgsrcPath to the pkgsrc source tree.
bob_prefixInstallation prefix.
bob_tarPath to the tar binary.
bob_build_userUnprivileged build user, if configured.
bob_bootstrapPath to the bootstrap tarball, if configured.

§Sandboxes Section

The sandboxes section is optional. When present, builds run in isolated chroot environments.

FieldTypeRequiredDescription
basedirstringyesBase directory for sandbox roots. Sandboxes are created as numbered subdirectories (basedir/0, basedir/1, etc.).
actionstableyesList of actions to perform during sandbox setup. See the action module for details.

Structs§

Config
Main configuration structure.
ConfigFile
Parsed configuration file contents.
LuaEnv
Holds the Lua state for evaluating env functions.
Options
General build options from the options section.
Pkgsrc
pkgsrc-related configuration from the pkgsrc section.
PkgsrcEnv
Environment variables retrieved from pkgsrc.
Sandboxes
Sandbox configuration from the sandboxes section.