# Needed for el5 %{!?_initddir: %global _initddir %{_sysconfdir}/rc.d/init.d} %global _hardened_build 1 Name: statsite Version: 0.7.1 Release: 2%{?dist} Summary: A C implementation of statsd Group: System Environment/Daemons # overall project is BSD, with exception of: # sinks/gmetric.py MIT License: BSD and MIT URL: https://github.com/armon/statsite Source0: https://github.com/armon/statsite/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz # Files are updated in master but not released yet Source1: https://raw.githubusercontent.com/armon/statsite/befda4e2c04632944238022064d0b45a1212291e/rpm/statsite.service # Issue https://github.com/armon/statsite/pull/177 Source2: https://raw.githubusercontent.com/piotr1212/statsite/ab7d3caabd6780c0911aebc5d0f06411de56a1a5/rpm/statsite.conf.example Source3: https://raw.githubusercontent.com/armon/statsite/483f772095a2559e7e40cddf9f1fcecd29c6212b/rpm/statsite.initscript Source4: %{name}.tmpfiles Source5: %{name}.sysconfig BuildRequires: scons BuildRequires: check-devel Requires(pre): shadow-utils %if 0%{?rhel} && 0%{?rhel} <= 6 Requires(post): chkconfig Requires(preun): chkconfig Requires(postun): initscripts %else BuildRequires: systemd Requires(post): systemd Requires(preun): systemd Requires(postun): systemd %endif # Needed for el5 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description Statsite is a metrics aggregation server. Statsite is based heavily on Etsy's StatsD https://github.com/etsy/statsd, and is wire compatible. %prep %setup -q -n %{name}-%{version} chmod +x sinks/statsite_json_sink.rb chmod +x sinks/gmetric.py %build export LDFLAGS="%{?__global_ldflags}" export CFLAGS="%{optflags}" make %{?_smp_mflags} %install # Needed for el5 rm -rf %{buildroot} %if 0%{?rhel} && 0%{?rhel} <= 6 mkdir -p %{buildroot}%{_localstatedir}/run/%{name} install -D -p -m 0755 %{SOURCE5} %{buildroot}%{_sysconfdir}/sysconfig/statsite %else install -D -p -m 0644 %{SOURCE4} %{buildroot}%{_tmpfilesdir}/%{name}.conf install -d -m 0755 %{buildroot}/%{_rundir}/%{name}/ %endif mkdir -p %{buildroot}%{_libexecdir}/%{name} cp -pr sinks %{buildroot}%{_libexecdir}/%{name} install -D -p -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf install -D -p -m0755 statsite %{buildroot}%{_sbindir}/%{name} %if 0%{?rhel} && 0%{?rhel} <= 6 install -D -p -m0755 %{SOURCE3} %{buildroot}%{_initddir}/%{name} %else install -D -p -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service %endif %check make test %pre getent group %{name} >/dev/null || groupadd -r %{name} getent passwd %{name} >/dev/null || \ useradd -r -g %{name} -d / -s /sbin/nologin \ -c "statsite daemon" %{name} exit 0 %post %if 0%{?rhel} && 0%{?rhel} <= 6 /sbin/chkconfig --add %{name} %else %systemd_post %{name}.service %endif %preun %if 0%{?rhel} && 0%{?rhel} <= 6 if [ $1 -eq 0 ] ; then /sbin/service %{name} stop >/dev/null 2>&1 /sbin/chkconfig --del %{name} fi %else %systemd_preun %{name}.service %endif %postun %if 0%{?rhel} && 0%{?rhel} <= 6 if [ "$1" -ge "1" ] ; then /sbin/service %{name} condrestart >/dev/null 2>&1 || : fi %else %systemd_postun_with_restart %{name}.service %endif %files %{!?_licensedir:%global license %%doc} %license LICENSE %doc CHANGELOG.md %doc README.md %doc rpm/statsite.conf.example %dir %{_sysconfdir}/%{name} %config(noreplace) %{_sysconfdir}/%{name}/statsite.conf %{_sbindir}/%{name} %{_libexecdir}/%{name}/sinks %if 0%{?rhel} && 0%{?rhel} <= 6 %{_initddir}/%{name} %attr(755, statsite, statsite) %dir %{_localstatedir}/run/%{name} %{_sysconfdir}/sysconfig/%{name} %else %{_unitdir}/%{name}.service %attr(755, statsite, statsite) %dir %{_rundir}/%{name} %{_tmpfilesdir}/%{name}.conf %endif %changelog * Thu Feb 04 2016 Piotr Popieluch - 0.7.1-2 - Update to comply with fedora package guidelines * Tue May 12 2015 Yann Ramin - 0.7.1-1 - Add a statsite user and group - Add systemd support * Fri Jul 18 2014 Gary Richardson - added missing __init__.py to spec file - fixed makefile for building RPMS * Tue May 20 2014 Marcelo Teixeira Monteiro - Added initscript and config file - small improvements * Wed Nov 20 2013 Vito Laurenza - Added 'sinks', which I overlooked initially. * Fri Nov 15 2013 Vito Laurenza - Initial release.