Overlay Package Sets

Published on 2011-10-03

I like to have the same base packages installed on my different machines and I like to be able to easily reference different package sets depending on what that specific machine is supposed to be used for. I have since long been using virtual ebuilds to do this, which is a terrible way to achieve the same thing; Granted that you, like myself, don’t do anything special with your system configs, or add scripts, or anything else which would warrant an ebuild with a version number.

So to recap, what we want to do is:

Define an overlay

I use github to host my overlay, pick whatever tool and service you like to provision your ebuilds. First lets make a place for the overlay in our local portage dir and add it to our PORTDIR_OVERLAY.

cd /usr/local/portage
mkdir edwtjo-ebuilds
cd edwtjo-ebuilds
cat >> /etc/make.conf <<___PO__

Almost there, now we need to name it in a way that portage understands.

mkdir profiles
echo "edwtjo-ebuilds" > profiles/repo_name

Define a package set

Next up we add some packages to our package set, lets call the new package set “edwtjo-common”

mkdir sets
cat > sets/edwtjo-common <<__EC__

But! Portage will not be able to find this set yet, we need to find a way to tell portage to index our sets directory. This is done by defining a sets.conf at the base of the repository.

cat > sets.conf <<__SC__
[edwtjo-ebuilds sets]
class = portage.sets.files.StaticFileSet
multiset = true
directory = ${repository:edwtjo-ebuilds}/sets/
world-candidate = True

Now we can install “edwtjo-common” by using

emerge @edwtjo-common

Great! But how about that “inherited”, or cascaded, package set? Easy! Just define another set and reference the first set in the same way as you would installing it, lets call this one “edwtjo-pentest”

cat > sets/edwtjo-pentest <<__EP__

And just install

emerge @edwtjo-pentest

It is this sort of elegance that makes me really love (gen|fun)too.