#!/bin/bash
set -e
BSN=bootstrapper
BS=/$BSN
mkdir -p $BS/var/lib/pacman
pacman -Sy -b $BS/var/lib/pacman -r $BS
pacman -S --noconfirm --noscriptlet -b $BS/var/lib/pacman -r $BS bootstrap
mkdir -p /sources/pkg/armv7h/bootstrap
cp bootstrapper-initial.sh $BS/initial.sh
cd $BS
cp /etc/makepkg.conf etc/
mount -t proc proc proc
mount -t sysfs sys sys
mount --bind /dev dev
chmod +x ./initial.sh
chroot . ./initial.sh
systemd-machine-id-setup --root=$BS
umount proc sys dev
rm ./initial.sh
cd -
echo "Done."