How to install a Gentoo Build Publisher

In my previous post I explained what Gentoo Build Publisher is and how it may benefit Gentoo users, especially those with multiple heterogeneous Gentoo systems. Here I will explain how I currently have a GBP instance running for my systems at home.

Firstly you'll need a Jenkins instance. GBP currently only works with Jenkins. Maybe in the future it will support other CI/CD platforms. Within Jenkins I have a "Gentoo" folder and within the "Gentoo" folder I have a "repos" folder.

Creating a GBP instance

You'll need an instance (machine, virtual machine, container, etc.) that will be your build publisher. This should be Linux system but need not be a Gentoo system (GBP does not depend on Gentoo). Gentoo Build Publisher is a Django application so you'll need Python 3 installed. In addition you'll need rsync for serving up repos and and http server (I use nginx) for serving binary packages. Those are the minimum requirements.

Gentoo Build Publisher performs all its work in a directory tree which is the "home" of Gentoo Build Publisher. On my instance I have a system user called gbp and its home directory is GBP's home. The filesystem where this directory resides needs to have ample storage available for the number of builds you wish to keep. A "build" consists of a portage tree, any additional repos, binpkgs and machine config.

In the instance, in the home directory, create a Python virtual environment and install GBP:

$ cd ~gbp
$ python3 -m venv .venv
$ ./.venv/bin/pip install git+https://github.com/enku/gentoo-build-publisher

Now that GBP is installed you'll need to create and configure a Django project.

$ ./.venv/bin/django-admin startproject project .

Next, go into project/settings.py and add 'gentoo_build_publisher' to the list of INSTALLED_APPS.

Setting up build jobs for your repos (overlays)

The "repos" folder contains the jobs for all my repos. The minimum repo needed is the "gentoo" repo (aka portage tree). For that I have a job called "gentoo" which polls Gentoo's portage repo (https://anongit.gentoo.org/git/repo/gentoo.git). This job should create an artifact, gentoo-repo.tar.gz. I also write the timestamp.chk file prior to archiving as portage checks this file when it does an emerge --sync. My build command basically looks like this:

date -R -u > ./metadata/timestamp.chk
rm -f gentoo-repo.tar.gz
mkdir -p "${WORKSPACE_TMP}"
tar cf "${WORKSPACE_TMP}"/gentoo-repo.tar.gz -I 'gzip -9' --exclude-vcs --exclude-vcs-ignores .
mv "${WORKSPACE_TMP}"/gentoo-repo.tar.gz .

And my Post-build action tells Jenkins to archive the gentoo-repo.tar.gz artifact.

Repeat the same process for any overlays that you'll be using. For example, I have a personal overlay, "marduk" and a Jenkins job for it that produces a marduk-repo.tar.gz artifact.

Once you've verified that repo artifacts are being created, you can move on to the next step.