Skip to main content

Build native (DEB/RPM) packages for testing

This document provides instructions for developers who need to build native packages locally for testing.

Requirements​

To build native packages locally, you will need the following:

  • A working Docker or Podman host.
  • A local copy of the source tree you want to build from.
  • A Go toolchain that meets the version in src/go/go.mod.

Building the packages​

Start from the root of a clean Agent source tree. Generate the synthetic topology IP intelligence stock data required by the default native package build.

.github/scripts/prepare-topology-ip-intel-stock.sh --mode synthetic --output-dir build-topology-ip-intel-stock

The Ubuntu 24.04 example passes the staged directory's path inside the container.

docker run -it --rm -e VERSION=0.1 \
-e NETDATA_TOPOLOGY_IP_INTEL_STOCK_DIR=/netdata/build-topology-ip-intel-stock \
-v "$PWD:/netdata" netdata/package-builders:ubuntu24.04-v2

or

podman run -it --rm -e VERSION=0.1 \
-e NETDATA_TOPOLOGY_IP_INTEL_STOCK_DIR=/netdata/build-topology-ip-intel-stock \
-v "$PWD:/netdata" netdata/package-builders:ubuntu24.04-v2

To choose another builder, combine its distro, version, and builder revision as <distro><version>-<builder_rev>. For example, use rockylinux9-v2 for the EL 9 packages. Check the Agent distro matrix for the active package targets and Docker Hub for published tags and platforms. Pass --platform to Docker or Podman when targeting a different architecture and use a builder that supports it.

The value passed in the VERSION environment variable can be any version number accepted by the type of package being built. As a general rule, it needs to start with a digit, and must include a . somewhere.

Once it finishes, the built packages can be found under artifacts/ in the source tree.

If an error is encountered and the build is being run interactively, it will drop to a shell to allow you to inspect the state of the container and look at build logs.

Detailed explanation​

The helper-images repository owns the build environments, including the Dockerfiles, image matrix, and publication workflow.

The build code expects the following requirements to be met:

  • It expects the source tree it should build from to be located at /netdata, and expects that said source tree is clean (no artifacts left over from previous builds).
  • It expects an environment variable named VERSION to be defined, and uses this to control what version number will be shown in the package metadata and filenames.

Internally, the source tree gets copied to a temporary location for the build process so that the source tree can be mounted directly from the host without worrying about leaving a dirty tree behind, any templating or file movements required for the build to work are done, the package build command is invoked with the correct arguments, and then the resultant packages are copied to the artifacts/ directory in the original source tree so they are accessible after the container exits.

Finding build logs after a failed build​

Build logs and artifacts can be found in the build directory, whose location varies by distribution.

On DEB systems (Ubuntu and Debian), the build directory inside the container is located at /usr/src/netdata

On RPM systems except openSUSE, the build directory inside the container is located under /root/rpmbuild/BUILD/ and varies based on the package version number.

On openSUSE, the build directory inside the container is located under /usr/src/packages/BUILDand varies based on the package version number.

Building for other architectures​

If you need to test a build for an architecture that does not match your host system, you can do so by setting up QEMU user-mode emulation. This requires a Linux kernel with binfmt_misc support (all modern distributions provide this out of the box, but I’m not sure about WSL or Docker Desktop).

The quick and easy way to do this is to run the following:

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

or

podman run --rm --privileged multiarch/qemu-user-static --reset -p yes

This will set up the required QEMU user-mode emulation until you reboot. Note that if using Podman, you will need to run this as root and not as a rootless container (the package builds work fine in a rootless container though, even if doing cross-architecture builds).

Once you have that set up, the command to build the packages is the same as above, you just need to add a correct --platform option to the docker run or podman run command. The current list of architectures we build for, and the correct value for the --platform option is:

  • 32-bit ARMv7: linux/arm/v7
  • 64-bit ARMv8: linux/arm64/v8
  • 32-bit x86: linux/i386
  • 64-bit x86: linux/amd64

Do you have any feedback for this page? If so, you can open a new issue on our netdata/learn repository.