Blob Blame History Raw
# Needed for el5
%{!?_initddir: %global _initddir %{_sysconfdir}/rc.d/init.d}

%global _hardened_build 1
%global commit 38fac767bf35aa6ecc4f9ea0c8861607325789bf

Name:               carbon-c-relay
Version:            0.44
Release:            3%{?dist}
Summary:            Enhanced C implementation of Carbon relay, aggregator and rewriter
License:            ASL 2.0
Group:              System Environment/Daemons
URL:                https://github.com/grobian/carbon-c-relay
Source0:            https://github.com/grobian/carbon-c-relay/archive/%{commit}.tar.gz#/%{name}-%{commit}.tar.gz
Source1:            carbon-c-relay.service
Source2:            carbon-c-relay.init
Source3:            carbon-c-relay.logrotate
Source4:            carbon-c-relay.sysconfig
Source5:            carbon-c-relay.conf

Requires(pre):      shadow-utils

%if 0%{?rhel} && 0%{?rhel} <= 6
Requires:           daemonize
Requires(post):     chkconfig
Requires(preun):    chkconfig
Requires(postun):   initscripts
%else
BuildRequires:      systemd
Requires(post):     systemd
Requires(preun):    systemd
Requires(postun):   systemd
%endif

# carbon-c-relay ships a bundled md5 library for which an exception exists
# see: https://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries
Provides:           bundled(md5-peslyak)

BuildRoot:          %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

# Does not build on old 32bit architectures (el5)
# https://github.com/grobian/carbon-c-relay/issues/100
ExcludeArch:        i386 ppc


%description
Carbon-like Graphite line mode relay. This project aims to be a replacement of 
the original Carbon relay. The main reason to build a replacement is 
performance and configurability. Carbon is single threaded, and sending 
metrics to multiple consistent-hash clusters requires chaining of relays. This 
project provides a multithreaded relay which can address multiple targets and 
clusters for each and every metric based on pattern matches.


%prep
%setup -q -n %{name}-%{commit}


%build
make %{?_smp_mflags} CFLAGS="%{optflags}" relay


%install
rm -rf %{buildroot}
install -Dp -m0755 relay %{buildroot}%{_bindir}/carbon-c-relay
install -Dp -m0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/carbon-c-relay
install -Dp -m0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/carbon-c-relay.conf

%if 0%{?rhel} && 0%{?rhel} <= 6
mkdir -p %{buildroot}%{_localstatedir}/log/carbon-c-relay
mkdir -p %{buildroot}%{_localstatedir}/run/carbon-c-relay
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
install -Dp -m0755 %{SOURCE2} %{buildroot}%{_initddir}/%{name}
install -Dp -m0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%else
install -Dp -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
%endif


%pre
getent group carbon-c-relay >/dev/null || groupadd -r carbon-c-relay
getent passwd carbon-c-relay >/dev/null || \
    useradd -r -g carbon-c-relay -d / -s /sbin/nologin \
    -c "Carbon cache daemon" carbon-c-relay
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}
%doc README.md
%license LICENSE.md
%{_bindir}/carbon-c-relay
%config(noreplace) %{_sysconfdir}/carbon-c-relay.conf
%config(noreplace) %{_sysconfdir}/sysconfig/carbon-c-relay

%if 0%{?rhel} && 0%{?rhel} <= 6
%{_initddir}/%{name}
%attr(0755,carbon-c-relay,carbon-c-relay) %dir %{_localstatedir}/log/%{name}
%attr(0755,carbon-c-relay,carbon-c-relay) %dir %{_localstatedir}/run/%{name}
%{_sysconfdir}/logrotate.d/%{name}
%else
%{_unitdir}/%{name}.service
%endif


%changelog
* Mon Aug 31 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.44-3
- Exclude 32 bit arches

* Sun Aug 30 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.44-2
- Add el5 support

* Fri Aug 14 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.44-1
- Update to upstream 0.44
- Use own relay.conf

* Mon Jul 27 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.43-2
- specify copylib 'Provides: bundled(md5-peslyak)'

* Mon Jul 27 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.43-1
- Update to upstream 0.43

* Mon Jul 27 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.42-2
- Removed obsoleted BR: openssl-devel

* Fri Jul 24 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.42-1
- Update to upstream 0.42
- Remove allow-percent patch, characters are now configurable
- Make characters to allow configurable in sysconfig

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.40-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Tue May 12 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.40-1
- update to upstream 0.40
- add logfile to sysconfig

* Fri May 01 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.39-3
- update to later commit to fix closed udp sockets
- logrotate sighup instead of restart
- allow percent characters in metric names

* Thu Apr 02 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.39-2
- fix filepath in logrotate

* Sat Mar 28 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.39-1
- update to latest upsream 0.39

* Wed Feb  4 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.37-1
- update to upstream 0.37
- rewritten for Fedora and comply with Fedora package guidelines

* Mon Sep 8 2014 Matthew Hollick <matthew@mayan-it.co.uk>
- tidy up for github
- reverted site specific changes

* Fri Aug 8 2014 Matthew Hollick <matthew@mayan-it.co.uk>
- packaged as part of twiki

* Tue Jul 1 2014 Matthew Hollick <matthew@mayan-it.co.uk>
- packaged as part of mdr
- binary renamed from 'relay' to 'cc_relay'
- pagage renamed to reflect function rather than component
- user / group named by function

* Tue May 6 2014 Matthew Hollick <matthew@mayan-it.co.uk>
- Initial package for the BBC