AUR-BUILD(1)

NAME
aur-build - build packages to a local repository

SYNOPSIS
aur build [-d database] [-cfSU] [-a queue] [--no-sync] [--pkgver] [--root DIRECTORY] [--margs] [makepkg_args...]

DESCRIPTION
Build packages adding the results to a local repository. A local repository is a pacman(8) repository configured with a file:// prefix in pacman.conf(5).

aur-build runs as a regular user, unless for the following options which require root privileges: --syncdeps, --rmdeps, --chroot. Unless the --nosync or --chroot options are provided, aur-build will also attempt to sync to local the repository with pacman -Syu and pacman -Fy. See the Repository updates section for details.

OPTIONS

-a FILE, --arg-file=FILE
    A text file describing directories containing a PKGBUILD relative to the current directory. If unspecified, the current directory is assumed.

-c, --chroot
    Build packages inside a systemd-nspawn(1) container with archbuild. The prerequisites for this option are that the devtools package is installed, and the a pacman(8) configuration for the container is placed in /etc/aurutils/pacman-<database>.conf where <database> is specified with --database. If this option is not provided, aur-build falls back to /etc/aurutils/pacman-<arch>.conf where <arch> is the output from uname -m. A different location can be chosen with the --pacman-conf option.

    Care should be taken when copying (or using) /etc/pacman.conf for this configuration file, as certain directives (e.g. IgnorePkg) may cause issues in the container. It is recommended to instead copy the template in /usr/share/devtools/pacman-extra.conf or /usr/share/devtools/pacman-multilib.conf and make the necessary adjustments. Due to devtools limitations, any desired repositories should be configured explicitly in this copy.

-d NAME, --database=NAME
    The name of the pacman(8) database.

-f, --force
    Continue the build process if a package with the same name is found.

-S, --sign, --gpg-sign
    Sign built packages and the database (repo-add -s) with gpg(1). To use another key than the default, the GPGKEY environment variable can be set to the appropriate key identifier.

--dry-run
    Display package names in the following format, without building anything:

    <mode>:<pkgbase>:file://<package_path>

    where mode is either build or exist, for packages which need to be built and packages which are already in the local repository, respectively.

--no-sync
    Do not sync the local repository after building.

--pkgver
    Run makepkg -od before checking existing packages (effectively running an existing pkgver() function). The --noextract option is added to the default makepkg(8) options.

    Note: The -r, -s, and --noconfirm options are forwarded to the above command. Other makepkg(8) options are ignored.

--root=DIR
    The root directory for the repository. The root is the location for the pacman database (foo.db), built packages, and secondary files such as the files database (foo.files). This defaults to the value of the Server directive for the configured repository.

    Note: The Server directive configured in pacman.conf(5) is used for pacman(8) sync operations regardless of this setting. See also --no-sync.

--makepkg-conf=FILE
    The makepkg.conf(5) file used for makepkg(8) operations. For chroot builds, the file is also used inside the container. (makepkg --config, aur-chroot --makepkg-conf).

--pacman-conf=FILE
    The file used for syncing and retrieving local repositories. For chroot builds, the file is also used inside the container (aur-chroot --pacman-conf). makepkg(8) calls are unaffected by this option.

  makechrootpkg options

-D DIR, --directory=DIR
    The base directory for containers. Defaults to /var/lib/archbuild/<chroot-suffix>-<arch>.

    Note: This directory usually contains a /root subdirectory that serves as template for user containers (named after $SUDO_USER, or /copy if unset).

-N, --namcap
    Run namcap(1) on the built package.

-T, --temp
    Build in a temporary container. (makechrootpkg -T) Temporary means that the user container has a random name and is removed on build completion.

-U USER, --user=USER
    Run the host makepkg(8) instance as the specified user. (makechrootpkg -U)

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

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

--checkpkg
    Run checkpkg(1) on the built package.

  makepkg options
Additional options may be passed to makepkg by placing them after --margs (comma-separated).

--nocheck
    Do not run the check() function in the PKGBUILD. (makepkg --nocheck)

-n, --noconfirm, --no-confirm
    Do not wait for user input. (makepkg --noconfirm)

-r, --rmdeps
    Remove dependencies installed by makepkg. (makepkg --rmdeps)

-s, --syncdeps
    Install missing dependencies using pacman. (makepkg --syncdeps)

-A, --ignorearch
    Ignore a missing or incomplete arch field in the build script. (makepkg --ignorearch)

-L, --log
    Enable logging to a text file in the build directory. (makepkg --log)

-C, --clean
    Clean up leftover work files and directories after a successful build. (makepkg --clean)

--buildscript=NAME
    Read the package script NAME instead of the PKGBUILD default. (makepkg -p)

  repo-add options

-v, --verify
    Verify the PGP signature of the database before updating. (repo-add -v)

-R, --remove
    Remove old package files from disk when updating their entry in the database. (repo-add -R)

--new
    Only add packages that are not already in the database. (repo-add -n)

--prevent-downgrade
    Do not add packages to the database if a newer version is already present. (repo-add -p)

ENVIRONMENT

AUR_REPO
    The repository used for building packages. If unspecified, the name is selected with aur-repo(1).

AUR_DBROOT
    The root directory of the repository. If unspecified, the path is retrieved with aur-repo(1).

GNUPGHOME
    Directory where the gpg keyring for signing built packages and the database file is stored.

GPGKEY
    The GPG key used for signing packages. This environment variable is respected by aur-build and repo-add. When the variable is set in makepkg.conf(5), is it only respected by makepkg.

MAKEPKG
    The command used to build packages. Any makepkg(8) options (see the makepkg options section) forwarded must be supported by this command, as well as the -o, -d, and --noextract options if aur-build --pkgver is used. AUR_PACMAN_AUTH A command prefix for running pacman(8) as root. If unset, sudo(8) is used. See also makepkg.conf(5).

TMPDIR
    The directory for temporary files. (This includes intermediary storage of built packages, defaulting to /var/tmp.)

NOTES

  Repository updates
When building locally (outside a container), pacman -Syu is run with pacman.conf(8) only containing the local repository. This is comparable to makepkg -i, but without subsequent package installation (if a package was installed before, it is updated to the latest available version). An interesting side-effect is that pacman considers packages inside the official repositories "local", and warns if they are newer than any custom counterpart. Packages which define a replaces field are ignored if the target package is installed on the local system.

  Using a dedicated build user
While using a dedicated user for the build process does not increase security (beyond protecting against packaging errors that write to $HOME), it may be useful when the local repository will be accessible to multiple users or as a way to avoid password prompts. (Note that such a user must be unprivileged; as of pacman 4.2, makepkg(8) may not run directly as root.)

New users may be created with useradd(8) as follows:

        # useradd build --system --home-dir /var/cache/build --create-home

Because dependency resolution is not replicated and left to makepkg(8) (see handle_deps() in /usr/bin/makepkg) the build user should be allowed to run pacman(8) with elevated privileges. For example, create the /etc/sudoers.d/10_build file with following contents:

        build ALL = (root) NOPASSWD: /usr/bin/pacman

aur-build(1) (and related programs such as aur-sync(1)) may now be run as the new build user. For example:

        # cd /var/cache/build
        # sudo -u build git clone https://aur.archlinux.org/mypackage.git
        # cd mypackage
        # sudo -u build aur build -d custom

Any created files in the local repository (such as packages, signatures and database files) will be owned by the build user.

  PKGBUILD signatures
GPG signatures defined in the validpgpkeys array may be automatically retrieved by setting the auto-key-retrieve option in gpg.conf. Note that this option only works with signatures that include an issuer fingerprint. See --auto-key-retrieve in gpg(1) for details.

  Signing packages unattended
By default, `gpg(1)` will cache passphrases for a duration set by the `default-cache-ttl` option. If extending this duration is not desired, the passphrase can be cached manually with `gpg-set-passphrase` before running `aur-build(1)`. The duration of the cached passphrase is then set by the `max-cache-ttl` option, which defaults to 2 hours. See `gpg-set-passphrase` for details.

  Rebuilding packages against updated dependencies
It is sometimes required to rebuild packages when their dependencies are updated, for example in the case of dynamic library linking. To detect which packages require a rebuild, the rebuild-detector (https://github.com/maximbaz/rebuild-detector) package can be used. To propagate rebuilt packages to clients, pkgver should be increased priorly, e.g. with setconf(1).

  Installing dependencies with makepkg
If --syncdeps is specified, package dependencies are installed with makepkg -s. makepkg uses the pacman -S --asdeps command for this purpose. If other pacman options are desired for this command, a wrapper script and the PACMAN environment variable have to be used. (See ENVIRONMENT VARIABLES in makepkg(8).)

For example, to use a custom pacman.conf(5) file, create a wrapper script:

      #!/bin/sh --
      pacman --config </path/to/file> "$@"

and set the PACMAN environment variable to its path. (In this particular example, building inside a container with dedicated pacman.conf(5) is an alternative.)

BUGS
Databases are built with LANG=C to avoid libalpm from skipping entries if the locale is not set (FS#49342). Packages are signed manually with gpg --batch --detach-sign --no-armor (FS#49946).

pacman(8) has a size-limit of 25 MiB for databases. The use of larger databases may result in an expected download size exceeded error. To avoid this issue, compress the database with gzip(1). See https://git.archlinux.org/pacman.git/commit/?id=6dc71926f9b16ebcf11b924941092d6eab204224 for details.

SEE ALSO
aur(1), aur-chroot(1), aur-repo(1), makepkg.conf(5), pacman.conf(5), sudoers(5), makepkg(8), pacman(8), repo-add(8), sudo(8)

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