AUR-CHROOT(2022-03-04)

NAME
aur-chroot - build pacman packages with systemd-nspawn

SYNOPSIS
aur chroot [--build] [--update] [--create] [-D directory] [-C pacman_conf] [-M makepkg_conf] [--] [package...]

DESCRIPTION
Build pacman(8) packages inside a systemd-nspawn(1) container.

OPERATIONS

-B, --build
    Build a package inside the container with makechrootpkg. Assumes --create was run at least once.

-U, --update
    Update or create the /root copy of the container with arch-nspawn.

--create
    Create a new container with mkarchroot. By default, the base-devel package group is installed to the container.

    If the host architecture is x86_64 and [multilib] is set in the pacman configuration (see --pacman-conf), the multilib-devel package group is also installed.

    If packages or package groups are listed on the command-line, these are installed instead of the above.

OPTIONS

-D DIR, --directory=DIR
    The base directory for containers. This directory usually contains a /root subdirectory that serves as template for user containers (named after $SUDO_USER, or /copy if unset).

    Note: If the -T parameter is specified to makechrootpkg, the user container has a random name and is removed on build completion.

-C FILE, --pacman-conf=FILE
    The pacman.conf(5) file used inside the container. Defaults to /usr/share/devtools/pacman-extra.conf.

    This file is read with pacman-conf to retrieve listed file:// repositories for bind mounting. (See Accessing a local repository)

-M FILE, --makepkg-conf=FILE
    The makepkg.conf(5) file used inside the container. Defaults to devtools' makepkg-<machine>.conf.

--cargs=ARGS, --makechrootpkg-args=ARGS
    Arguments (comma-separated) to be passed to makechrootpkg for --build. Defaults to makechrootpkg -c.

--margs=ARGS, --makepkg-args=ARGS
    Additional (comma-separated) makepkg arguments for makechrootpkg. A default list of arguments can be listed with makechrootpkg --help.

--bind
    Bind a directory read-only to the container. (makechrootpkg -D)

--bind-rw
    Bind a directory read-write to the container. (makechrootpkg -d)

--path
    Print the path to the container template ($directory/root).

-x, --suffix
    The path component <suffix> in the pacman configuration /usr/share/devtools/pacman-<suffix>.conf. Defaults to extra. A full path may be specified with --pacman-conf.

ENVIRONMENT
Packages are placed in the directory set in PKGDEST. If unset, the current directory ($PWD) is used. See also makepkg.conf(5) and makechrootpkg -h.

NOTES

  Building with makechrootpkg
Changes to the pacman database are not propagated from the container to the local system. Packages must be installed and updated separately, typically through pacman -Syu package_name.

Package conflicts inside the container must be resolved manually, as makechrootpkg uses makepkg --noconfirm -s internally. For example, to replace gcc with gcc-multilib, run arch-nspawn /var/lib/aurbuild/root pacman -S gcc-multilib as root.

  Accessing a local repository
To install packages from the local repository (for example, on dependency resolution with makepkg -s, the container requires read access to the host directory where it is located. This is ensured through a (read-write) bind mount. In particular, paths to file:// repositories are passed to arch-nspawn and makechrootpkg with --bind and -d, respectively.

  Avoiding password prompts
makepkg(8) must be run as a regular user as of version 4.2, with privileged operations done via sudo(8). It follows that aur-chroot(1) and aur-build(1) can not run directly as root. To avoid password prompts, sudoers(5) can be used instead. For example, if aur-chroot(1) is run as the archie user, create the following sudoers policy:
      archie ALL = (root) NOPASSWD: SETENV: /usr/bin/makechrootpkg
      archie ALL = (root) NOPASSWD: /usr/bin/mkarchroot, /usr/bin/arch-nspawn
Should the rule only apply to specific hosts, replace ALL with the respective hostname.

  Using ccache and distcc
As in Building with makechrootpkg, install the required packages:
      # aur chroot --update ccache distcc
Ensure write access to ccache directories on the host:
      # aur chroot --build --bind /home/_ccache:/build/.ccache
Necessary makepkg(8) options may be set in a specified (-M) makepkg.conf(5) file. See GitHub issue #334 for details.

  Building for a different architecture
To build packages for a different architecture, prepend setarch arch to the aur-build command line.

The target architecture must be supported both by the host (run setarch --list for an approximation), and have a matching makepkg.conf(5) file available in /usr/share/devtools (such as /usr/share/devtools/makepkg-i686.conf for i686).

Building for other CPU architectures may be done through QEMU user mode. See https://www.qemu.org/docs/master/user/index.html for details.

  Devtools limitations
PKGDEST is not checked for existing packages when building with makechrootpkg. This happens because packages are built to the /build path inside the container, and moved afterward to PKGDEST on the host. Checking for existing packages must thus be done manually, e.g. with makepkg --packagelist.

GPG signing packages with makepkg --sign is not possible inside the container as the necessary environment variables are not set (see https://lists.archlinux.org/pipermail/arch-projects/2016-May/004341.html for details.) Signing packages should thus be done in the host environment e.g. with aur-build --sign.

Default makepkg arguments used in makechrootpkg (as listed in makechrootpkg -h) can be extended but not overriden. In particular, package conflicts can not solved interactively. (makepkg --noconfirm)

arch-nspawn will unconditionally modify the supplied pacman.conf(5) to copy mirrors (and other settings) from the host (see FS#27544 and FS#38641 for details.) Furthermore, repositories must be configured explicitly in this configuration file, and not part of a separate file configured with the Include directive.

SEE ALSO
aur(1), aur-build(1), pacconf(1), pacman(1), makepkg(8), makepkg.conf(5), pacman.conf(5), setarch(8)

AUTHORS
Alad Wenter (https://github.com/AladW)