netdata/netdata.spec

296 lines
9.8 KiB
RPMSpec
Raw Normal View History

2021-06-24 11:07:00 +08:00
%bcond_without systemd
#We use some plugins which need suid
%global _hardened_build 1
2023-08-24 16:31:55 +08:00
%global plugin_go_ver 0.54.1
%global __os_install_post %{nil}
%global netdata_conf_stock %{_prefix}/lib/%{name}
2021-06-24 11:07:00 +08:00
# Build release candidate
2023-08-24 16:31:55 +08:00
%global upver 1.42.1
2021-06-24 11:07:00 +08:00
Name: netdata
2023-08-24 16:31:55 +08:00
Version: 1.42.1
Release: 1
2021-06-24 11:07:00 +08:00
Summary: Real-time performance monitoring
2022-06-21 02:41:15 +00:00
License: GPLv3 and GPLv3+ and ASL 2.0 and CC-BY-4.0 and MIT and WTFPL
2021-06-24 11:07:00 +08:00
URL: https://github.com/%{name}/%{name}/
2023-08-24 16:31:55 +08:00
Source0: https://github.com/%{name}/%{name}/archive/v%{upver}%{?rcver:-%{rcver}}/%{name}-v%{upver}%{?rcver:-%{rcver}}.tar.gz
2021-06-24 11:07:00 +08:00
Source1: netdata.tmpfiles.conf
Source2: netdata.init
Source3: netdata.conf
2023-08-24 16:31:55 +08:00
Source4: netdata.profile
Source5: README-packager.md
Source20: https://github.com/netdata/go.d.plugin/releases/download/v%{plugin_go_ver}/config.tar.gz
Source21: netdata-install-go-plugins.sh
Patch0: netdata-fix-shebang-1.41.0.patch
2021-06-24 11:07:00 +08:00
BuildRequires: zlib-devel git autoconf automake pkgconfig libuuid-devel freeipmi-devel httpd
BuildRequires: cppcheck gcc tinyxml2
2023-08-24 16:31:55 +08:00
BuildRequires: libuv-devel
BuildRequires: Judy-devel
BuildRequires: lz4-devel
BuildRequires: openssl-devel
BuildRequires: libmnl-devel
BuildRequires: make
BuildRequires: libcurl-devel
BuildRequires: systemd
BuildRequires: openssl-devel
BuildRequires: libpfm-devel
BuildRequires: libyaml-devel
BuildRequires: autogen
BuildRequires: snappy-devel
BuildRequires: protobuf-devel
BuildRequires: protobuf-c-devel
BuildRequires: findutils
BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: json-c-devel
BuildRequires: libcap-devel
BuildRequires: libcmocka-devel
BuildRequires: cups-devel >= 1.7
BuildRequires: python3
Requires: nodejs
2021-06-24 11:07:00 +08:00
%if %{with systemd}
BuildRequires: systemd
%{?systemd_requires}
%else
Requires: initscripts /sbin/service /sbin/chkconfig
%endif
Requires: %{name}-data = %{version}-%{release} %{name}-conf = %{version}-%{release}
%description
netdata is the fastest way to visualize metrics. It is a resource
efficient, highly optimized system for collecting and visualizing any
type of realtime time-series data, from CPU usage, disk activity, SQL
queries, API calls, web site visitors, etc.
netdata tries to visualize the truth of now, in its greatest detail,
so that you can get insights of what is happening now and what just
happened, on your systems and applications.
%package data
BuildArch: noarch
Summary: Data files for netdata
%description data
Data files for netdata
%package conf
BuildArch: noarch
Summary: Configuration files for netdata
%description conf
Configuration files for netdata
%package freeipmi
Summary: FreeIPMI plugin for netdata
Requires: %{name}%{?_isa} = %{version}-%{release}
License: GPLv3
%description freeipmi
freeipmi plugin for netdata
%prep
2023-08-24 16:31:55 +08:00
%setup -qn %{name}-v%{upver}%{?rcver:-%{rcver}}
2021-06-24 11:07:00 +08:00
%patch0 -p1
2023-08-24 16:31:55 +08:00
rm -rf web/fonts web/gui/dashboard/static/media
cp %{SOURCE5} .
2021-06-24 11:07:00 +08:00
%build
autoreconf -ivf
%configure \
--prefix=%{_prefix} \
--sysconfdir=%{_sysconfdir} \
--localstatedir=%{_localstatedir} \
--enable-plugin-freeipmi \
--with-zlib --with-math --with-user=netdata
%make_build
2023-08-24 16:31:55 +08:00
mkdir conf.d
tar -xf %{SOURCE20} -C conf.d/
2021-06-24 11:07:00 +08:00
%install
%make_install
find %{buildroot} -name '.keep' -delete
# Unit file
mkdir -p %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_tmpfilesdir}
2023-08-24 16:31:55 +08:00
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
install -Dp -m 0644 system/systemd/netdata.service %{buildroot}%{_unitdir}/%{name}.service
2021-06-24 11:07:00 +08:00
install -p -m 0644 %{SOURCE1} %{buildroot}%{_tmpfilesdir}/%{name}.conf
2023-08-24 16:31:55 +08:00
2021-06-24 11:07:00 +08:00
mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}
2023-08-24 16:31:55 +08:00
mkdir -p %{buildroot}%{_localstatedir}/log/%{name}
mkdir -p %{buildroot}%{_localstatedir}/cache/%{name}
2021-06-24 11:07:00 +08:00
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
install -p -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/%{name}/
2023-08-24 16:31:55 +08:00
install -Dp -m 0644 system/logrotate/netdata %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
mkdir -p %{buildroot}%{netdata_conf_stock}/conf.d
mv %{buildroot}%{_libdir}/%{name}/conf.d/* %{buildroot}%{netdata_conf_stock}/conf.d/
sed -i -e '/^script_dir/s;=.*;="\$\{NETDATA_USER_CONFIG_DIR:-%{_sysconfdir}/netdata\}";' \
%{buildroot}%{_sysconfdir}/%{name}/edit-config
2021-06-24 11:07:00 +08:00
# Scripts must not be in /etc
mv %{buildroot}%{_sysconfdir}/%{name}/edit-config %{buildroot}%{_libexecdir}/%{name}/edit-config
# Fix EOL
sed -i -e 's/\r//' %{buildroot}%{_datadir}/%{name}/web/lib/tableExport-1.6.0.min.js
# Delete useless hidden dir
2023-08-24 16:31:55 +08:00
rm -rf %{buildroot}%{_libdir}/%{name}/system
2021-06-24 11:07:00 +08:00
rm -rf %{buildroot}%{_datadir}/%{name}/web/.well-known
2023-08-24 16:31:55 +08:00
rm -f %{buildroot}%{_sysconfdir}/%{name}/conf.d/ebpf.d/ebpf_kernel_reject_list.txt
for dir in charts.d health.d python.d statsd.d ; do
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/${dir}
done
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
install -p -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/profile.d/netdata.sh
sed -i -e '/NETDATA_STOCK_CONFIG_DIR/s;@STOCK_CONFIG_DIR@;%{netdata_conf_stock};' %{buildroot}%{_sysconfdir}/profile.d/netdata.sh
# Integrate go plugins
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/go.d
install -p conf.d/go.d.conf %{buildroot}%{netdata_conf_stock}/conf.d/go.d.conf
cp -rp conf.d/go.d %{buildroot}%{netdata_conf_stock}/conf.d/go.d
install -p -m 0644 packaging/go.d.checksums %{buildroot}%{_datadir}/%{name}/go.d.checksums
install -p -m 0750 %{SOURCE21} %{buildroot}%{_sbindir}/netdata-install-go-plugins.sh
sed -i \
-e 's;@PLUGIN_GO_VERSION@;%{plugin_go_ver};' \
-e 's;@DATADIR@;%{_datadir};' \
-e 's;@LIBEXEC@;%{_libexecdir};' \
%{buildroot}%{_sbindir}/netdata-install-go-plugins.sh
rm -f %{buildroot}%{_sysconfdir}/%{name}/netdata-updater.conf
2021-06-24 11:07:00 +08:00
%check
2023-08-24 16:31:55 +08:00
make tests
2021-06-24 11:07:00 +08:00
%pre
getent group netdata > /dev/null || groupadd -r netdata
getent passwd netdata > /dev/null || useradd -r -g netdata -c "NetData User" -s /sbin/nologin -d /var/log/%{name} netdata
%post
%if 0%{?systemd_post:1}
%systemd_post %{name}.service
%else
if [ $1 = 1 ]; then
# Initial installation
%if %{with systemd}
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%else
/sbin/chkconfig --add %{name}
%endif
fi
%endif
echo "The current config file can be downloaded with the following command"
echo "curl -o /etc/netdata/netdata.conf http://localhost:19999/netdata.conf"
%preun
%if 0%{?systemd_preun:1}
%systemd_preun %{name}.service
%else
if [ "$1" = 0 ] ; then
# Package removal, not upgrade
%if %{with systemd}
/bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
/bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
%else
/sbin/service %{name} stop > /dev/null 2>&1
/sbin/chkconfig --del %{name}
%endif
fi
exit 0
%endif
%postun
%if 0%{?systemd_postun_with_restart:1}
%systemd_postun_with_restart %{name}.service
%else
%if %{with systemd}
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ]; then
# Package upgrade, not uninstall
/bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
fi
%else
if [ "$1" -ge 1 ]; then
/sbin/service %{name} restart > /dev/null 2>&1
fi
exit 0
%endif
%endif
%triggerun -- netdata
%if %{with systemd}
if [ -f /etc/rc.d/init.d/%{name} ]; then
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply netdata
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save %{name} >/dev/null 2>&1 ||:
# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
/bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
fi
%endif
%files
2023-08-24 16:31:55 +08:00
%doc README.md CHANGELOG.md README-packager.md
2021-06-24 11:07:00 +08:00
%license LICENSE REDISTRIBUTED.md
%{_sbindir}/%{name}
2023-08-24 16:31:55 +08:00
%{_sbindir}/%{name}-claim.sh
%{_sbindir}/%{name}cli
2021-06-24 11:07:00 +08:00
%{_libexecdir}/%{name}
%if %{with systemd}
%{_unitdir}/%{name}.service
%{_tmpfilesdir}/%{name}.conf
%else
%attr(0755,root,root) %{_initrddir}/%{name}
%endif
%attr(4755,root,root) %{_libexecdir}/%{name}/plugins.d/apps.plugin
%exclude %{_libexecdir}/%{name}/plugins.d/freeipmi.plugin
%attr(0755, netdata, netdata) %{_localstatedir}/lib/%{name}
%attr(0755, netdata, netdata) %dir %{_localstatedir}/cache/%{name}
%attr(0755, netdata, netdata) %dir %{_localstatedir}/log/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
2023-08-24 16:31:55 +08:00
%attr(0750,root,netdata)%{_sbindir}/netdata-install-go-plugins.sh
2021-06-24 11:07:00 +08:00
%files conf
%doc README.md
%license LICENSE REDISTRIBUTED.md
%dir %{_sysconfdir}/%{name}
2023-08-24 16:31:55 +08:00
%dir %{_sysconfdir}/%{name}/charts.d
%dir %{_sysconfdir}/%{name}/health.d
%dir %{_sysconfdir}/%{name}/python.d
%dir %{_sysconfdir}/%{name}/statsd.d
%dir %{_sysconfdir}/%{name}/go.d
2021-06-24 11:07:00 +08:00
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
2023-08-24 16:31:55 +08:00
%dir %{netdata_conf_stock}/conf.d
%{netdata_conf_stock}/conf.d/*
%config %{_sysconfdir}/logrotate.d/netdata
%config %{_sysconfdir}/profile.d/netdata.sh
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/edit-config
%{_sysconfdir}/netdata/.install-type
2021-06-24 11:07:00 +08:00
%files data
%doc README.md
%license LICENSE REDISTRIBUTED.md
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/web
2023-08-24 16:31:55 +08:00
%{_datadir}/%{name}/go.d.checksums
2021-06-24 11:07:00 +08:00
%files freeipmi
%doc README.md
%license LICENSE REDISTRIBUTED.md
%attr(4755,root,root) %{_libexecdir}/%{name}/plugins.d/freeipmi.plugin
%changelog
2023-08-24 16:31:55 +08:00
* Thu Aug 24 2023 chenchen <chen_aka_jan@163.com> - 1.42.1-1
- Upgrade to version 1.42.1
2022-08-09 01:45:29 +00:00
* Tue Jun 21 2022 Chenyx <chenyixiong3@huawei.com> - 1.16.0-4
2022-06-21 02:41:15 +00:00
- License compliance rectification
* Sat Jan 29 2022 caodongxia <caodongxia@huawei.com> - 1.16.0 - 3
- remove install requires glyphicons-halfings-fonts
* Wed Aug 04 2021 sunguoshuai <sunguoshuai@huawei.com> - 1.16.0 - 2
- Fix missing extern in some global variables
2021-06-24 11:07:00 +08:00
* Thu Jun 24 2021 baizhonggui <baizhonggui@huawei.com> - 1.16.0 - 1
- package init