Module sandbox

Module sandbox 

Source
Expand description

Sandbox creation and management.

This module provides the Sandbox struct for creating isolated build environments using chroot. The implementation varies by platform but presents a uniform interface.

§Platform Support

PlatformImplementation
LinuxMount namespaces + chroot
macOSbindfs/devfs + chroot
NetBSDNative mounts + chroot
illumos/SolarisPlatform mounts + chroot

§Sandbox Lifecycle

  1. Create: Set up the sandbox directory and perform configured actions
  2. Execute: Run build scripts inside the sandbox via chroot
  3. Destroy: Reverse actions and clean up the sandbox directory

§Configuration

Sandboxes are configured in the sandboxes section of the Lua config file. See the action module for available actions.

sandboxes = {
    basedir = "/data/chroot/bob",
    actions = {
        { action = "mount", fs = "proc", dir = "/proc" },
        { action = "mount", fs = "dev", dir = "/dev" },
        { action = "mount", fs = "bind", dir = "/usr/bin", opts = "ro" },
        { action = "copy", dir = "/etc" },
    },
}

§Multiple Sandboxes

Multiple sandboxes can be created for parallel builds. Each sandbox is identified by an integer ID (0, 1, 2, …) and created as a subdirectory of basedir.

With build_threads = 4, sandboxes are created at:

  • /data/chroot/bob/0
  • /data/chroot/bob/1
  • /data/chroot/bob/2
  • /data/chroot/bob/3

Structs§

Sandbox
Build sandbox manager.