+# TODO:
+# - Test it.
+# NOTE:
+# - consider split sqlite and apache to separate packages? Or only suggest them?
+
Summary: A Django webapp for enterprise scalable realtime graphing
Name: graphite-web
-Version: 0.9.10
-Release: 0.5
+Version: 0.9.15
+Release: 1
License: Apache v2.0
Group: Applications/WWW
-Source0: https://github.com/downloads/graphite-project/graphite-web/%{name}-%{version}.tar.gz
+Source0: https://github.com/graphite-project/graphite-web/archive/0.9.15/%{name}-%{version}.tar.gz
+# Source0-md5: f81c50b8b57672fc15a1cfe7bbae1c52
Source1: apache.conf
Source2: %{name}.logrotate
-Patch0: %{name}-0.9.10-fhs-thirdparty.patch
+Source3: local_settings.py
+Patch0: %{name}-kill-thirdparty-modules.patch
URL: https://launchpad.net/graphite/
-BuildRequires: python-devel
BuildRequires: rpm-pythonprov
-BuildRequires: rpmbuild(macros) >= 1.658
+BuildRequires: python-devel
+BuildRequires: rpmbuild(macros) >= 1.710
+Requires: apache-mod_alias
+Requires: apache-mod_authz_host
+Requires: apache-mod_log_config
Requires: apache-mod_wsgi
Requires: fonts-TTF-DejaVu
Requires: python-django
Requires: python-django_tagging >= 0.3
+Requires: python-modules-sqlite
Requires: python-pycairo
Requires: python-pyparsing
Requires: python-pytz
Requires: python-simplejson
-Requires: python-whisper
+Requires: python-whisper >= %{version}
Requires: webapps
+Conflicts: logrotate < 3.8.0
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%prep
%setup -q
-# Patch for Filesystem Hierarchy Standard
-# Remove thridparty libs
-# https://github.com/hggh/graphite-web-upstream/commit/47361a2707f904a8b817ca96deeddabcdbaaa534.patch
+# Kill strict use of thidparty subdir copies of python modules
%patch0 -p1
%build
-%{__python} setup.py build
+%py_build %{?with_tests:test}
%install
rm -rf $RPM_BUILD_ROOT
-%{__python} setup.py install \
- --skip-build \
- --optimize=2 \
- --root=$RPM_BUILD_ROOT
+# http://graphite.readthedocs.org/en/latest/install-source.html#installing-in-the-default-location
+%py_install \
+--prefix %{_prefix} \
+ --install-lib %{py_sitescriptdir} \
+ --install-data %{_datadir}/graphite
%py_postclean -x manage.py
# Create directories
-install -d $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}
-install -d $RPM_BUILD_ROOT%{_localstatedir}/log/%{name}
-install -d $RPM_BUILD_ROOT%{_sysconfdir}
+install -d $RPM_BUILD_ROOT{%{_sysconfdir},/etc/logrotate.d,%{_localstatedir}/{lib,log}/%{name}}
# Install some default configurations and wsgi
install -Dp conf/dashboard.conf.example $RPM_BUILD_ROOT%{_sysconfdir}/dashboard.conf
-mv $RPM_BUILD_ROOT{%{py_sitescriptdir}/graphite/local_settings.py.example,%{_sysconfdir}/local_settings.py}
+# mv $RPM_BUILD_ROOT{%{py_sitescriptdir}/graphite/local_settings.py.example,%{_sysconfdir}/local_settings.py}
+cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/local_settings.py
+
touch $RPM_BUILD_ROOT%{py_sitescriptdir}/graphite/local_settings.py{c,o}
-install -Dp conf/graphite.wsgi.example $RPM_BUILD_ROOT%{_datadir}/graphite/%{name}.wsgi
-install -Dp %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf
-install -Dp %{SOURCE2} $RPM_BUILD_ROOT/etc/logrotate.d/%{name}
+cp -p conf/graphite.wsgi.example $RPM_BUILD_ROOT%{_datadir}/graphite/%{name}.wsgi
+cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf
+cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/logrotate.d/%{name}
# Configure django /media/ location
sed -i 's|##PYTHON_SITELIB##|%{py_sitescriptdir}|' $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf
# Don't ship thirdparty
rm -r $RPM_BUILD_ROOT%{py_sitescriptdir}/graphite/thirdparty
+# Install django/httpd accessible DB
+touch $RPM_BUILD_ROOT/var/lib/graphite-web/graphite.db
+
%clean
rm -rf $RPM_BUILD_ROOT
%{py_sitescriptdir}/graphite/composer
%{py_sitescriptdir}/graphite/dashboard
%{py_sitescriptdir}/graphite/events
-%{py_sitescriptdir}/graphite/graphlot
%{py_sitescriptdir}/graphite/metrics
%{py_sitescriptdir}/graphite/render
%{py_sitescriptdir}/graphite/templates
%{py_sitescriptdir}/graphite/version
+%{py_sitescriptdir}/graphite/url_shortener
%{py_sitescriptdir}/graphite/whitelist
%{py_sitescriptdir}/graphite_web-%{version}-py*.egg-info
%attr(775,root,http) %dir %{_localstatedir}/log/%{name}
%attr(775,root,http) %dir %{_sharedstatedir}/%{name}
+%attr(640,http,http) %config(noreplace) %verify(not md5 mtime size) /var/lib/graphite-web/graphite.db