@cryptotaxi247 / netdata-1 / commits / 908e30b2d

Use improved compression algorithms when building DEB packages. (#21310)

* Switch to XZ compression by default for DEB packages. XZ compression is the de-facto standard compression used for DEB packages on Ubuntu prior to Ubuntu 21.10 and Debian prior to Debian 12. Using XZ for DEB package compression incurs a nontrivial performance hit for the installation of the packages (specifically, the process of unpacking the packages), but provides a roughly 34% space savings for the whole collection of packages compared to our current usage of gzip compression (tested using Debian 13 packages) and unlike the newer zstd compression has been supported by dpkg for long enough that we don’t really have to worry about any given system not supporting it. * Enable zstd compression for DEB packages on platforms that support it. Zstd compression is supported, and used by default, in Debian and Ubuntu starting with Debian 12 and Ubuntu 21.10. Compared to gzip compression, zstd provides a roughly 8.6% reduction in the total size of a full set of our packages (tested using Debian 13 packages), while at the same time reducing the overhead of unpacking the package for installation. Compared to the XZ compression that the previous commit enabled by default for our packages, zstd results in roughly 38% larger packages, but it completely removes the overhead on installation that XZ imposes, and is thus generally considered enough of a net improvement that both Debian and Ubuntu have pivoted from using XZ for package compression for their distribution packages to using zstd.

Austin S. Hemmelgarn committed Dec 2, 2025 at 06:51 UTC 908e30b2d4b1d4037b209dbd5d6e803e73be4dcb
1 file changed +39
packaging/cmake/Modules/Packaging.cmake
+39
@@ -15,6 +15,45 @@ set(CPACK_STRIP_FILES NO)
15 set(CPACK_DEBIAN_DEBUGINFO_PACKAGE NO)
16
17 set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)
18 +set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
19 +
20 +if(OS_LINUX)
21 + set(OS_DISTRO_ID "unknown")
22 + set(OS_VERSION_ID "unknown")
23 +
24 + find_file(OS_RELEASE_PATH os-release PATHS /etc /usr/lib
25 + NO_DEFAULT_PATH
26 + NO_PACKAGE_ROOT_PATH
27 + NO_CMAKE_PATH
28 + NO_CMAKE_ENVIRONMENT_PATH
29 + NO_SYSTEM_ENVIRONMENT_PATH
30 + NO_CMAKE_SYSTEM_PATH
31 + NO_CMAKE_INSTALL_PREFIX)
32 +
33 + if(NOT OS_RELEASE_PATH STREQUAL OS_RELEASE_PATH-NOTFOUND)
34 + file(STRINGS "${OS_RELEASE_PATH}" OS_RELEASE_LINES)
35 +
36 + foreach(_line IN LISTS OS_RELEASE_LINES)
37 + if(_line MATCHES "^ID=.*$")
38 + string(SUBSTRING "${_line}" 3 -1 OS_DISTRO_ID)
39 + string(REPLACE "\"" "" OS_DISTRO_ID "${OS_DISTRO_ID}")
40 + elseif(_line MATCHES "^VERSION_ID=.*$")
41 + string(SUBSTRING "${_line}" 11 -1 OS_VERSION_ID)
42 + string(REPLACE "\"" "" OS_VERSION_ID "${OS_VERSION_ID}")
43 + endif()
44 + endforeach()
45 + endif()
46 +
47 + if(OS_DISTRO_ID STREQUAL "debian")
48 + if(OS_VERSION_ID VERSION_GREATER_EQUAL 12)
49 + set(CPACK_DEBIAN_COMPRESSION_TYPE "zstd")
50 + endif()
51 + elseif(OS_DISTRO_ID STREQUAL "ubuntu")
52 + if(OS_VERSION_ID VERSION_GREATER_EQUAL 21.10)
53 + set(CPACK_DEBIAN_COMPRESSION_TYPE "zstd")
54 + endif()
55 + endif()
56 +endif()
57
58 set(CPACK_PACKAGING_INSTALL_PREFIX "/")
59