LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

makechrootpkg

builds Arch Linux packages in a clean chroot environment

TLDR

Build the PKGBUILD in the current directory using a clean chroot
$ makechrootpkg -c -r [/var/lib/archbuild/extra-x86_64]
copy
Build without cleaning the chroot first
$ makechrootpkg -r [/var/lib/archbuild/extra-x86_64]
copy
Update the chroot before building
$ makechrootpkg -u -r [/var/lib/archbuild/extra-x86_64]
copy
Install a local package into the chroot before building
$ makechrootpkg -r [chroot] -I [package.pkg.tar.zst]
copy
Run namcap and checkpkg on the built package
$ makechrootpkg -c -n -C -r [chroot]
copy
Bind-mount a directory read-write into the chroot
$ makechrootpkg -d [/host/path] -r [chroot]
copy
Pass extra arguments to makepkg
$ makechrootpkg -c -r [chroot] -- --skippgpcheck
copy

SYNOPSIS

makechrootpkg [options] -r chroot [--] [makepkg-args]

DESCRIPTION

makechrootpkg builds a PKGBUILD inside a clean, isolated chroot environment. This ensures reproducible builds by insulating the build from the host system's installed packages and configuration, making it the standard method for building official Arch Linux packages.The chroot is managed as a root template plus per-user working copies that are cloned from it. Options such as -c and -u refresh the working copy, while -I and -d let you customize the build environment.

PARAMETERS

-r dir

Chroot directory to build in (required).
-c
Clean the chroot copy before building.
-u
Update the working copy (chroot) before building.
-I pkg
Install the given package file into the working copy before building.
-d dir[:dest]
Bind-mount a host directory into the chroot as read-write.
-D dir[:dest]
Bind-mount a host directory into the chroot as read-only.
-t dir[:opts]
Mount a tmpfs at the specified directory inside the chroot.
-l name
Name of the working copy directory (defaults to `$USER`).
-n
Run namcap quality checks on the built package.
-C
Run checkpkg validation against the previous package version.
-T
Build inside a temporary copy (discarded after the build).
-U user
Run makepkg as the specified user.
-x when
Launch an interactive shell inside the chroot: `never`, `always`, or `failure`.
-h
Display usage information.

SETUP

$ # Create the chroot template (once)
mkarchroot /var/lib/archbuild/extra-x86_64/root base-devel

# Build the package in the current directory
cd package-dir
makechrootpkg -c -r /var/lib/archbuild/extra-x86_64
copy

CAVEATS

Requires the devtools package. The chroot must be initialized with mkarchroot before first use. Root privileges are needed; slower than running makepkg directly but produces cleaner, more reproducible builds. Anything after -- is forwarded to makepkg.

HISTORY

makechrootpkg is part of Arch Linux devtools, maintained by Arch Linux developers and Trusted Users for building official packages in reproducible chroot environments.

SEE ALSO

Copied to clipboard
Kai