Alright fine we'll use chroot

This commit is contained in:
Salt 2020-12-04 02:37:34 -06:00
parent 5bedbeec62
commit 9ea05a7b50

View File

@ -79,7 +79,6 @@ Usage: $_name [OPTION]...
-h Print this help text -h Print this help text
-c Perform the Gentoo half of installation. Must be invoked from a chroot -c Perform the Gentoo half of installation. Must be invoked from a chroot
or a systemd-nspawn container
-d Perform the second Gentoo half of installation from a chroot -d Perform the second Gentoo half of installation from a chroot
-v Print more status messages. Stacks -v Print more status messages. Stacks
@ -193,21 +192,15 @@ build-gentoo() {
"${EDITOR:-vim}" "$_optdest/etc/fstab" "${EDITOR:-vim}" "$_optdest/etc/fstab"
# Now we need to pivot into a chroot and finish configuration natively # Now we need to pivot into a chroot and finish configuration natively
# Buuuut... since we're using systemd, we get to just spawn a systemd-nspawn container
popd popd
log "Pivoting to container for more setup" log "Pivoting to container for more setup"
cp "$0" "$_optdest/gentoostrap.sh" cp "$0" "$_optdest/gentoostrap.sh"
for dir in proc sys dev; do
umount "$_optdest/$dir" || :
done
sudo systemd-nspawn --directory="$_optdest" /gentoostrap.sh -c
# The nspawn container sadly cannot manipulate the environment entirely, so we need to now do an ACTUAL chroot to install GRUB
mount --types proc /proc "$_optdest/proc" mount --types proc /proc "$_optdest/proc"
mount --rbind /sys "$_optdest/sys" mount --rbind /sys "$_optdest/sys"
mount --make-rslave "$_optdest/sys" mount --make-rslave "$_optdest/sys"
mount --rbind /dev "$_optdest/dev" mount --rbind /dev "$_optdest/dev"
mount --make-rslave "$_optdest/dev" mount --make-rslave "$_optdest/dev"
chroot "$_optdest" /gentoostrap.sh -c
chroot "$_optdest" /gentoostrap.sh -d chroot "$_optdest" /gentoostrap.sh -d
log "Configuration complete! You should be good to reboot now." log "Configuration complete! You should be good to reboot now."
} }
@ -354,7 +347,7 @@ main() {
# TODO: That # TODO: That
# Validate core program dependencies # Validate core program dependencies
log "Validating dependencies" 2 log "Validating dependencies" 2
if ! has basename chroot curl sha512sum systemd-nspawn tar; then if ! has basename chroot curl sha512sum tar; then
error "Failed to find program: $_return" 1 error "Failed to find program: $_return" 1
fi fi