Blob Blame History Raw
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}


Name:		openxcap
Version:	2.0.1
Release:	2%{?dist}
Summary:	Fully featured XCAP server
Group:		System Environment/Daemons
License:	GPLv2
URL:		http://openxcap.org/
Source0:	http://download.ag-projects.com/XCAP/%{name}-%{version}.tar.gz
Source1:	%{name}.init
Source2:	%{name}.service
Source3:	%{name}.tmpfiles.conf
# Make openxcap compatible with python-pillow
# https://bugzilla.redhat.com/show_bug.cgi?id=895773
Patch0:		openxcap-pillow.patch

BuildArch:      noarch
BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires:	python-setuptools
Requires:	python >= 2.5
Requires:	MySQL-python >= 1.2.2
Requires:	python-application >= 1.2.8
Requires:	python-gnutls >= 1.1.9
Requires:	python-imaging >= 1.1.7
Requires:	python-lxml >= 2.0.7
Requires:	python-sqlobject
Requires:	python-twisted-core >= 8.1.0
Requires:	python-twisted-web >= 8.1.0
Requires:	python-twisted-web2 >= 8.1.0
Requires:	python-zope-interface

%if 0%{?fedora} > 17
# Users and groups
Requires(pre): shadow-utils
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
%else
Requires(post): chkconfig
Requires(preun): chkconfig
# This is for /sbin/service
Requires(preun): initscripts
%endif


%description
Fully featured XCAP server. An XCAP server is used by SIP SIMPLE clients and
servers to manage buddy lists and policy for subscriptions to presence or
other type of events published using SIP protocol.

XCAP protocol allows a client to read, write and modify application
configuration data stored in XML format on a server. XCAP maps XML document
sub-trees and element attributes to HTTP URIs, so that these components can
be directly accessed by HTTP. An XCAP server is used by the XCAP clients to
store data like Presence policy in combination with a SIP Presence server
that supports PUBLISH/SUBSCRIBE/NOTIFY methods to provide a complete SIP
SIMPLE server solution.


%prep
%setup -q
%patch0 -p1

%build
%{__python} -c 'import setuptools; execfile("setup.py")' build


%install
rm -rf %{buildroot}
%{__python} -c 'import setuptools; execfile("setup.py")' install --skip-build --root %{buildroot}
install -D -p -m 0644 config.ini.sample %{buildroot}%{_sysconfdir}/%{name}/config.ini
install -d %{buildroot}%{_sysconfdir}/%{name}/tls
install -D -p -m 0644 scripts/mysql-create-tables.sql %{buildroot}%{_datadir}/%{name}/mysql-create-tables.sql
install -D -p -m 0644 scripts/mysql-create-user.sql %{buildroot}%{_datadir}/%{name}/mysql-create-user.sql
install -d %{buildroot}%{_localstatedir}/run/%{name}
install -d %{buildroot}%{_localstatedir}/log/%{name}
%if 0%{?fedora} > 17
# install systemd files
install -D -m 0644 -p %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 0644 -p %{SOURCE3} %{buildroot}/usr/lib/tmpfiles.d/%{name}.conf
%else
install -D -p -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name}
%endif


%clean
rm -rf %{buildroot}


%pre
%if 0%{?fedora} > 17
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || \
useradd -r -g %{name} -d %{_localstatedir}/run/%{name} -s /sbin/nologin \
-c "OpenXCAP Server" %{name} 2>/dev/null || :
%endif

%post
%if 0%{?fedora} > 17
if [ $1 -eq 1 ] ; then
    # Initial installation
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%else
/sbin/chkconfig --add %{name}
%endif


%preun
%if 0%{?fedora} > 17
if [ $1 -eq 0 ] ; then
    # Package removal, not upgrade
    /bin/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || :
    /bin/systemctl stop %{name}.service > /dev/null 2>&1 || :
fi
%else
if [ $1 = 0 ]; then
 /sbin/service %{name} stop > /dev/null 2>&1
 /sbin/chkconfig --del %{name}
fi
%endif

%if 0%{?fedora} > 17
%triggerun -- %{name} < 2.0.1-1
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply opensips
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save %{name} >/dev/null 2>&1 ||:

# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
/bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :

chown -R %{name}:%{name} %{_sysconfdir}/%{name}
chown -R %{name}:%{name} %{_localstatedir}/run/%{name}
%endif

%files
%doc LICENSE PKG-INFO README TODO opensips/opensips.cfg
%dir %{_datadir}/%{name}
%{_bindir}/%{name}
%{_datadir}/%{name}/mysql-create-tables.sql
%{_datadir}/%{name}/mysql-create-user.sql
%{python_sitelib}/xcap
%{python_sitelib}/%{name}-%{version}-*.egg-info

%if 0%{?fedora} > 17
%dir %attr(0755, %{name}, %{name}) %{_localstatedir}/log/%{name}
%dir %attr(0755, %{name}, %{name}) %{_localstatedir}/run/%{name}
%dir %attr(0755, %{name}, %{name}) %{_sysconfdir}/%{name}
%dir %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/tls
%config(noreplace) %attr(0644, %{name}, %{name}) %{_sysconfdir}/%{name}/config.ini
%{_unitdir}/%{name}.service
/usr/lib/tmpfiles.d/%{name}.conf
%else
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/tls
%dir %{_localstatedir}/run/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/config.ini
%{_initrddir}/%{name}
%endif


%changelog
* Mon Feb  4 2013 Toshio Kuratomi <toshio@fedoraproject.org> - 2.0.1-2
- Patch to add compatibility with python-pillow (see rhbz #895773)

* Sat Aug 18 2012 Peter Lemenkov <lemenkov@gmail.com> - 2.0.1-1
- Ver. 2.0.1
- Switch to systemd
- Drop dependency on PyXML (see rhbz #844538)

* Fri Jul 20 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Wed Jul 21 2010 David Malcolm <dmalcolm@redhat.com> - 1.1.2-2
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Thu Sep 24 2009 Peter Lemenkov <lemenkov@gmail.com> - 1.1.2-1
- Initial package