]> arthur.barton.de Git - netdata.git/commitdiff
update spec file to support EL6
authorJason Barnett <jason.w.barnett@gmail.com>
Tue, 26 Jul 2016 13:30:49 +0000 (09:30 -0400)
committerJason Barnett <jason.w.barnett@gmail.com>
Tue, 26 Jul 2016 13:36:14 +0000 (09:36 -0400)
netdata.spec.in

index 13c047968b0061670c59a566b0f04f72e94aa147..4e826985707807c857c845319b72fff39b80ae2e 100644 (file)
@@ -1,7 +1,8 @@
+%define contentdir %{_datadir}/netdata
 #
 # Conditional build:
-%bcond_without systemd         # systemd
-%bcond_without nfacct          # build with nfacct plugin
+%bcond_without  systemd  # systemd
+%bcond_with     nfacct   # build with nfacct plugin
 
 %if 0%{?fedora} || 0%{?rhel} >= 7
 %else
@@ -19,16 +20,24 @@ URL:                http://netdata.firehol.org/
 BuildRequires: pkgconfig
 BuildRequires: xz
 BuildRequires: zlib-devel
+
+# Packages can be found in the EPEL repo
 %if %{with nfacct}
 BuildRequires: libmnl-devel
 BuildRequires: libnetfilter_acct-devel
 %endif
+
+Requires(pre): /usr/sbin/groupadd
+Requires(pre): /usr/sbin/useradd
+
 %if %{with systemd}
-BuildRequires:         systemd
-Requires(post):                systemd
-Requires(preun):       systemd
-Requires(postun):      systemd
+Requires(preun):  systemd-units
+Requires(postun): systemd-units
+Requires(post):   systemd-units
+%else
+Requires(post):   chkconfig
 %endif
+
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
@@ -46,7 +55,6 @@ happened, on your systems and applications.
 
 %build
 %configure \
-       --docdir=%{_docdir}/%{name}-%{version} \
        --with-zlib \
        --with-math \
        %{?with_nfacct:--enable-plugin-nfacct} \
@@ -65,13 +73,20 @@ find $RPM_BUILD_ROOT -name .keep | xargs -r rm
 %if %{with systemd}
 install -d $RPM_BUILD_ROOT%{_unitdir}
 install -m 644 -p system/netdata.service $RPM_BUILD_ROOT%{_unitdir}/netdata.service
+%else
+# install SYSV init stuff
+mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
+install -m755 system/netdata-init-d \
+        $RPM_BUILD_ROOT/etc/rc.d/init.d/netdata
 %endif
 
+%if %{with systemd}
 %pre
-getent group netdata > /dev/null || groupadd -r netdata
-getent passwd netdata > /dev/null || useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
+# Add the "netdata" user
+/usr/sbin/groupadd -r netdata 2> /dev/null || :
+/usr/sbin/useradd -c "netdata" -g netdata \
+        -s /sbin/nologin -r -d %{contentdir} netdata 2> /dev/null || :
 
-%if %{with systemd}
 %post
 %systemd_post netdata.service
 
@@ -80,6 +95,24 @@ getent passwd netdata > /dev/null || useradd -r -g netdata -c netdata -s /sbin/n
 
 %postun
 %systemd_postun_with_restart netdata.service
+%else
+%pre
+# Add the "netdata" user
+getent group netdata >/dev/null || groupadd -r netdata
+getent passwd netdata >/dev/null || \
+  useradd -r -g netdata -s /sbin/nologin \
+    -d %{contentdir} -c "netdata" netdata
+exit 0
+
+%post
+# Register the netdata service
+/sbin/chkconfig --add netdata
+
+%preun
+if [ $1 = 0 ]; then
+        /sbin/service netdata stop > /dev/null 2>&1
+        /sbin/chkconfig --del netdata
+fi
 %endif
 
 %clean
@@ -88,18 +121,29 @@ rm -rf $RPM_BUILD_ROOT
 %files
 %attr(-,netdata,netdata) %dir %{_localstatedir}/cache/%{name}
 %attr(-,netdata,netdata) %dir %{_localstatedir}/log/%{name}
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/*.conf
+%config(noreplace) %{_sysconfdir}/%{name}/*.conf
+%config(noreplace) %{_sysconfdir}/%{name}/python.d/*.conf
 %dir %{_sysconfdir}/%{name}
 %{?with_systemd:%{_unitdir}/netdata.service}
 %{_libexecdir}/%{name}
 %{_sbindir}/%{name}
 %dir %{_datadir}/%{name}
 
+%if %{with systemd}
+%else
+%{_sysconfdir}/rc.d/init.d/netdata
+%endif
+
 # override defattr for web files
 %defattr(644,root,netdata,755)
 %{_datadir}/%{name}/web
 
 %changelog
+* Tue Jul 26 2016 Jason Barnett <J@sonBarnett.com> - 1.2.0-2
+- Added support for EL6
+- Corrected several Requires statements
+- Changed default to build without nfacct
+- Removed --docdir from configure
 * Mon May 16 2016 Costa Tsaousis <costa@tsaousis.gr> - 1.2.0-1
 - netdata is now 30% faster.
 - netdata now has a registry (my-netdata menu on the dashboard).