%define name diamond %define version 4.0.832 %define unmangled_version 4.0.832 %define release 0 Summary: Smart data producer for graphite graphing package Name: %{name} Version: %{version} Release: %{release} Source0: %{name}-%{unmangled_version}.tar.gz License: MIT License Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot Prefix: %{_prefix} BuildArch: noarch Vendor: The Diamond Team Provides: diamond Requires: python python-configobj python-setuptools Url: https://github.com/python-diamond/Diamond BuildRequires: python python-configobj python-setuptools %description UNKNOWN %prep %setup -n %{name}-%{unmangled_version} %build python setup.py build %install %{__python} setup.py install -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES %if ! (0%{?fedora} > 12 || 0%{?rhel} > 5) %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %endif CONFIGFILES=" %config(noreplace) /etc/diamond/*" echo "$CONFIGFILES" | cat INSTALLED_FILES - > INSTALLED_FILES.new mv INSTALLED_FILES.new INSTALLED_FILES %clean rm -rf $RPM_BUILD_ROOT %pre getent group diamond > /dev/null || /usr/sbin/groupadd -r diamond getent passwd diamond > /dev/null || /usr/sbin/useradd -r -g diamond \ -d /var/lib/diamond -s /sbin/nologin diamond %post # add diamond service upon initial install if test "$1" = "1" ; then echo "Adding and activating diamond service" if chkconfig --add diamond ; then true else logger -p user.err -s -t %name -- "ERROR: Could not enable diamond service." exit 0 fi fi # always restart diamond if it was running if service diamond status > /dev/null 2>&1; then echo "Restarting diamond service because it was running." if ! service diamond restart ; then logger -p user.err -s -t %name -- "ERROR: Could not restart diamond service." exit 0 fi fi %preun # remove service only on final uninstall if test "$1" = "0" ; then if service diamond status > /dev/null 2>&1 ; then if ! service diamond stop ; then logger -p user.err -s -t "%{name}" -- "ERROR: Uninstall failed. Not able to stop service." exit 0 fi fi if chkconfig --del diamond ; then echo "Removed diamond service." else logger -p user.err -s -t "%{name}" -- "ERROR: Uninstall failed. Not able to remove service from services from management system." exit 0 fi fi %files -f INSTALLED_FILES %defattr(-,root,root)