A few times I had the need to build Arch Linux AUR packages which took a long time on my notebook. I had access to some faster hosts but they were all running Ubuntu (16.04 and later). To keep this in mind I write down how to create a Arch Linux build chroot inside an Ubuntu host.

Bootstrapping Arch Linux

First we need to get the the Arch Linux base filesystem and extract it to a directory.

cd /var/lib/machines/
wget http://mirrors.dotsrc.org/archlinux/iso/2020.12.01/archlinux-bootstrap-2020.12.01-x86_64.tar.gz
btrfs subvolume create archlinux-builder
tar -zxvf archlinux-bootstrap-2020.12.01-x86_64.tar.gz 
mv root.x86_64/* archlinux-builder
rmdir root.x86_64

Afterwards we can configure the DNS settings and chroot to it

cd archlinux-builder
cp /etc/resolv.conf etc
bin/arch-chroot .

Finally we can configure pacman inside the chroot and install/build software under a seperate user

# select a mirror
vim /etc/pacman.d/mirrorlist
vim /etc/pacman.conf
pacman-key --init
pacman-key --refresh-keys
pacman -Syu
pacman -S --needed base-devel git
pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
useradd builder
echo "builder  ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/builder
chown builder: -R yay
cd yay
su builder
makepkg -si

Now we can build Arch Linux AUR packages inside that chroot with makepkg or yay.
I usually save the freshly configured state of such a chroot with

# either with BTRFS
btrfs subvolume snapshot archlinux-builder archlinux-builder-fresh
# or with systemds machinectl
machinectl export-tar archlinux-builder archlinux-builder-fresh.tar

Install Arch Linux from existing Linux (Arch Linux wiki)