netdata.spec.in 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. # SPDX-License-Identifier: GPL-3.0-or-later
  2. %global contentdir %{_datadir}/netdata
  3. %global version @PACKAGE_VERSION@
  4. #TODO: Temporary fix for the build-id error during go.d plugin set up
  5. %global _missing_build_ids_terminate_build 0
  6. # This is temporary and should eventually be resolved. This bypasses
  7. # the default rhel __os_install_post which throws a python compile
  8. # error.
  9. %global __os_install_post %{nil}
  10. # Mitigate the cross-distro mayhem by strictly defining the libexec destination
  11. %define _prefix /usr
  12. %define _sysconfdir /etc
  13. %define _localstatedir /var
  14. %define _libexecdir /usr/libexec
  15. %define _libdir /usr/lib
  16. #
  17. # Conditional build:
  18. %bcond_without systemd # systemd
  19. %bcond_with netns # build with netns support (cgroup-network)
  20. %if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1140
  21. %else
  22. %undefine with_systemd
  23. %undefine with_netns
  24. %endif
  25. %if %{with systemd}
  26. %if 0%{?suse_version}
  27. %global netdata_initd_buildrequires \
  28. BuildRequires: systemd-rpm-macros \
  29. %{nil}
  30. %global netdata_initd_requires \
  31. %{?systemd_requires} \
  32. %{nil}
  33. %global netdata_init_post %service_add_post netdata.service \
  34. /sbin/service netdata restart > /dev/null 2>&1 \
  35. %{nil}
  36. %global netdata_init_preun %service_del_preun netdata.service \
  37. /sbin/service netdata stop > /dev/null 2>&1 \
  38. %{nil}
  39. %global netdata_init_postun %service_del_postun netdata.service
  40. %else
  41. %global netdata_initd_buildrequires \
  42. BuildRequires: systemd
  43. %global netdata_initd_requires \
  44. Requires(preun): systemd-units \
  45. Requires(postun): systemd-units \
  46. Requires(post): systemd-units \
  47. %{nil}
  48. %global netdata_init_post %systemd_post netdata.service \
  49. /usr/bin/systemctl enable netdata.service \
  50. /usr/bin/systemctl daemon-reload \
  51. /usr/bin/systemctl restart netdata.service \
  52. %{nil}
  53. %global netdata_init_preun %systemd_preun netdata.service
  54. %global netdata_init_postun %systemd_postun_with_restart netdata.service
  55. %endif
  56. %else
  57. %global netdata_initd_buildrequires %{nil}
  58. %global netdata_initd_requires \
  59. Requires(post): chkconfig \
  60. %{nil}
  61. %global netdata_init_post \
  62. /sbin/chkconfig --add netdata \
  63. /sbin/service netdata restart > /dev/null 2>&1 \
  64. %{nil}
  65. %global netdata_init_preun %{nil} \
  66. if [ $1 = 0 ]; then \
  67. /sbin/service netdata stop > /dev/null 2>&1 \
  68. /sbin/chkconfig --del netdata \
  69. fi \
  70. %{nil}
  71. %global netdata_init_postun %{nil} \
  72. if [ $1 != 0 ]; then \
  73. /sbin/service netdata condrestart 2>&1 > /dev/null \
  74. fi \
  75. %{nil}
  76. %endif
  77. Summary: Real-time performance monitoring, done right!
  78. Name: netdata
  79. Version: %{version}
  80. Release: 1%{?dist}
  81. License: GPLv3+
  82. Group: Applications/System
  83. Source0: https://github.com/netdata/%{name}/releases/download/%{version}/%{name}-%{version}.tar.gz
  84. URL: http://my-netdata.io
  85. # #####################################################################
  86. # Core build/install/runtime dependencies
  87. # #####################################################################
  88. # Build dependencies
  89. #
  90. BuildRequires: gcc
  91. BuildRequires: gcc-c++
  92. BuildRequires: make
  93. BuildRequires: git
  94. BuildRequires: autoconf
  95. %if 0%{?fedora} || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1140
  96. BuildRequires: autoconf-archive
  97. BuildRequires: autogen
  98. %endif
  99. BuildRequires: automake
  100. BuildRequires: pkgconfig
  101. BuildRequires: curl
  102. BuildRequires: findutils
  103. BuildRequires: zlib-devel
  104. BuildRequires: libuuid-devel
  105. BuildRequires: libuv-devel >= 1
  106. BuildRequires: openssl-devel
  107. %if 0%{?suse_version}
  108. BuildRequires: judy-devel
  109. BuildRequires: liblz4-devel
  110. BuildRequires: netcat-openbsd
  111. BuildRequires: json-glib-devel
  112. %else
  113. BuildRequires: Judy-devel
  114. BuildRequires: lz4-devel
  115. BuildRequires: nc
  116. BuildRequires: json-c-devel
  117. %endif
  118. # Core build requirements for service install
  119. %{netdata_initd_buildrequires}
  120. # Runtime dependencies
  121. #
  122. Requires: python
  123. Requires: zlib
  124. %if 0%{?suse_version}
  125. # for libuv, Requires version >= 1
  126. Requires: libuv1
  127. Requires: libJudy1
  128. Requires: json-glib
  129. Requires: libuuid1
  130. %else
  131. # for libuv, Requires version >= 1
  132. Requires: libuv >= 1
  133. Requires: Judy
  134. Requires: json-c
  135. Requires: libuuid
  136. %endif
  137. Requires: openssl
  138. Requires: lz4
  139. # Core requirements for the install to succeed
  140. Requires(pre): /usr/sbin/groupadd
  141. Requires(pre): /usr/sbin/useradd
  142. %if 0%{?suse_version} >= 1140
  143. Requires(post): libcap1
  144. %else
  145. Requires(post): libcap
  146. %endif
  147. %{netdata_initd_requires}
  148. # #####################################################################
  149. # Functionality-dependent package dependencies
  150. # #####################################################################
  151. # Note: Some or all of the Packages may be found in the EPEL repo,
  152. # rather than the standard ones
  153. # nfacct plugin dependencies
  154. BuildRequires: libmnl-devel
  155. %if 0%{?fedora} || 0%{?suse_version} >= 1140
  156. BuildRequires: libnetfilter_acct-devel
  157. %endif
  158. %if 0%{?suse_version}
  159. Requires: libmnl0
  160. %else
  161. Requires: libmnl
  162. %endif
  163. %if 0%{?fedora}
  164. Requires: libnetfilter_acct
  165. %else
  166. %if 0%{?suse_version} >= 1140
  167. Requires: libnetfilter_acct1
  168. %endif
  169. %endif
  170. # end nfacct plugin dependencies
  171. # freeipmi plugin dependencies
  172. BuildRequires: freeipmi-devel
  173. Requires: freeipmi
  174. # end - freeipmi plugin dependencies
  175. # CUPS plugin dependencies
  176. %if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7
  177. BuildRequires: cups-devel >= 1.7
  178. %endif
  179. # end - cups plugin dependencies
  180. # Prometheus remote write dependencies
  181. BuildRequires: snappy-devel
  182. BuildRequires: protobuf-devel
  183. %if 0%{?suse_version}
  184. BuildRequires: libprotobuf-c-devel
  185. %else
  186. BuildRequires: protobuf-c-devel
  187. %endif
  188. %if 0%{?suse_version}
  189. Requires: libsnappy1
  190. Requires: protobuf-c
  191. Requires: libprotobuf15
  192. %else
  193. Requires: snappy
  194. Requires: protobuf-c
  195. Requires: protobuf
  196. %endif
  197. # end - prometheus remote write dependencies
  198. # #####################################################################
  199. # End of dependency management configuration
  200. # #####################################################################
  201. %description
  202. netdata is the fastest way to visualize metrics. It is a resource
  203. efficient, highly optimized system for collecting and visualizing any
  204. type of realtime timeseries data, from CPU usage, disk activity, SQL
  205. queries, API calls, web site visitors, etc.
  206. netdata tries to visualize the truth of now, in its greatest detail,
  207. so that you can get insights of what is happening now and what just
  208. happened, on your systems and applications.
  209. %prep
  210. %setup -q -n %{name}-%{version}
  211. %build
  212. # Conf step
  213. autoreconf -ivf
  214. %configure \
  215. --prefix="%{_prefix}" \
  216. --sysconfdir="%{_sysconfdir}" \
  217. --localstatedir="%{_localstatedir}" \
  218. --libexecdir="%{_libexecdir}" \
  219. --libdir="%{_libdir}" \
  220. --with-zlib \
  221. --with-math \
  222. --with-user=netdata \
  223. # Build step
  224. %{__make} %{?_smp_mflags}
  225. %install
  226. # ###########################################################
  227. # Clear the directory, if already exists and install
  228. rm -rf "${RPM_BUILD_ROOT}"
  229. %{__make} %{?_smp_mflags} DESTDIR="${RPM_BUILD_ROOT}" install
  230. find "${RPM_BUILD_ROOT}%{_localstatedir}" -name .keep -delete -print
  231. install -m 644 -p system/netdata.conf "${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}"
  232. # ###########################################################
  233. # logrotate settings
  234. install -m 755 -d "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d"
  235. install -m 644 -p system/netdata.logrotate "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}"
  236. # ###########################################################
  237. # Install freeipmi
  238. install -m 4750 -p freeipmi.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/freeipmi.plugin"
  239. # ###########################################################
  240. # Install apps.plugin
  241. install -m 4750 -p apps.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/apps.plugin"
  242. # ###########################################################
  243. # Install perf.plugin
  244. install -m 4750 -p perf.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/perf.plugin"
  245. # ###########################################################
  246. # Install cups.plugin
  247. %if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7
  248. install -m 0750 -p cups.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/cups.plugin"
  249. %endif
  250. # ###########################################################
  251. # Install slabinfo.plugin
  252. install -m 4750 -p slabinfo.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/slabinfo.plugin"
  253. # ###########################################################
  254. # Install registry directory
  255. install -m 755 -d "${RPM_BUILD_ROOT}%{_localstatedir}/lib/%{name}/registry"
  256. # ###########################################################
  257. # Install netdata service
  258. %if %{with systemd}
  259. install -m 755 -d "${RPM_BUILD_ROOT}%{_unitdir}"
  260. install -m 644 -p system/netdata.service "${RPM_BUILD_ROOT}%{_unitdir}/netdata.service"
  261. %else
  262. # install SYSV init stuff
  263. install -d "${RPM_BUILD_ROOT}/etc/rc.d/init.d"
  264. install -m 755 system/netdata-init-d \
  265. "${RPM_BUILD_ROOT}/etc/rc.d/init.d/netdata"
  266. %endif
  267. # ############################################################
  268. # Package Go within netdata (TBD: Package it separately)
  269. safe_sha256sum() {
  270. # Within the contexct of the installer, we only use -c option that is common between the two commands
  271. # We will have to reconsider if we start non-common options
  272. if command -v sha256sum >/dev/null 2>&1; then
  273. sha256sum $@
  274. elif command -v shasum >/dev/null 2>&1; then
  275. shasum -a 256 $@
  276. else
  277. fatal "I could not find a suitable checksum binary to use"
  278. fi
  279. }
  280. download_go() {
  281. url="${1}"
  282. dest="${2}"
  283. if command -v curl >/dev/null 2>&1; then
  284. curl -sSL --connect-timeout 10 --retry 3 "${url}" > "${dest}"
  285. elif command -v wget >/dev/null 2>&1; then
  286. wget -T 15 -O - "${url}" > "${dest}"
  287. else
  288. echo >&2
  289. echo >&2 "Downloading go.d plugin from '${url}' failed because of missing mandatory packages."
  290. echo >&2 "Either add packages or disable it by issuing '--disable-go' in the installer"
  291. echo >&2
  292. exit 1
  293. fi
  294. }
  295. install_go() {
  296. # When updating this value, ensure correct checksums in packaging/go.d.checksums
  297. GO_PACKAGE_VERSION="$(cat packaging/go.d.version)"
  298. ARCH_MAP=(
  299. 'i386::386'
  300. 'i686::386'
  301. 'x86_64::amd64'
  302. 'aarch64::arm64'
  303. 'armv64::arm64'
  304. 'armv6l::arm'
  305. 'armv7l::arm'
  306. 'armv5tel::arm'
  307. )
  308. if [ -z "${NETDATA_DISABLE_GO+x}" ]; then
  309. echo >&2 "Install go.d.plugin"
  310. ARCH=$(uname -m)
  311. OS=$(uname -s | tr '[:upper:]' '[:lower:]')
  312. for index in "${ARCH_MAP[@]}" ; do
  313. KEY="${index%%::*}"
  314. VALUE="${index##*::}"
  315. if [ "$KEY" = "$ARCH" ]; then
  316. ARCH="${VALUE}"
  317. break
  318. fi
  319. done
  320. tmp=$(mktemp -d /tmp/netdata-go-XXXXXX)
  321. GO_PACKAGE_BASENAME="go.d.plugin-${GO_PACKAGE_VERSION}.${OS}-${ARCH}.tar.gz"
  322. download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/${GO_PACKAGE_BASENAME}" "${tmp}/${GO_PACKAGE_BASENAME}"
  323. download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/config.tar.gz" "${tmp}/config.tar.gz"
  324. if [ ! -f "${tmp}/${GO_PACKAGE_BASENAME}" ] || [ ! -f "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/${GO_PACKAGE_BASENAME}" ]; then
  325. echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
  326. echo >&2
  327. return 1
  328. fi
  329. grep "${GO_PACKAGE_BASENAME}\$" "packaging/go.d.checksums" > "${tmp}/sha256sums.txt" 2>/dev/null
  330. grep "config.tar.gz" "packaging/go.d.checksums" >> "${tmp}/sha256sums.txt" 2>/dev/null
  331. # Checksum validation
  332. if ! (cd "${tmp}" && safe_sha256sum -c "sha256sums.txt"); then
  333. echo >&2 "go.d plugin checksum validation failure."
  334. echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
  335. echo >&2
  336. echo "go.d.plugin package files checksum validation failed."
  337. exit 1
  338. fi
  339. # Install files
  340. tar -xf "${tmp}/config.tar.gz" -C "${RPM_BUILD_ROOT}%{_libdir}/%{name}/conf.d/"
  341. tar xf "${tmp}/${GO_PACKAGE_BASENAME}"
  342. mv "${GO_PACKAGE_BASENAME/\.tar\.gz/}" "go.d.plugin"
  343. rm -rf "${tmp}"
  344. fi
  345. return 0
  346. }
  347. install_go
  348. install -m 0640 -p go.d.plugin "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/plugins.d/go.d.plugin"
  349. %pre
  350. # User/Group creations, as needed
  351. getent group netdata >/dev/null || groupadd -r netdata
  352. getent group docker >/dev/null || groupadd -r docker
  353. getent passwd netdata >/dev/null || \
  354. useradd -r -g netdata -G docker -s /sbin/nologin \
  355. -d %{contentdir} -c "netdata" netdata
  356. %post
  357. %{netdata_init_post}
  358. %preun
  359. %{netdata_init_preun}
  360. %postun
  361. %{netdata_init_postun}
  362. %clean
  363. rm -rf "${RPM_BUILD_ROOT}"
  364. %files
  365. %doc README.md
  366. %{_sysconfdir}/%{name}
  367. %config(noreplace) %{_sysconfdir}/%{name}/netdata.conf
  368. %defattr(-,root,netdata)
  369. %dir %{_libdir}/%{name}
  370. %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
  371. %{_libdir}/%{name}
  372. %defattr(0755,netdata,netdata,0755)
  373. %{_libexecdir}/%{name}
  374. %{_sbindir}/%{name}
  375. %defattr(0755,root,root,0755)
  376. %{_sbindir}/netdatacli
  377. %{_sbindir}/netdata-claim.sh
  378. %defattr(4750,root,netdata,0750)
  379. %dir %{_libexecdir}/%{name}/python.d
  380. %dir %{_libexecdir}/%{name}/charts.d
  381. %dir %{_libexecdir}/%{name}/plugins.d
  382. %dir %{_libexecdir}/%{name}/node.d
  383. %caps(cap_dac_read_search,cap_sys_ptrace=ep) %attr(0550,root,netdata) %{_libexecdir}/%{name}/plugins.d/apps.plugin
  384. %if %{with netns}
  385. # cgroup-network detects the network interfaces of CGROUPs
  386. # it must be able to use setns() and run cgroup-network-helper.sh as root
  387. # the helper script reads /proc/PID/fdinfo/* files, runs virsh, etc.
  388. %caps(cap_setuid=ep) %attr(4550,root,netdata) %{_libexecdir}/%{name}/plugins.d/cgroup-network
  389. %attr(0550,root,root) %{_libexecdir}/%{name}/plugins.d/cgroup-network-helper.sh
  390. %endif
  391. # perf plugin
  392. %caps(cap_setuid=ep) %attr(4750,root,netdata) %{_libexecdir}/%{name}/plugins.d/perf.plugin
  393. # perf plugin
  394. %caps(cap_setuid=ep) %attr(4550,root,netdata) %{_libexecdir}/%{name}/plugins.d/slabinfo.plugin
  395. # freeipmi files
  396. %caps(cap_setuid=ep) %attr(4550,root,netdata) %{_libexecdir}/%{name}/plugins.d/freeipmi.plugin
  397. %dir %{_datadir}/%{name}
  398. %defattr(0750,netdata,netdata,0755)
  399. %{_libdir}/%{name}/conf.d/
  400. %if %{with systemd}
  401. %{_unitdir}/netdata.service
  402. %else
  403. %{_sysconfdir}/rc.d/init.d/netdata
  404. %endif
  405. # Enforce 0644 for files and 0755 for directories
  406. # for the netdata web directory
  407. %defattr(0644,root,netdata,0755)
  408. %{_datadir}/%{name}/web
  409. # Enforce 0660 for files and 0770 for directories
  410. # for the netdata lib, cache and log dirs
  411. %defattr(0660,root,netdata,0770)
  412. %attr(0770,netdata,netdata) %dir %{_localstatedir}/cache/%{name}
  413. %attr(0755,netdata,root) %dir %{_localstatedir}/log/%{name}
  414. %attr(0770,netdata,netdata) %dir %{_localstatedir}/lib/%{name}
  415. %attr(0770,netdata,netdata) %dir %{_localstatedir}/lib/%{name}/registry
  416. # CUPS belongs to a different sub package
  417. %if 0%{?centos_ver} != 6 && 0%{?centos_ver} != 7
  418. %exclude %{_libexecdir}/%{name}/plugins.d/cups.plugin
  419. %package plugin-cups
  420. Summary: The Common Unix Printing System plugin for netdata
  421. Group: Applications/System
  422. Requires: cups >= 1.7
  423. Requires: netdata = %{version}
  424. %description plugin-cups
  425. This is the Common Unix Printing System plugin for the netdata daemon.
  426. Use this plugin to enable metrics collection from cupsd, the daemon running when CUPS is enabled on the system
  427. %files plugin-cups
  428. %attr(0750,root,netdata) %{_libexecdir}/%{name}/plugins.d/cups.plugin
  429. %endif
  430. %changelog
  431. * Mon Nov 04 2019 Konstantinos Natsakis <konstantinos.natsakis@gmail.com> 0.0.0-10
  432. - Fix /etc/netdata permissions
  433. * Mon Sep 23 2019 Konstantinos Natsakis <konstantinos.natsakis@gmail.com> 0.0.0-9
  434. - Do not build CUPS plugin subpackage on CentOS 6 and CentOS 7
  435. * Tue Aug 20 2019 Pavlos Emm. Katsoulakis <paul@netdat.acloud> - 0.0.0-8
  436. - Split CUPS functionality on separate package
  437. * Fri Jun 28 2019 Pavlos Emm. Katsoulakis <paul@netdata.cloud> - 0.0.0-7
  438. - Raise the path overrides to the spec file level, not just the configure.
  439. - Adjust tighter permissions on some folders, based on what we did on our installer
  440. - Introduce go.d plugin download and install, to include it on the package (Temporarily, to become separate package on next iteration)
  441. * Tue Jun 25 2019 Pavlos Emm. Katsoulakis <paul@netdata.cloud> - 0.0.0-6
  442. - Adjust dependency list: Some packages are missing on some distros, adopt to build successfully
  443. * Mon Jun 24 2019 Pavlos Emm. Katsoulakis <paul@netdata.cloud> - 0.0.0-5
  444. Another pass on cleaning up pre/post installation steps
  445. - Sync permission and ownership on files and directories
  446. * Sun Jun 16 2019 Pavlos Emm. Katsoulakis <paul@netdata.cloud> - 0.0.0-4
  447. First draft refactor on package dependencies section
  448. - Remove freeipmi/nfacct plugin flags. We auto-detect all plugins by decision
  449. - Start refactor of package dependencies
  450. - Add missing dependencies, with respect to distro peculiarities
  451. - Adjust existing dependencies, so that distro-specific package names is applied
  452. * Wed Jan 02 2019 Pawel Krupa <pkrupa@redhat.com> - 0.0.0-3
  453. - Temporary set version statically
  454. - Fix changelog ordering
  455. - Comment-out node.d configuration directory
  456. * Wed Jan 02 2019 Pawel Krupa <pkrupa@redhat.com> - 0.0.0-2
  457. - Fix permissions for log files
  458. * Sun Nov 15 2015 Alon Bar-Lev <alonbl@redhat.com> - 0.0.0-1
  459. - Initial add.