bob 0.9.0

A pkgsrc package builder
Documentation
-- Example configuration file for Linux.

-- Common variables
local initdir = "@INITDIR@"

-- General configuration variables.
options = {
    build_threads = 4,
    scan_threads = 4,
    -- Log level: error, warn, info, debug, trace.  Override with RUST_LOG env.
    log_level = "info",
}

--
-- Dynamic resource allocation settings.  Uses statistics from the history
-- database, knowledge of upcoming builds, and package weight to make informed
-- choices for what MAKE_JOBS and WRKOBJDIR should be set to for each package
-- build.
--
-- On first builds with no history, conservative values are used.
--
--[[
dynamic = {
    jobs = 16,
    wrkobjdir = {
        tmpfs = "/tmp/work",
        disk = "/home/builder/work",
        threshold = "1G",
    },
}
]]

-- Environment variables for sandbox processes.  It is recommended to be as
-- strict as possible, as pollution from the user environment can negatively
-- impact builds.
environment = {
    clear = true,
    inherit = { "TERM", "HOME" },
    set = {
        PATH = "/sbin:/bin:/usr/sbin:/usr/bin",
    },
}

-- Variables that configure pkgsrc, where it is, what packages to build, etc.
pkgsrc = {
    basedir = "/usr/pkgsrc",
    bootstrap = initdir .. "/bootstrap.tar.gz",
    make = "/usr/pkg/bin/bmake",
    -- or pkgpaths = read_pkgpaths("/path/to/file"),
    pkgpaths = {
        "mail/mutt",
        "sysutils/coreutils",
    },
    tar = "/bin/tar",

    -- It is strongly recommended to set up an unprivileged user to perform
    -- builds.  If this is enabled, there is an action below to automatically
    -- create the user home directory.  If build_user_home is not set it is
    -- fetched from getpwnam(3).
    -- build_user = "builder",
    -- build_user_home = "/home/builder",

    -- List of pkgsrc variables to fetch once and cache.  These are then set in
    -- the environment for scans and builds, avoiding expensive forks.  Only add
    -- variables that are calculated prior to mk.conf being included.
    cachevars = {
        "NATIVE_OPSYS",
        "NATIVE_OPSYS_VERSION",
        "NATIVE_OS_VERSION",
    },

    -- On build failure, save files matching these glob patterns from WRKDIR.
    -- save_wrkdir_patterns = {
    --     "**/CMakeError.log",
    --     "**/CMakeOutput.log",
    --     "**/config.log",
    --     "**/meson-log.txt",
    -- },
}

-- These scripts are executed during sandbox creation and destruction, as well
-- as before and after every single package build.
scripts = {
    ["pre-build"] = initdir .. "/scripts/pre-build",
    ["post-build"] = initdir .. "/scripts/post-build",
}

-- The sandboxes section defines where sandboxes should be created, and how file
-- systems and ancilliary data should be created.
--
-- The number of sandboxes that will be created is build_threads if set,
-- otherwise 1.
--
-- During creation the actions list is processed in order, and when destroying
-- sandboxes it is processed in reverse order.
sandboxes = {
    basedir = "/data/chroot",

    actions = {
        { action = "mount", fs = "dev", dir = "/dev" },
        { action = "mount", fs = "proc", dir = "/proc" },

        { action = "mount", fs = "tmp", dir = "/tmp", opts = "size=1G" },
        { action = "mount", fs = "tmp", dir = "/var", opts = "size=1G" },

        { action = "mount", fs = "bind", dir = "/usr/bin", opts = "ro" },
        { action = "mount", fs = "bind", dir = "/usr/sbin", opts = "ro" },
        { action = "mount", fs = "bind", dir = "/usr/lib", opts = "ro" },
        { action = "mount", fs = "bind", dir = "/usr/lib64", opts = "ro" },
        { action = "mount", fs = "bind", dir = "/usr/libexec", opts = "ro" },
        { action = "mount", fs = "bind", dir = "/usr/include", opts = "ro" },
        { action = "mount", fs = "bind", dir = "/usr/share", opts = "ro" },

        { action = "symlink", src = "usr/bin", dest = "/bin" },
        { action = "symlink", src = "usr/lib", dest = "/lib" },
        { action = "symlink", src = "usr/lib64", dest = "/lib64" },
        { action = "symlink", src = "usr/sbin", dest = "/sbin" },

        { action = "copy", dir = "/etc" },

        -- At this point everything should be set up so that chrooted commands
        -- will execute successfully.  Perform additional chroot setup.
        { action = "cmd", chroot = true, create = "mkdir -m 1777 /var/tmp; chmod 1777 /tmp" },

        -- Configure build user home directory if enabled.  Bob automatically
        -- sets bob_build_user* variables when the build user is configured,
        -- and the scripts are executed with 'set -eu', so these should be safe.
        { action = "cmd", ifset = "pkgsrc.build_user",
          create = [[
                mkdir -p ${bob_sandbox_path}${bob_build_user_home}
                chown ${bob_build_user} ${bob_sandbox_path}${bob_build_user_home}
          ]],
          destroy = "rm -rf ${bob_sandbox_path}${bob_build_user_home}" },

        -- It is recommended to mount pkgsrc read-only, but you will first need
        -- to configure DISTDIR, PACKAGES, and WRKOBJDIR to other directories.
        { action = "mount", fs = "bind", dir = pkgsrc.basedir },

        -- Directory where this config and support scripts live.
        { action = "mount", fs = "bind", dir = initdir },
    },
}