Build Custom RPM and DEB packages

Hi, we need to build rpm and deb packages with custom binary and service names. I have searched for a way to build from source code but most of the posts/topics are related to old versions and have broken link to github.

My understanding is that you have changed the way you build these packages but I can't find documentation or info about it.

What is the correct way to make packages with custom names? Thanks

Hi @Domenico, welcome to discuss :slight_smile:

What kind of customization do you want to make?

Packages can be built running mage package from each beat source directory, but in principle it is not possible to modify package names (without modifying the code).

Hi @jsoriano, thank you for your answer ( and the greetings :slight_smile:) .

I try to give some context:
We automate the installation of filebeat, using rpm and deb packages, while deploying our software.
Some of this servers have filebeat already installed (also different major version) sending data to another elastic server and we do not want to interfere with it.

In order to prevent any issues we would like "our" filebeat to use the same deploy strategy we already have but change the binary name from/usr/share/filebeat/ to something like /usr/share/filebeat-our-product-name and do the same with the service name (same for registry and conf file).

In this way we would have 2 different filebeat binary working in parallel on the same machine. The already installed filebeat MUST not change or be even stopped, while we have full control of "our" filebeat.

I have tried to use the mage package command but it seems not to create the service when installed (Did I do somenthing wrong?).
I have no problem to change the source code (I tried to change the env var BEAN_NAME but it seems to be used for paths tto and it do not work).

I can evaluate any option but having the "custom rpm and deb packages means we do not need to make any change to our source code. It will save us a lot of time!!

I think there are different strategies you may try that don't imply to re-build the package with custom names and paths. This, even if possible with the proper customizations in the code, can be cumbersome and error-prone.

Have you considered to use the tar.gz package? This package can be installed in any path, and wouldn't interfere with other existing installations. You could for example decide to install it in /opt/filebeat-your-product, or inside the path of your product. Filebeat installed this way will use the installation path as the base path for configuration and data, and you can of course configure it to use any other path.

These packages are available under the "Linux 32/64 bit" links in https://www.elastic.co/downloads/beats/filebeat

Thanks Jaime, that's is a much more elegant solution. I will give it a try. About the service created with the rpm and deb package, where I can find the configuration file (if available)?

Do you mean the systemd unit file? You can find the base template here: https://github.com/elastic/beats/blob/v7.9.3/dev-tools/packaging/templates/linux/systemd.unit.tmpl

You will need to replace the missing variables in the placeholders and customize the paths.

You can also start by copying one of the installed unit files on any system where you have installed filebeat with a deb or rpm package. You can see this unit file with systemctl cat filebeat.

You can place your custom unit file in the /etc/systemd/system directory.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.