diff options
author | vkalintiris <vasilis@netdata.cloud> | 2023-12-13 16:41:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-13 16:41:20 +0200 |
commit | 92842d8422a570aed4005b5069531f7f5189fe4d (patch) | |
tree | 6923d0e00551ab448f7211e865577cd7a8991aef /netdata.spec.in | |
parent | 548489555bbdadc7274a2165f365b968992b98da (diff) |
CMake build system. (#15996)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Austin S. Hemmelgarn <austin@netdata.cloud>
Co-authored-by: Tasos Katsoulas <12612986+tkatsoulas@users.noreply.github.com>
Co-authored-by: Emmanuel Vasilakis <mrzammler@mm.st>
Co-authored-by: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com>
Co-authored-by: netdatabot <bot@netdata.cloud>
Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
Diffstat (limited to 'netdata.spec.in')
-rw-r--r-- | netdata.spec.in | 299 |
1 files changed, 214 insertions, 85 deletions
diff --git a/netdata.spec.in b/netdata.spec.in index 13d9dee9c3..f723ef4586 100644 --- a/netdata.spec.in +++ b/netdata.spec.in @@ -19,6 +19,31 @@ AutoReqProv: yes # hours to finish). %global _lto_cflags %nil +# Use our custom CMake version from our package builders if we can’t find cmake. +%if 0%{?centos_ver} == 7 +%global __cmake /cmake/bin/cmake +%global __cmake_builddir . +%global cmake %{__cmake} +%global cmake_build %{__cmake} --build %{__cmake_builddir} --verbose --parallel $(nproc) +%global cmake_install DESTDIR="%{buildroot}" %{__cmake} --install %{__cmake_builddir} +%global _have_ml 0 +%endif +%if 0%{?amazon_linux} == 2 +%global __cmake /cmake/bin/cmake +%global __cmake_builddir . +%global cmake %{__cmake} +%global cmake_build %{__cmake} --build %{__cmake_builddir} --verbose --parallel $(nproc) +%global cmake_install DESTDIR="%{buildroot}" %{__cmake} --install %{__cmake_builddir} +%global _have_ml 0 +%endif + +# openSUSE requires us to explicity ask for ninja for builds. +# We also need to specify the build directory since they do not. +%if 0%{?suse_version} +%global __builder ninja +%global __cmake_builddir %{__builddir} +%endif + # Disable go.d.plugin build on outdated golang distros %if 0%{?centos_ver:1} %if 0%{?centos_ver} >= 10 && 0%{?almalinux_ver:1} && 0%{?rocky_ver:1} @@ -56,6 +81,13 @@ AutoReqProv: yes %global _have_freeipmi 1 %endif +# Disable CUPS on old RHEL systems. +%if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7 && 0%{?amazon_linux} != 2 +%global _have_cups 1 +%else +%global _have_cups 0 +%endif + # Disable NFACCT for RHEL equivalents and Amazon Linux %if 0%{?centos_ver} || 0%{?amzn} %global _have_nfacct 0 @@ -63,6 +95,32 @@ AutoReqProv: yes %global _have_nfacct 1 %endif +# Disable xenstat if we’re not on Fedora or openSUSE +%if 0%{?suse_version} || 0%{?fedora} +%if 0%{!?amzm:1} +%global _have_xenstat 0 +%else +%global _have_xenstat 1 +%endif +%else +%global _have_xenstat 0 +%endif + +# Skip MongoDB exporter on known problem platforms +%if 0%{?oraclelinux} || 0%{?suse_version} || 0%{?amzn} +%global _have_mongo_exporter 0 +%else +%global _have_mongo_exporter 1 +%endif + +# If ML hasn’t been explicitly disabled or enabled yet, enable it now. +%if 0%{!?_have_ml:1} +%global _have_ml 1 +%endif + +# Filter known bogus deps that would be caught by AutoReqProv. +%global __requires_exclude_from ^%{_libdir}/%{name}/system/.*$ + Summary: Real-time performance monitoring, done right! Name: netdata Version: %{version} @@ -88,49 +146,40 @@ BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: make BuildRequires: git-core -BuildRequires: autoconf -%if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1140 -BuildRequires: autoconf-archive -%if 0%{?rhel} <= 8 && 0%{?amzn} < 2023 -BuildRequires: autogen -%endif -%endif -BuildRequires: automake BuildRequires: cmake +%if 0%{!?suse_version:1} +BuildRequires: ninja-build +%else +BuildRequires: ninja +%endif BuildRequires: pkgconfig BuildRequires: curl BuildRequires: findutils -BuildRequires: zlib-devel -BuildRequires: libuuid-devel -BuildRequires: libuv-devel >= 1 -BuildRequires: openssl-devel -BuildRequires: libcurl-devel +BuildRequires: pkgconfig(zlib) +BuildRequires: pkgconfig(uuid) +BuildRequires: pkgconfig(libuv) +BuildRequires: pkgconfig(openssl) +BuildRequires: pkgconfig(libcurl) +BuildRequires: pkgconfig(liblz4) +BuildRequires: pkgconfig(yaml-0.1) +BuildRequires: pkgconfig(json-c) %if 0%{?suse_version} # log2journal is not available on these systems %else -BuildRequires: pcre2-devel +BuildRequires: pkgconfig(libpcre2-8) %endif %if 0%{?suse_version} BuildRequires: protobuf-devel BuildRequires: libprotobuf-c-devel -BuildRequires: liblz4-devel -BuildRequires: libjson-c-devel -BuildRequires: libyaml-devel %else %if 0%{?fedora} BuildRequires: protobuf-devel BuildRequires: protobuf-c-devel -BuildRequires: lz4-devel -BuildRequires: json-c-devel -BuildRequires: libyaml-devel %else %if 0%{?centos_ver} >= 8 BuildRequires: protobuf-devel BuildRequires: protobuf-c-devel %endif -BuildRequires: lz4-devel -BuildRequires: json-c-devel -BuildRequires: libyaml-devel %endif %endif @@ -162,14 +211,19 @@ Requires: %{name}-plugin-debugfs = %{version} Requires: %{name}-plugin-chartsd = %{version} Requires: %{name}-plugin-slabinfo = %{version} Requires: %{name}-plugin-perf = %{version} -%if 0%{?_have_nfacct} +%if %{_have_nfacct} Requires: %{name}-plugin-nfacct = %{version} %endif -%if 0%{?_have_freeipmi} && 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7 && 0%{?amazon_linux} != 2 +%if %{_have_xenstat} +Suggests: %{name}-plugin-xenstat = %{version} +%endif +%if %{_have_freeipmi} && 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7 && 0%{?amazon_linux} != 2 Suggests: %{name}-plugin-freeipmi = %{version} %endif %if 0%{?centos_ver} != 7 && 0%{?amazon_linux} != 2 +%if %{_have_cups} Suggests: %{name}-plugin-cups = %{version} +%endif Recommends: %{name}-plugin-systemd-journal = %{version} Recommends: %{name}-plugin-logs-management = %{version} %else @@ -184,31 +238,27 @@ Requires: %{name}-plugin-systemd-journal = %{version} # rather than the standard ones # epbf plugin dependencies -%if 0%{?_have_ebpf} -%if 0%{?suse_version} -BuildRequires: libelf-devel -%else -BuildRequires: elfutils-libelf-devel -%endif +%if %{_have_ebpf} +BuildRequires: pkgconfig(libelf) %endif # end ebpf plugin dependencies # nfacct plugin dependencies -%if 0%{?_have_nfacct} -BuildRequires: libmnl-devel -BuildRequires: libnetfilter_acct-devel +%if %{_have_nfacct} +BuildRequires: pkgconfig(libmnl) +BuildRequires: pkgconfig(libnetfilter_acct) %endif # end nfacct plugin dependencies # freeipmi plugin dependencies -%if 0%{?_have_freeipmi} -BuildRequires: freeipmi-devel +%if %{_have_freeipmi} +BuildRequires: pkgconfig(libipmimonitoring) %endif # end - freeipmi plugin dependencies # CUPS plugin dependencies -%if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7 -BuildRequires: cups-devel >= 1.7 +%if %{_have_cups} +BuildRequires: cups-devel %endif # end - cups plugin dependencies @@ -221,13 +271,34 @@ BuildRequires: golang # end - go.d.plugin plugin dependencies # systemd-journal dependencies -BuildRequires: systemd-devel +BuildRequires: pkgconfig(libsystemd) # end - systemd-journal dependencies # Prometheus remote write dependencies +%if 0%{?suse_version} +BuildRequires: snappy-devel +%else +%if 0%{?centos_ver} != 7 +BuildRequires: pkgconfig(snappy) +%else BuildRequires: snappy-devel +%endif +%endif # end - prometheus remote write dependencies +# Xenstat dependencies +%if %{_have_xenstat} +BuildRequires: pkgconfig(xenstat) +BuildRequires: pkgconfig(xenlight) +%endif +# end - xenstat dependencies + +# MongoDB exporter dependencies +%if %{_have_mongo_exporter} +BuildRequires: pkgconfig(libmongoc-1.0) +%endif +# end - mongodb expoerter dependencies + # logs-management dependencies BuildRequires: bison BuildRequires: flex @@ -280,37 +351,70 @@ make download %build # Conf step -autoreconf -ivf -%configure \ - %if 0%{!?_have_ebpf} - --disable-ebpf \ +%cmake -G Ninja \ + -DCMAKE_INSTALL_PREFIX=/ \ + %if %{_have_cups} + -DENABLE_PLUGIN_CUPS=On \ + %else + -DENABLE_PLUGIN_CUPS=Off \ %endif - %if 0%{!?_have_freeipmi} - --disable-plugin-freeipmi \ + %if %{_have_ebpf} + -DENABLE_PLUGIN_EBPF=On \ + %else + -DENABLE_PLUGIN_EBPF=Off \ %endif - %if 0%{!?_have_nfacct} - --disable-plugin-nfacct \ + %if %{_have_freeipmi} + -DENABLE_PLUGIN_FREEIPMI=On \ + %else + -DENABLE_PLUGIN_FREEIPMI=Off \ + %endif + %if %{_have_nfacct} + -DENABLE_PLUGIN_NFACCT=On \ + %else + -DENABLE_PLUGIN_NFACCT=Off \ + %endif + %if %{_have_xenstat} + -DENABLE_PLUGIN_XENSTAT=On \ + %else + -DENABLE_PLUGIN_XENSTAT=Off \ %endif %if 0%{?centos_ver:1} %if %{centos_ver} < 8 - --with-bundled-protobuf \ + -DENABLE_BUNDLED_PROTOBUF=On \ + %else + -DENABLE_BUNDLED_PROTOBUF=Off \ %endif + %else + -DENABLE_BUNDLED_PROTOBUF=Off \ %endif - %if 0%{?oraclelinux} - --disable-exporting-mongodb \ + %if %{_have_ml} + -DENABLE_ML=On \ + %else + -DENABLE_ML=Off \ %endif - --prefix="%{_prefix}" \ - --sysconfdir="%{_sysconfdir}" \ - --localstatedir="%{_localstatedir}" \ - --libexecdir="%{_libexecdir}" \ - --libdir="%{_libdir}" \ - --with-zlib \ - --with-math \ - --with-user=%{name} \ - --disable-dependency-tracking + %if %{_have_mongo_exporter} + -DENABLE_EXPORTER_MONGODB=On \ + %else + -DENABLE_EXPORTER_MONGODB=Off \ + %endif + -DENABLE_ACLK=On \ + -DENABLE_CLOUD=On \ + -DENABLE_DBENGINE=On \ + -DENABLE_H2O=On \ + -DENABLE_PLUGIN_APPS=On \ + -DENABLE_PLUGIN_CGROUP_NETWORK=On \ + -DENABLE_PLUGIN_DEBUGFS=On \ + -DENABLE_PLUGIN_LOCAL_LISTENERS=On \ + -DENABLE_PLUGIN_PERF=On \ + -DENABLE_PLUGIN_SLABINFO=On \ + -DENABLE_PLUGIN_SYSTEMD_JOURNAL=On \ + -DENABLE_PLUGIN_LOGS_MANAGEMENT=On \ + -DENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE=On \ + -DENABLE_BUNDLED_JSONC=Off \ + -DENABLE_BUNDLED_YAML=Off # Build step -%{__make} %{?_smp_mflags} +%{cmake_build} # Build go.d.plugin %if 0%{?_golang_build} @@ -324,7 +428,7 @@ TRAVIS_TAG="%{go_version}" %{__make} build # ########################################################### # Clear the directory, if already exists and install rm -rf "${RPM_BUILD_ROOT}" -%{__make} %{?_smp_mflags} DESTDIR="${RPM_BUILD_ROOT}" install +%{cmake_install} install -m 644 -p "system/%{name}.conf" "${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}" @@ -335,25 +439,25 @@ install -m 755 -p packaging/installer/%{name}-updater.sh "${RPM_BUILD_ROOT}%{_li # ########################################################### # logrotate settings install -m 755 -d "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d" -install -m 644 -p "system/logrotate/%{name}" "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}" +install -m 644 -p "%{__cmake_builddir}/system/logrotate/%{name}" "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}" # ########################################################### # Install freeipmi -%if 0%{?_have_freeipmi} -install -m 4750 -p freeipmi.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/freeipmi.plugin" -%endif +#%if 0%{?_have_freeipmi} +#install -m 4750 -p freeipmi.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/freeipmi.plugin" +#%endif # ########################################################### # Install apps.plugin -install -m 4750 -p apps.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/apps.plugin" +#install -m 4750 -p apps.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/apps.plugin" # ########################################################### # Install debugfs.plugin -install -m 0750 -p debugfs.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/debugfs.plugin" +#install -m 0750 -p debugfs.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/debugfs.plugin" # ########################################################### # Install systemd-journal.plugin -install -m 4750 -p systemd-journal.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/systemd-journal.plugin" +#install -m 4750 -p systemd-journal.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/systemd-journal.plugin" # ########################################################### # Install logs-management.plugin @@ -361,23 +465,23 @@ install -m 4750 -p systemd-journal.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{nam # ########################################################### # Install perf.plugin -install -m 4750 -p perf.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/perf.plugin" +#install -m 4750 -p perf.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/perf.plugin" # ########################################################### # Install ebpf.plugin -%if 0%{?_have_ebpf} -install -m 4750 -p ebpf.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/ebpf.plugin" -%endif +#%if 0%{?_have_ebpf} +#install -m 4750 -p ebpf.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/ebpf.plugin" +#%endif # ########################################################### # Install cups.plugin -%if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7 -install -m 0750 -p cups.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/cups.plugin" -%endif +#%if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7 +#install -m 0750 -p cups.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/cups.plugin" +#%endif # ########################################################### # Install slabinfo.plugin -install -m 4750 -p slabinfo.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/slabinfo.plugin" +#install -m 4750 -p slabinfo.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/slabinfo.plugin" # ########################################################### # Install cache and log directories @@ -398,9 +502,9 @@ install -m 750 -p packaging/installer/%{name}-uninstaller.sh \ install -m 755 -d "${RPM_BUILD_ROOT}%{_unitdir}" %if 0%{?centos_ver} != 7 && 0%{?amazon_linux} != 2 -install -m 644 -p "system/systemd/%{name}.service" "${RPM_BUILD_ROOT}%{_unitdir}/%{name}.service" +install -m 644 -p "%{__cmake_builddir}/system/systemd/%{name}.service" "${RPM_BUILD_ROOT}%{_unitdir}/%{name}.service" %else -install -m 644 -p "system/systemd/%{name}.service.v235" "${RPM_BUILD_ROOT}%{_unitdir}/%{name}.service" +install -m 644 -p "%{__cmake_builddir}/system/systemd/%{name}.service.v235" "${RPM_BUILD_ROOT}%{_unitdir}/%{name}.service" %endif install -m 755 -d "${RPM_BUILD_ROOT}%{_presetdir}" install -m 644 -p "system/systemd/50-%{name}.preset" "${RPM_BUILD_ROOT}%{_presetdir}/50-%{name}.preset" @@ -623,14 +727,15 @@ rm -rf "${RPM_BUILD_ROOT}" %attr(0755,netdata,root) %dir %{_localstatedir}/log/%{name} %attr(0770,netdata,netdata) %dir %{_localstatedir}/lib/%{name} %attr(0770,netdata,netdata) %dir %{_localstatedir}/lib/%{name}/registry +%attr(0770,netdata,netdata) %dir %{_localstatedir}/lib/%{name}/cloud.d # Free IPMI belongs to a different sub-package -%if 0%{?_have_freeipmi} +%if %{_have_freeipmi} %exclude %{_libexecdir}/%{name}/plugins.d/freeipmi.plugin %endif # NFACCT belongs to a different sub-package -%if 0%{?_have_nfacct} +%if %{_have_nfacct} %exclude %{_libexecdir}/%{name}/plugins.d/nfacct.plugin %endif @@ -642,7 +747,7 @@ rm -rf "${RPM_BUILD_ROOT}" %exclude %{_libdir}/%{name}/conf.d/charts.d/ # eBPF belongs to a different sub-package -%if 0%{?_have_ebpf} +%if %{_have_ebpf} %exclude %{_libexecdir}/%{name}/plugins.d/ebpf.plugin %exclude %{_libdir}/%{name}/conf.d/ebpf.d.conf %exclude %{_libdir}/%{name}/conf.d/ebpf.d @@ -673,19 +778,21 @@ rm -rf "${RPM_BUILD_ROOT}" # systemd-journal belongs to a different sub-package %exclude %{_libexecdir}/%{name}/plugins.d/systemd-journal.plugin +# xenstat belongs to a different sub-package +%exclude %{_libexecdir}/%{name}/plugins.d/xenstat.plugin + # logs management belongs to a different sub-package %exclude %{_libexecdir}/%{name}/plugins.d/logs-management.plugin %exclude %{_libdir}/%{name}/conf.d/logsmanagement.d.conf %exclude %{_libdir}/%{name}/conf.d/logsmanagement.d # CUPS belongs to a different sub package -%if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7 +%if %{_have_cups} %exclude %{_libexecdir}/%{name}/plugins.d/cups.plugin %package plugin-cups Summary: The CUPS metrics collection plugin for the Netdata Agent Group: Applications/System -Requires: cups >= 1.7 Requires: %{name} = %{version} %description plugin-cups @@ -721,7 +828,7 @@ fi %attr(4750,root,netdata) %{_libexecdir}/%{name}/plugins.d/freeipmi.plugin %endif -%if 0%{?_have_nfacct} +%if %{_have_nfacct} %package plugin-nfacct Summary: The NFACCT metrics collection plugin for the Netdata Agent Group: Applications/System @@ -996,6 +1103,27 @@ fi # CAP_DAC_READ_SEARCH required for data collection. %caps(cap_dac_read_search=ep) %attr(0750,root,netdata) %{_libexecdir}/%{name}/plugins.d/systemd-journal.plugin +%if %{_have_xenstat} +%package plugin-xenstat +Summary: The xenstat plugin for the Netdata Agent +Group: Applications/System +Requires: %{name} = %{version} +Conflicts: %{name} < %{version} + +%description plugin-xenstat + This plugin allows Netdata to collect metrics from the Xen Hypervisor. + +%pre plugin-xenstat +if ! getent group %{name} > /dev/null; then + groupadd --system %{name} +fi + +%files plugin-xenstat +%defattr(0750,root,netdata,0750) +# SUID needed for data collection +%attr(4750,root,netdata) %{_libexecdir}/%{name}/plugins.d/xenstat.plugin +%endif + %package plugin-logs-management Summary: The logs-management plugin for the Netdata Agent Group: Applications/System @@ -1007,7 +1135,6 @@ Conflicts: %{name} < %{version} and parse them to extract metrics. %pre plugin-logs-management - if ! getent group %{name} > /dev/null; then groupadd --system %{name} fi @@ -1023,6 +1150,8 @@ fi %changelog * Thu Oct 26 2023 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-24 - Add package for logs-management plugin +* Tue Sep 19 2023 Austin hemmelgarn <austin@netdata.cloud> 0.0.0-24 +- Switch to using cmake for builds. * Mon Aug 28 2023 Konstantin Shalygin <k0ste@k0ste.ru> 0.0.0-23 - Build go.d.plugin natively for CentOS Stream distro * Mon Aug 21 2023 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-22 |