Multiple ports trees on one system

Good afternoon,

I'm working on a project to enable users to easily install additional ports trees using different $PORTSDIR and $PREFIX on the same system.

My primary motivation is to enable static ports installations for long-term scientific studies, where upgrading installed packages mid-study can create serious problems. Researchers sometimes need to run the exact same version of a software package for many years in order to protect the integrity of a study.

The solution we use on our CentOS systems is to install pkgsrc quarterly snapshots, each under a unique prefix, and leave them in-place indefinitely. The system is described in detail here:

We can, of course, use pkgsrc on FreeBSD as well, but the FreeBSD ports collection is currently much bigger and all of the ports are tested on FreeBSD, whereas many pkgsrc packages are not.

I have developed a script to bootstrap additional ports trees either as root or as an ordinary user. The system is mostly functional now. There are a few ports that fail because they assume root privileges (e.g. cups), and ports depending on OpenMPI do not currently see the libs in $PREFIX/mpi/openmpi/lib.

I'd like to solicit feedback on the approach and suggestions for ways to improve the system.

The script is available here:


+1 on that. Build whatever you need with poudriere and save the resulting packages somewhere safe. Switching package trees is as easy as creating or changing /usr/local/etc/pkg/repos/myrepo.conf. Or create multiple ones and let the user enable/disable them.

myrepo1: {
 enabled: no
 priority: 1
myrepo2: {
 enabled: yes
 priority: 2

If you build things really clever you can enable them all and let the priority pick the right repo. Besides that, even if you keep the ports tree the same, if a user selects different options, or inadvertently adds some compiler options, the results can vary greatly. By always installing from the exact same package tree you can be sure that your package has the exact same features, compiler options and whatnot.

I'd probably do something similar for CentOS too. Just fetch all the packages you need and host them locally. It's easy to modify /etc/yum.repos.d/. Why take the risk of letting users build from source?
Thanks - I do use Poudriere and might provide a set of binary packages at some point, but as the FreeBSD ports system isn't designed to rely entirely on binary packages, it's important to support building from source as well. Part of the goal here is to make it easy for scientists to install software on their own using non-default port options, experimental ports, etc. I can't provide that for everyone via Poudriere, and most of them are not Unix gurus, so expecting them to use Poudriere on their own is not feasible. That's where the auto-ports-setup script comes in.

I think you're misunderstanding what I mean by allowing ordinary users to install software. Users are not given root access to install in /usr/local. They will simply bootstrap a ports tree in a directory where they have write access and install things there. Try the script as a regular user and see how it works.