Chroot build environment

From Armagetron
Revision as of 22:10, 22 August 2021 by Cadillac (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Working on this as I build a new virtual machine for semi-automated Linux and Windows builds.


Our "weekly" builds are done in a virtual machine with a chroot prison for 32 and 64 bit builds and wine for the Windows build. Here I document step by step how to set one up. I write this as I go, so it is incomplete.

Make snapshots after every section or so.

Base system

Install Ubuntu Trusty in a virtual machine. Straightforward :) Pick LVM in the setup options so you can resize partitions later.

Install bzr and (optinal, I use it for remote access) ssh and stuff:

sudo apt-get update
sudo apt-get install bzr ssh schroot

Add common volume to host builds

Edit: These steps are provided as is because I set my system up that way. They're not required. /mnt/builds on the root system side can be any old directory.

Use LVM to add a new volume. My VM has 150 G total space:

lvcreate -L 100G -n builds ubuntu-vg
mkfs.ext4 /dev/ubuntu-vg/builds

If there is not enough space, reduce existing volumes. This needs to be done from a Live CD:

resize2fs /dev/ubuntu-vg/root 50G
lvresize /dev/ubuntu-vg/root 50G

Add the new volume to fstab:

/dev/mapper/ubuntu--vg-builds /mnt/builds  ext4    errors=remount-ro 0       1

This new volume will be mounted into the chroots for easy access.

Set up chroot environments

Follow this documentation: [1] You can stop before "Setting up a dchroot (non-root) environment"

Our /etc/schroot/schroot.conf:

description=Ubuntu 64 Bit
description=Ubuntu 32 Bit

Creating the actual installations:

debootstrap --variant=buildd --arch i386 trusty /var/chroot/32
debootstrap --variant=buildd --arch amd64 trusty /var/chroot/64

To change into the new environments, you can do "schroot -c 32" or "schroot -c 64".

Create mount points for the shared files in the chroots:

mkdir /var/chroot/32/mnt/builds
mkdir /var/chroot/64/mnt/builds

Add bind mounts for them into /etc/fstab:

/mnt/builds /var/chroot/32/mnt/builds none bind
/mnt/builds /var/chroot/64/mnt/builds none bind

Mount them with "mount -a". Inside the chroots, you should now see /mnt/build.