Compiling syslog-ng git snapshots on FreeBSD

The syslog-ng team publishes nightly syslog-ng git snapshot builds for Debian and Ubuntu. I publish weekly snapshot builds for RPM distributions. Recently, I was asked if creating git snapshot builds for FreeBSD is also possible. Yes, it is. That is how I test syslog-ng on FreeBSD. However, it needs some extra preparations.

Update: removed reference to gsed, as this PR fixes the problem: https://github.com/syslog-ng/syslog-ng/pull/4163

Before you begin

The methods I describe here require that you have an up-to-date ports tree and the sysutils/syslog-ng port contains the latest syslog-ng release. I use FreeBSD 13.1 AMD64, but most likely, anything I write also works on other platforms, on earlier and development releases as well.

There are two main steps: creating a release tgz (which is the input of the sysutils/syslog-ng port) and editing the Makefile in ports to compile the git snapshot instead of the latest release. For the first step, I provide two alternatives. One has many little steps but runs natively on FreeBSD. If you have a Linux box available, there is also a quicker way to create a release tgz.

Generating a release tgz on FreeBSD

Make sure that ports are up-to-date on your FreeBSD host. By the time of writing, it means that if you see anything earlier than 3.38.1 in sysutils/syslog-ng, you need to refresh ports.

Compile syslog-ng from ports. You do not have to install it but compiling syslog-ng ensures that most of the necessary dependencies are installed. You also need to install a few extra dependencies which are only necessary when generating the release tgz from git sources:

  • autoconf-archive

  • docbook-xsl

  • libxslt

You also need git. If you only use it to download source code, installing git-lite is more than enough, and pulls in a lot less dependencies.

Change to a directory, which does not already have a syslog-ng sub-directory and clone the syslog-ng sources from GitHub to your machine:

git clone https://github.com/syslog-ng/syslog-ng/

After this little fix, generating the syslog-ng release tgz is comparable to doing so on other platforms. You need to execute three commands:

./autogen.sh
OPENSSL_CFLAGS="-I/usr/include/openssl/" OPENSSL_LIBS="-L/usr/lib -lcrypto -lssl" MAKE="gmake" ./configure --enable-manpages –with-docbook=/usr/local/share/xsl/docbook/manpages/docbook.xsl
gmake dist

Note that on the last line you need to use GNU make (gmake) instead of BSD make. Otherwise, all you will see are some funny, hard to interpret error messages.

Once the last command finished running, you should see a new file in the directory with a rather strange name. For example: syslog-ng-3.38.1.75.gf1bc7db.tar.gz. The extra numbers at the end identify the latest git commit used to build the tgz file.

The Linux alternative

As you could see, preparing the release tgz needs some extra steps on FreeBSD. The only regularly tested and thus supported way of creating a release tgz is using Linux and containers (Docker or Podman). The main reason to use this containerized environment is that you do not have to install dozens of dependencies by hand, but everything is there, ready to use. You can find more information about how to generate the release tarball at: https://www.syslog-ng.com/community/b/blog/posts/dbld-a-syslog-ng-developer-tool-not-just-for-developers or in the DBLD readme at: https://github.com/syslog-ng/syslog-ng/tree/master/dbld

Copy the resulting tgz file from the dbld/build directory to your FreeBSD host.

Modifying the ports Makefile

No matter how you generated the release tgz, you should copy the resulting file under the /usr/ports/distfiles directory. Using the file name from above:

cp syslog-ng-3.38.1.75.gf1bc7db.tar.gz /usr/ports/distfiles/

Instead of editing the original ports file, copy the sysutils/syslog-ng directory somewhere else, and work on that copy. Before copying, make sure that there is no syslog-ng sub-directory in the current directory. Then:

cp -Rp /usr/ports/sysutils/syslog-ng .

Change to the syslog-ng directory and open the Makefile in your favorite text editor. Right at the beginning, there is a line:

DISTVERSION=    3.38.1

Do you still remember the strange version number in the release tgz file name? Make sure that the DISTVERSION variable equals to that. (If you forgot it, just list /usr/ports/distfiles.) Using the version from above, it should look something similar to this:

DISTVERSION=    3.38.1.75.gf1bc7db

Save the file. Now make sure that the distinfo file has the correct values about the release tarball generated from the git snapshot:

make makesum

You are now ready to compile syslog-ng. I tend to use:

make check-orphans

As it also lists any packaging list problems at the end. Right now, everything works as expected, but later in the development process you might need to edit the pkg-plist and / or the Makefile.

What is next?

You are now ready to install and test the freshly built syslog-ng package. From my previous blogs you can see how you can test syslog-ng 4.0 features or simply test the latest features and bug fixes.

-

If you have questions or comments related to syslog-ng, do not hesitate to contact us. You can reach us by email or even chat with us. For a list of possibilities, check our GitHub page under the “Community” section at https://github.com/syslog-ng/syslog-ng. On Twitter, I am available as @PCzanik.

Related Content