3fab847
%global srcname carbon
c6b6051
%global commit0 d986e991dba085a1acbfbd2958989679b5d165c3
3fab847
%global shortcommit0 %(c=%{commit0}; echo ${c:0:7})
f876fbb
a22b616
# systemd service files introduced in Fedora 21 and EPEL 7.
b553d95
%if 0%{?fedora} || 0%{?rhel} >= 7
a22b616
%global with_systemd 1
c473bf7
%else
a22b616
%global with_systemd 0
c473bf7
%endif
c473bf7
62ab5f9
Name:           python-carbon
c6b6051
Version:        0.9.16
c6b6051
Release:        1%{?dist}
7df2f32
62ab5f9
Summary:        Back-end data caching and persistence daemon for Graphite
62ab5f9
License:        ASL 2.0
200281f
URL:            https://github.com/graphite-project/carbon
7df2f32
3fab847
Source0:        https://github.com/graphite-project/%{srcname}/archive/%{commit0}.tar.gz#/%{srcname}-%{shortcommit0}.tar.gz
d45531d
Source10:       carbon-aggregator.1
d45531d
Source11:       carbon-cache.1
d45531d
Source12:       carbon-client.1
d45531d
Source13:       carbon-relay.1
d45531d
Source14:       validate-storage-schemas.1
c473bf7
Source20:       %{name}.logrotate
a22b616
7ee660c
Source30:       carbon-aggregator.service
7ee660c
Source31:       carbon-cache.service
7ee660c
Source32:       carbon-relay.service
b373a60
Source33:       carbon-aggregator@.service
b373a60
Source34:       carbon-cache@.service
b373a60
Source35:       carbon-relay@.service
a22b616
a22b616
Source40:       %{name}-cache.init
a22b616
Source41:       %{name}-relay.init
a22b616
Source42:       %{name}-aggregator.init
a22b616
Source43:       %{name}.sysconfig
a22b616
200281f
# Set sane default filesystem paths.
b9b939a
Patch1:         %{name}-0.9.13-Set-sane-defaults.patch
200281f
# Fix path to storage-schemas.conf.
b9b939a
Patch2:         %{name}-0.9.13-Fix-path-to-storage-schemas.conf.patch
62ab5f9
62ab5f9
BuildArch:      noarch
3fab847
BuildRequires:  python2-devel
a22b616
BuildRequires:  python-setuptools
c6b6051
BuildRequires:  python-twisted-core
c6b6051
BuildRequires:  python-whisper
a22b616
a22b616
Requires:       python-twisted-core >= 8.0
a22b616
Requires:       python-whisper >= %{version}
a22b616
a22b616
Requires(pre):    shadow-utils
a22b616
%if %{with_systemd}
a22b616
BuildRequires:    systemd
a22b616
Requires(post):   systemd
a22b616
Requires(preun):  systemd
a22b616
Requires(postun): systemd
a22b616
%else
a22b616
Requires(post):   chkconfig
a22b616
Requires(preun):  chkconfig, initscripts
a22b616
%endif
62ab5f9
62ab5f9
62ab5f9
%description
d5bb1fe
Carbon is one of the components of Graphite, and is responsible for
d5bb1fe
receiving metrics over the network and writing them down to disk using
d5bb1fe
a storage back-end.
62ab5f9
62ab5f9
62ab5f9
%prep
200281f
%autosetup -p1 -n %{srcname}-%{commit0}
f8899e7
ce81c6e
sed -i '1s|^#!/usr/bin/env python|#!/usr/bin/python2|' lib/carbon/amqp_listener.py
ce81c6e
sed -i '1s|^#!/usr/bin/env python|#!/usr/bin/python2|' lib/carbon/amqp_publisher.py
ce81c6e
c473bf7
# Disable internal log rotation.
c473bf7
sed -i -e 's/ENABLE_LOGROTATION.*/ENABLE_LOGROTATION = False/g' \
c473bf7
    conf/carbon.conf.example
c473bf7
62ab5f9
62ab5f9
%build
200281f
%py2_build
62ab5f9
62ab5f9
62ab5f9
%install
200281f
%py2_install \
bd470d8
    --install-data=%{_localstatedir}/lib/carbon \
bd470d8
    --install-lib=%{python_sitelib} \
bd470d8
    --install-scripts=%{_bindir}
62ab5f9
c6d7495
rm -rf %{buildroot}%{_localstatedir}/lib/carbon/*
c6d7495
mkdir -p %{buildroot}%{_localstatedir}/lib/carbon/lists
c6d7495
mkdir -p %{buildroot}%{_localstatedir}/lib/carbon/rrd
c6d7495
mkdir -p %{buildroot}%{_localstatedir}/lib/carbon/whisper
1a2e51f
1a2e51f
# default config
1a2e51f
mkdir -p %{buildroot}%{_sysconfdir}/carbon
1a2e51f
install -D -p -m0644 conf/carbon.conf.example \
1a2e51f
    %{buildroot}%{_sysconfdir}/carbon/carbon.conf
77bd135
install -D -p -m0644 conf/storage-aggregation.conf.example \
77bd135
    %{buildroot}%{_sysconfdir}/carbon/storage-aggregation.conf
1a2e51f
install -D -p -m0644 conf/storage-schemas.conf.example \
1a2e51f
    %{buildroot}%{_sysconfdir}/carbon/storage-schemas.conf
62ab5f9
d45531d
# man pages
d45531d
mkdir -p %{buildroot}%{_mandir}/man1
d45531d
install -D -p -m0644 %{SOURCE10} %{buildroot}%{_mandir}/man1
d45531d
install -D -p -m0644 %{SOURCE11} %{buildroot}%{_mandir}/man1
d45531d
install -D -p -m0644 %{SOURCE12} %{buildroot}%{_mandir}/man1
d45531d
install -D -p -m0644 %{SOURCE13} %{buildroot}%{_mandir}/man1
d45531d
install -D -p -m0644 %{SOURCE14} %{buildroot}%{_mandir}/man1
d45531d
c473bf7
# log files
c473bf7
mkdir -p %{buildroot}%{_localstatedir}/log/carbon
c473bf7
install -D -p -m0644 %{SOURCE20} \
c473bf7
    %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
c473bf7
a22b616
# init scripts
a22b616
%if %{with_systemd}
a22b616
install -D -p -m0644 %{SOURCE30} \
7ee660c
    %{buildroot}%{_unitdir}/carbon-aggregator.service
7ee660c
install -D -p -m0644 %{SOURCE31} \
a22b616
    %{buildroot}%{_unitdir}/carbon-cache.service
7ee660c
install -D -p -m0644 %{SOURCE32} \
7ee660c
    %{buildroot}%{_unitdir}/carbon-relay.service
b373a60
install -D -p -m0644 %{SOURCE33} \
b373a60
    %{buildroot}%{_unitdir}/carbon-aggregator@.service
b373a60
install -D -p -m0644 %{SOURCE34} \
b373a60
    %{buildroot}%{_unitdir}/carbon-cache@.service
b373a60
install -D -p -m0644 %{SOURCE35} \
b373a60
    %{buildroot}%{_unitdir}/carbon-relay@.service
a22b616
%else
a22b616
mkdir -p %{buildroot}%{_localstatedir}/run/carbon
a22b616
install -Dp -m0755 %{SOURCE40} \
a22b616
    %{buildroot}%{_sysconfdir}/init.d/carbon-cache
a22b616
install -Dp -m0755 %{SOURCE41} \
a22b616
    %{buildroot}%{_sysconfdir}/init.d/carbon-relay
8d4d5ef
install -Dp -m0755 %{SOURCE42} \
a22b616
    %{buildroot}%{_sysconfdir}/init.d/carbon-aggregator
8d4d5ef
install -Dp -m0644 %{SOURCE43} \
a22b616
    %{buildroot}%{_sysconfdir}/sysconfig/carbon
a22b616
%endif
a22b616
f2d0354
# remove .py suffix
f2d0354
for i in %{buildroot}%{_bindir}/*.py; do
f2d0354
    mv ${i} ${i%%.py}
f2d0354
done
f2d0354
79cbf96
# fix permissions
79cbf96
chmod 755 %{buildroot}%{python_sitelib}/carbon/amqp_listener.py
79cbf96
chmod 755 %{buildroot}%{python_sitelib}/carbon/amqp_publisher.py
79cbf96
62ab5f9
c6b6051
%check
c6b6051
export PYTHONPATH=%{buildroot}%{python_sitelib}
c6b6051
trial carbon
c6b6051
c6b6051
62ab5f9
%pre
62ab5f9
getent group carbon >/dev/null || groupadd -r carbon
62ab5f9
getent passwd carbon >/dev/null || \
bd470d8
    useradd -r -g carbon -d %{_localstatedir}/lib/carbon \
62ab5f9
    -s /sbin/nologin -c "Carbon cache daemon" carbon
62ab5f9
a22b616
%post
a22b616
%if %{with_systemd}
7ee660c
%systemd_post carbon-aggregator.service
a22b616
%systemd_post carbon-cache.service
7ee660c
%systemd_post carbon-relay.service
a22b616
%else
a22b616
/sbin/chkconfig --add carbon-cache
a22b616
/sbin/chkconfig --add carbon-relay
a22b616
/sbin/chkconfig --add carbon-aggregator
a22b616
%endif
62ab5f9
62ab5f9
%preun
a22b616
%if %{with_systemd}
7ee660c
%systemd_preun carbon-aggregator.service
a22b616
%systemd_preun carbon-cache.service
7ee660c
%systemd_preun carbon-relay.service
a22b616
%else
a22b616
if [ $1 -eq 0 ]; then
62ab5f9
    /sbin/service carbon-cache stop >/dev/null 2>&1
62ab5f9
    /sbin/chkconfig --del carbon-cache
62ab5f9
    /sbin/service carbon-relay stop >/dev/null 2>&1
62ab5f9
    /sbin/chkconfig --del carbon-relay
62ab5f9
    /sbin/service carbon-aggregator stop >/dev/null 2>&1
62ab5f9
    /sbin/chkconfig --del carbon-aggregator
62ab5f9
fi
a22b616
%endif
62ab5f9
a22b616
%if %{with_systemd}
a22b616
%postun
7ee660c
%systemd_postun_with_restart carbon-aggregator.service
a22b616
%systemd_postun_with_restart carbon-cache.service
7ee660c
%systemd_postun_with_restart carbon-relay.service
a22b616
%endif
62ab5f9
62ab5f9
62ab5f9
%files
3fab847
%license LICENSE
3fab847
%doc README.md
df78127
%doc conf/ examples/ distro/redhat/init.d/
be09234
79cbf96
%dir %{_sysconfdir}/carbon
79cbf96
%config(noreplace) %{_sysconfdir}/carbon/carbon.conf
77bd135
%config(noreplace) %{_sysconfdir}/carbon/storage-aggregation.conf
79cbf96
%config(noreplace) %{_sysconfdir}/carbon/storage-schemas.conf
62ab5f9
c473bf7
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
c473bf7
79cbf96
%attr(0755,carbon,carbon) %dir %{_localstatedir}/lib/carbon
79cbf96
%attr(0755,carbon,carbon) %dir %{_localstatedir}/lib/carbon/lists
79cbf96
%attr(0755,carbon,carbon) %dir %{_localstatedir}/lib/carbon/rrd
79cbf96
%attr(0755,carbon,carbon) %dir %{_localstatedir}/lib/carbon/whisper
79cbf96
%attr(0755,carbon,carbon) %dir %{_localstatedir}/log/carbon
79cbf96
79cbf96
%{_bindir}/carbon-aggregator
79cbf96
%{_bindir}/carbon-cache
79cbf96
%{_bindir}/carbon-client
79cbf96
%{_bindir}/carbon-relay
79cbf96
%{_bindir}/validate-storage-schemas
79cbf96
d45531d
%{_mandir}/man1/carbon-aggregator.1*
d45531d
%{_mandir}/man1/carbon-cache.1*
d45531d
%{_mandir}/man1/carbon-client.1*
d45531d
%{_mandir}/man1/carbon-relay.1*
d45531d
%{_mandir}/man1/validate-storage-schemas.1*
d45531d
79cbf96
%{python_sitelib}/carbon
79cbf96
%{python_sitelib}/twisted
79cbf96
4b4b6de
%{python_sitelib}/carbon-*-py?.?.egg-info
4b4b6de
a22b616
%if %{with_systemd}
7ee660c
%{_unitdir}/carbon-aggregator.service
a22b616
%{_unitdir}/carbon-cache.service
7ee660c
%{_unitdir}/carbon-relay.service
b373a60
%{_unitdir}/carbon-aggregator@.service
b373a60
%{_unitdir}/carbon-cache@.service
b373a60
%{_unitdir}/carbon-relay@.service
a22b616
%else
a22b616
%dir %{_localstatedir}/run/carbon
a22b616
%{_sysconfdir}/init.d/carbon-*
a22b616
%config(noreplace) %{_sysconfdir}/sysconfig/carbon
a22b616
%endif
a22b616
62ab5f9
62ab5f9
%changelog
c6b6051
* Thu Apr 13 2017 Piotr Popieluch <piotr1212@gmail.com> - 0.9.16-1
c6b6051
- Update to 0.9.16
c6b6051
c6b6051
* Sun Sep 18 2016 Piotr Popieluch <piotr1212@gmail.com> - 0.9.15-6
ce81c6e
- Set correct interpreter for amqp listener and publiser
c7e1499
c7e1499
* Sun Sep 18 2016 Piotr Popieluch <piotr1212@gmail.com> - 0.9.15-5
df78127
- Add example init script to upstream, rhbz#1360469
b553d95
- Enable logrotate by default, fixes rhbz#1285727
b553d95
- Add storage-aggregation.conf, fixes rhbz#1285725
77bd135
- Update to newer package guidelines
77bd135
- Remove el5 support
77bd135
- Remove obsoleted macros
77bd135
- Update URL
77bd135
b373a60
* Wed Aug 03 2016 Piotr Popieluch <piotr1212@gmail.com> - 0.9.15-4
b373a60
- Add systemd unit files with instances
b373a60
7bddbdc
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.15-3
7bddbdc
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
7bddbdc
eada4c1
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.15-2
eada4c1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
eada4c1
6210c5f
* Sat Nov 28 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.9.15-1
6210c5f
- Update to new version
6210c5f
3fab847
* Sun Nov 08 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.9.14-1
3fab847
- Update to new version
3fab847
78cd72e
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.13-0.2.pre1
78cd72e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
78cd72e
b9b939a
* Mon Jan 19 2015 Piotr Popieluch <piotr1212@gmail.com> - 0.9.13-0.1.pre1
b9b939a
- update to 0.9.13-pre1
b9b939a
f8899e7
* Mon Nov 24 2014 Jamie Nguyen <jamielinux@fedoraproject.org> - 0.9.12-7
f8899e7
- patch setup.py to prevent installation of upstream init scripts
f8899e7
00cd1d4
* Fri Nov 14 2014 Jamie Nguyen <jamielinux@fedoraproject.org> - 0.9.12-6
00cd1d4
- conditionally define macros for EPEL 6 and below
00cd1d4
daf6ec1
* Wed Oct 01 2014 Jamie Nguyen <jamielinux@fedoraproject.org> - 0.9.12-5
daf6ec1
- update URL
daf6ec1
- improve description
daf6ec1
- use commit hash for Source URL
daf6ec1
- use loop to rename files
daf6ec1
- include README.md and examples/
daf6ec1
- amend patch for filesystem default paths
daf6ec1
- fix path to storage-schemas.conf
daf6ec1
- add man pages from Debian
daf6ec1
- disable internal log rotation and include logrotate configuration
daf6ec1
  for Fedora >= 21 and EPEL >= 7
daf6ec1
- be more explicit in %%files
daf6ec1
- include python egg
daf6ec1
- migrate to systemd on Fedora >= 21 and EPEL >= 7
daf6ec1
1fd9ebb
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.12-4
1fd9ebb
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
1fd9ebb
5047fa5
* Mon Sep 30 2013 Jonathan Steffan <jsteffan@fedoraproject.org> - 0.9.12-3
5047fa5
- Update default runtime user to carbon for carbon-aggregator and
5047fa5
  carbon-relay (RHBZ#1013813)
5047fa5
50a28e0
* Tue Sep 24 2013 Jonathan Steffan <jsteffan@fedoraproject.org> - 0.9.12-2
50a28e0
- Add strict python-whisper Requires (RHBZ#1010432)
50a28e0
- Don't cleanup user and user data on package remove (RHBZ#1010430)
50a28e0
14a8753
* Mon Sep 02 2013 Jonathan Steffan <jsteffan@fedoraproject.org> - 0.9.12-1
14a8753
- Update to 0.9.12
14a8753
524e134
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.10-4
524e134
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
524e134
bcabd8f
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.10-3
bcabd8f
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
bcabd8f
b793e8b
* Sat Nov 24 2012 Jonathan Steffan <jsteffan@fedoraproject.org> - 0.9.10-2
b793e8b
- Update spec to build on el5
b793e8b
- Fix python_sitelib definition
b793e8b
14a8753
* Wed May 30 2012 Jonathan Steffan <jsteffan@fedoraproject.org> - 0.9.10-1
62ab5f9
- Initial Package