Pacstrap

From ArchWiki

This article or section is a candidate for merging with DeveloperWiki:Building_in_a_clean_chroot#Classic_way.

Notes: Same scope (Discuss in Talk:Pacstrap)

From the pacstrap(8):

Pacstrap is designed to create a new system installation from scratch.

Installation

Install arch-install-scripts

Note: Pacstrap is mainly used during the installation of the system, and comes preinstalled within the arch installation media.

Tips and tricks

Creating a clean chroot

Currently, devtools only supports sudo. This can not be changed as devtools require the use of the complex functionality of sudo, which opendoas does not support. You can use Pacstrap to create a chroot manually.

First, create the chroot directory:

# mkdir /var/chroot

Then, install the base system and base-devel (meta package containing tools which are used by the makepkg utility):

# pacstrap -K /var/chroot base base-devel
Note: The -K flag initialises a new pacman keyring, instead of using the hosts keyring, for people who are using unofficial mirrors within their chroot and want to import their keys from the host can omit this flag.

If you have not mounted a partition to /var/chroot, you must bind the directory on itself to make it a mountpoint, therefore ensuring compatibility with arch-chroot.

# mount --bind /var/chroot /var/chroot

Then you can enter the chroot, using arch-chroot:

# arch-chroot /var/chroot

You can not build arch pages as root, makepkg does not permit the use of the root, due to security concerns. Create a build user:

# useradd -m build
Note: The -m flag is needed to ensure that useradd creates the home directory of the build user with the correct permissions.

You can then become the build user using the following command:

# su -l build
Note: The -l flag is used to change into the home directory of the user you are becoming, this prevents you from accidentally trying to read/write to the root home directory.

You can now build any AUR package you wish by cloning them into the chroot, or use the chroot for testing and debugging of arch packages.