Re: automatic creation of a chroot environment

From: Rozhuk Ivan <rozhuk.im_at_gmail.com>
Date: Thu, 16 Jul 2026 20:48:06 UTC
On Thu, 16 Jul 2026 11:57:23 -0700
Mark Millard <marklmi@yahoo.com> wrote:


> If one tries to build, for example, lang/rust using a tmpfs file
> system, there needs to be enough RAM+SWAP to allow something like 30
> GiBytes for the tmpfs to use just for lang/rust materials in that
> RAM+SWAP --plus space for other stuff not specific to lang/rust.

Yes, and cromium uses a bit more.
In case port build I assume that WRKDIRPREFIX will be used to create chroot env, without forcing tmpfs.

 
> > Currently, everything is stored in tmpfs, but this can easily be
> > changed to geom md + UFS2 image.  
> 
> The md+UFS2 context is analogous to the tmpfs for needing to be able
> to hold something like 30 GiBytes+ for lang/rust materials --plus
> space for other stuff not specific to lang/rust.

This part was not for ports build, it mean that chroot env can be stored
on disk and can be tranfered like docker container.


> > In chroot, almost everything is mounted in RO, unlike in jails,
> > where everything looks like a regular installation.
> > 
> > You can adapt this script for your own purposes to create an
> > environment with all dependencies. In your blog, you used
> > /rescue/sh. The examples include examples/sh - the script will
> > automatically copy everything needed to /bin/sh.
> > 
> > 
> > 
> > PS: I wanted to rework portmaster/ports make so that it would build
> > packages like poudriere in a clean environment, but without
> > requiring zfs and complex management.  
> 
> poudriere(-devel) has separate clean environments for each
> port-package built, not just one for the overall sequence for one
> bulk command (vs. the live boot system). poudriere(-devel) bulk
> builds never run into conflicts with ports/packages that are not
> being used for the specific one being built at the time in a builder
> (assuming no unnecessary dependencies have been created).
> 
> The goals:
> 
> ) protect the live system from changes
> vs.
> ) avoid port/port-package conflicts as well
> 
> are very different. Which/what scope and type of "clean" are you
> referencing for your rework effort?
> 


What I meant was that you could easily and quickly create chroot environments for building ports in a similar way.
If I ever get around to doing this, I’d use nullfs to map almost all the system directories and use code from the script to clone the necessary packages into the chroot.
There are still many unanswered questions; for now, it’s just an idea for isolating the port-building process from the host system.

This isn't a replacement for poudriere; it’s an approach aimed at reducing errors caused by building ports on a system that has a lot of other software installed.