Blob Blame History Raw
%global selinux_types %(%{__awk} '/^#[[:space:]]*SELINUXTYPE=/,/^[^#]/ { if ($3 == "-") printf "%s ", $2 }' /etc/selinux/config 2>/dev/null)
%global selinux_variants %([ -z "%{selinux_types}" ] && echo mls targeted || echo %{selinux_types})

# real name
%define r_name radicale

Name:             radicale2
Version:          2.1.12
Release:          4%{?dist}
Summary:          A simple CalDAV (calendar) and CardDAV (contact) server
Group:            Applications/Internet
License:          GPLv3+
URL:              http://radicale.org
Source0:          https://github.com/Kozea/Radicale/archive/%{version}/%{r_name}-%{version}.tar.gz
Source1:          %{r_name}.service
Source2:          %{r_name}-logrotate
Source3:          %{r_name}-httpd
Source4:          %{r_name}.te
Source5:          %{r_name}.fc
Source6:          %{r_name}.if
Source7:          %{r_name}-tmpfiles.conf

Conflicts:        radicale < 2.0.0
Conflicts:        radicale >= 3.0.0

BuildArch:        noarch
%if "%{?rhel}" == "7"
BuildRequires:    python34-devel
BuildRequires:    python34-setuptools
%else
BuildRequires:    python3-devel
BuildRequires:    python3-setuptools
%endif
BuildRequires:    systemd
BuildRequires:    checkpolicy
BuildRequires:    selinux-policy-devel
BuildRequires:    hardlink

%if "%{?rhel}" == "7"
Requires:         python34-%{name} = %{version}-%{release}
%else
Requires:         python3-%{name} = %{version}-%{release}
%endif
Requires(pre):    shadow-utils
%{?systemd_requires}
Requires:         %{name} = %{version}-%{release}
%if "%{_selinux_policy_version}" != ""
Requires:         selinux-policy >= %{_selinux_policy_version}
%endif
Requires(post):   /usr/sbin/semodule
Requires(post):   /usr/sbin/fixfiles
Requires(post):   /usr/sbin/restorecon
%if 0%{?rhel}
Requires(post):   policycoreutils-python
%else
Requires(post):   policycoreutils-python-utils
%endif
Requires(postun): /usr/sbin/semodule
Requires(postun): /usr/sbin/fixfiles
Requires(postun): /usr/sbin/restorecon
%if 0%{?rhel}
Requires(postun): policycoreutils-python
%else
Requires(postun): policycoreutils-python-utils
%endif

%description
The Radicale Project is a CalDAV (calendar) and CardDAV (contact) server. It
aims to be a light solution, easy to use, easy to install, easy to configure.
As a consequence, it requires few software dependencies and is pre-configured
to work out-of-the-box.

The Radicale Project runs on most of the UNIX-like platforms (Linux, BSD,
MacOS X) and Windows. It is known to work with Evolution, Lightning, iPhone
and Android clients. It is free and open-source software, released under GPL
version 3.

This is major version 2 - which can't be upgraded inline from major version 1

%if "%{?rhel}" == "7"
%package -n python34-%{name}
%else
%package -n python3-%{name}
%endif
Summary:          A simple CalDAV (calendar) and CardDAV (contact) server
%if "%{?rhel}" == "7"
Requires:         python34-vobject >= 0.9.6
Requires:         python34-dateutil >= 2.7.3
%else
Requires:         python3-vobject
%endif
Provides:         python-%{name} = %{version}-%{release}
Obsoletes:        python-%{name} < %{version}-%{release}

%if "%{?rhel}" == "7"
%description -n python34-%{name}
%else
%description -n python3-%{name}
%endif
The Radicale Project is a CalDAV (calendar) and CardDAV (contact) server. It
aims to be a light solution, easy to use, easy to install, easy to configure.
As a consequence, it requires few software dependencies and is pre-configured
to work out-of-the-box.

The Radicale Project runs on most of the UNIX-like platforms (Linux, BSD,
MacOS X) and Windows. It is known to work with Evolution, Lightning, iPhone
and Android clients. It is free and open-source software, released under GPL
version 3.

%package httpd
Summary:        httpd config for Radicale
Requires:       %{name} = %{version}-%{release}
Requires:       httpd
%if "%{?rhel}" == "7"
Requires:       python34-mod_wsgi
%else
Requires:       python3-mod_wsgi
%endif

%description httpd
httpd example config for Radicale (Python3).

%prep
%autosetup -n Radicale-%{version}
mkdir SELinux
cp -p %{SOURCE4} %{SOURCE5} %{SOURCE6} SELinux

%build
%py3_build
cd SELinux
for selinuxvariant in %{selinux_variants}
do
    make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile
    mv %{r_name}.pp %{r_name}.pp.${selinuxvariant}
    make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
done
cd -

%install
%py3_install

# Install configuration files
mkdir -p %{buildroot}%{_sysconfdir}/%{r_name}/
install -p -m 640 config %{buildroot}%{_sysconfdir}/%{r_name}/
install -p -m 644 logging %{buildroot}%{_sysconfdir}/%{r_name}/
install -p -m 644 rights %{buildroot}%{_sysconfdir}/%{r_name}/

# Install wsgi file
mkdir -p %{buildroot}%{_datadir}/%{r_name}
sed -i 's|^#!/usr/bin/env python3$|#!/usr/bin/python3|' radicale.wsgi
sed -i 's|^#!/usr/bin/env python3$|#!/usr/bin/python3|' radicale.fcgi
install -p -m 755 radicale.wsgi %{buildroot}%{_datadir}/%{r_name}/
install -p -m 755 radicale.fcgi %{buildroot}%{_datadir}/%{r_name}/

# Install apache's configuration file
mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d/
install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/httpd/conf.d/%{r_name}.conf

# Create folder where the calendar will be stored
mkdir -p  %{buildroot}%{_sharedstatedir}/%{r_name}/

install -D -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{r_name}.service
install -D -p -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{r_name}
install -D -p -m 644 %{SOURCE7} %{buildroot}%{_tmpfilesdir}/%{r_name}.conf
mkdir -p %{buildroot}%{_localstatedir}/run/%{r_name}

mkdir -p %{buildroot}%{_localstatedir}/log/%{r_name}

for selinuxvariant in %{selinux_variants}
do
    install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
    install -p -m 644 SELinux/%{r_name}.pp.${selinuxvariant} \
        %{buildroot}%{_datadir}/selinux/${selinuxvariant}/%{r_name}.pp
done
/usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux

%pre
if [ $1 -gt 1 ]; then
	# Failsafe protection to prevent automatic upgrade from major version 1 to 2 resulting in non-working service
	version_major_existing=$(rpm -q --queryformat "%%{version}\n" %{r_name} | awk -F. '{ print $1 }' | sort -n | head -1)
	if [ -n "$version_major_existing" ]; then
		if [ $version_major_existing -lt 2 ]; then
			echo "*****************************************************"
			echo "* ERROR: radicale major version < 2 found on system *"
			echo "*        no automatic upgrade possible              *"
			echo "*        see http://radicale.org/1to2/              *"
			echo "*****************************************************"
			exit 1
		fi
	else
		echo "ERROR : older version of radicale installed, but major version can't be retrieved - failsafe check blocks update"
		exit 1
	fi
fi

getent group %{r_name} >/dev/null || groupadd -r %{r_name}
getent passwd %{r_name} >/dev/null || \
    useradd -r -g %{r_name} -d %{_sharedstatedir}/%{r_name} -s /sbin/nologin \
    -c "Radicale service account" %{r_name}
exit 0

%post
%systemd_post %{r_name}.service
for selinuxvariant in %{selinux_variants}
do
  /usr/sbin/semodule -s ${selinuxvariant} -i \
    %{_datadir}/selinux/${selinuxvariant}/%{r_name}.pp &> /dev/null || :
done
# http://danwalsh.livejournal.com/10607.html
semanage port -a -t radicale_port_t -p tcp 5232 &> /dev/null || :
/usr/sbin/fixfiles -R %{r_name} restore &> /dev/null || :
/usr/sbin/fixfiles -R %{r_name}-httpd restore &> /dev/null || :
/usr/sbin/fixfiles -R %{r_name}-httpd-python2 restore &> /dev/null || :
/usr/sbin/restorecon -R %{_localstatedir}/log/%{r_name} &> /dev/null || :

%preun
%systemd_preun %{r_name}.service

%postun
%systemd_postun_with_restart %{r_name}.service
if [ $1 -eq 0 ] ; then
  semanage port -d -p tcp 5232 &> /dev/null || :
  for selinuxvariant in %{selinux_variants}
  do
    /usr/sbin/semodule -s ${selinuxvariant} -r %{r_name} &> /dev/null || :
  done
  /usr/sbin/restorecon -R %{_localstatedir}/log/%{r_name} &> /dev/null || :
fi

%files
%doc README.md NEWS.md
%doc SELinux/*
%{_bindir}/%{r_name}
%dir %{_sysconfdir}/%{r_name}/
%config(noreplace) %attr(0640, root, %{r_name}) %{_sysconfdir}/%{r_name}/config
%config(noreplace) %{_sysconfdir}/%{r_name}/logging
%config(noreplace) %{_sysconfdir}/%{r_name}/rights
%config(noreplace) %{_sysconfdir}/logrotate.d/%{r_name}
%{_unitdir}/%{r_name}.service
%{_tmpfilesdir}/%{r_name}.conf
%dir %attr(750, %{r_name}, %{r_name}) %{_localstatedir}/log/%{r_name}
%dir %attr(750, %{r_name}, %{r_name}) %{_sharedstatedir}/%{r_name}/
%dir %{_datadir}/%{r_name}
%dir %attr(755, %{r_name}, %{r_name}) %{_localstatedir}/run/%{r_name}
%{_datadir}/selinux/*/%{r_name}.pp

%if "%{?rhel}" == "7"
%files -n python34-%{name}
%else
%files -n python3-%{name}
%endif
%license COPYING
%{python3_sitelib}/%{r_name}
%{python3_sitelib}/Radicale-*.egg-info

%files httpd
%{_datadir}/%{r_name}/%{r_name}.wsgi
%{_datadir}/%{r_name}/%{r_name}.fcgi
%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{r_name}.conf

%changelog
* Sat Sep 19 2020 Peter Bieringer <pb@bieringer.de> - 2.1.12-4
- Version 2.1.12
- Change package name to radicale2 while keeping everything else

* Sun Mar 10 2019 Peter Bieringer <pb@bieringer.de> - 2.1.11-3
- Version 2.1.11
- Set requirement for python34-dateutil >= 2.7.3
- Set requirement for python34-vobject >= 0.9.6

* Mon Oct 09 2017 Peter Bieringer <pb@bieringer.de> - 2.1.8-2
- Run in daemon mode so it creates the PID file (align with Fedora 27)
- Add failsafe check to prevent automatic upgrade from major version 1 to 2

* Sat Oct 07 2017 Peter Bieringer <pb@bieringer.de> - 2.1.8-1
- Version 2.1.8
- Align spec with Fedora 27 and adjust for EL7

* Fri May 05 2017 Juan Orti Alcaine <jorti@fedoraproject.org> - 1.1.2-1
- Version 1.1.2
- Security fix for CVE-2017-8342

* Fri Jan 08 2016 Juan Orti Alcaine <jorti@fedoraproject.org> - 1.1.1-1
- Update to 1.1.1 (#1296746)

* Fri Jan 01 2016 Juan Orti Alcaine <jorti@fedoraproject.org> - 1.1-1
- Version 1.1
- Unify epel and Fedora specs

* Wed Sep 23 2015 Peter Bieringer <pb@bieringer.de> - 1.0.1-2
- Fix policycore-utils and python-pam dependencies on el6/el7/fc22
- Switch conditionally back to python2 to support el6/el7

* Tue Sep 22 2015 Juan Orti Alcaine <jorti@fedoraproject.org> - 1.0.1-1
- Version 1.0.1

* Tue Sep 15 2015 Juan Orti Alcaine <jorti@fedoraproject.org> - 1.0-1
- Version 1.0
- Merge SELinux subpackage into the main package

* Mon Sep 07 2015 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.10-7
- Drop old _selinux_policy_version hack
- Require radicale-selinux

* Fri Jul 24 2015 Tomas Radej <tradej@redhat.com> - 0.10-6
- Updated dep on policycoreutils-python-utils

* Wed Jun 17 2015 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.10-5
- Switch to python3

* Thu Apr 09 2015 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.10-4
- Use license macro

* Mon Apr 06 2015 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.10-3
- Add patch1 to fix rhbz#1206813

* Tue Feb 24 2015 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.10-2
- Add radicale_var_run_t to SELinux policy 1.0.3

* Tue Jan 13 2015 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.10-1
- Version 0.10

* Mon Aug 18 2014 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.9-2
- Hide error when re-adding SELinux port label.

* Thu Aug 14 2014 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.9-1
- Version 0.9
- Automatically restart service if it dies.
- Update systemwide patch

* Mon Aug 04 2014 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-11
- Handle PID file.

* Thu Jul 17 2014 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-10
- Add network-online.target dependency. Bug #1119818

* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Tue Apr 29 2014 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-8
- Add PrivateDevices to unit file

* Wed Dec 25 2013 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-7
- SELinux policy 1.0.2

* Fri Nov 29 2013 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-6
- SELinux policy 1.0.1 fix bug #1035925

* Fri Nov 08 2013 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-5
- Hardcode _selinux_policy_version in F20 because of #999584

* Thu Oct 03 2013 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-4
- Update httpd config file and add SELinux policy. Bug #1014408

* Tue Aug 27 2013 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-3
- Move .wsgi and .fcgi to main package

* Sun Jul 21 2013 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-2
- BuildRequire python2-devel

* Thu Jul 18 2013 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.8-1
- Update to version 0.8
- Merge Till Maas's spec file. Bug #922276

* Mon Jul 08 2013 Juan Orti Alcaine <jorti@fedoraproject.org> - 0.7.1-1
- Initial packaging