File iRony.spec of Package iRony

# Needed for opensuse build system
%if 0%{?opensuse_bs}
#!BuildIgnore:  boa
#!BuildIgnore:  cherokee
#!BuildIgnore:  nginx
#!BuildIgnore:  httpd-itk
#!BuildIgnore:  lighttpd
#!BuildIgnore:  thttpd

#!BuildIgnore:  php-mysqlnd
%endif

%{!?php_inidir: %global php_inidir %{_sysconfdir}/php.d}

%if 0%{?suse_version} < 1 && 0%{?fedora} < 1 && 0%{?rhel} < 7
%global with_systemd 0
%else
%global with_systemd 1
%endif

%if 0%{?suse_version}
%global httpd_group www
%global httpd_name apache2
%global httpd_user wwwrun
%else
%if 0%{?plesk}
%global httpd_group roundcube_sysgroup
%global httpd_name httpd
%global httpd_user roundcube_sysuser
%else
%global httpd_group apache
%global httpd_name httpd
%global httpd_user apache
%endif
%endif

%global _ap_sysconfdir %{_sysconfdir}/%{httpd_name}

Name:           iRony
Version:        0.4.6
Release:	    4%{?dist}
Summary:        DAV for Kolab Groupware

Group:          Applications/Internet
License:        AGPLv3+
URL:            http://kolab.org

# From 7ebe1adc8b7c0f818d837d682b2b85202aac9303
Source0:        iRony-%{version}.tar.gz
Source1:        iRony.conf
Source2:        iRony.logrotate

Patch0:         0001-Remove-type-declaration-from-property.patch

BuildArch:      noarch

Requires:       chwala >= 0.5.2
Requires:       roundcubemail(core) >= 1.5

%if 0%{?suse_version}
Requires:       http_daemon
%else
Requires:       webserver
%endif

# Build requirements needed of *SUSE, which otherwise bails over
# dead-end symbolic links and/or files and directories not owned
# by any package.
BuildRequires:  chwala >= 0.5.2

BuildRequires:  roundcubemail(core) >= 1.5

%description
iRony is the CardDAV, CalDAV and WebDAV storage access provider for the
Kolab Groupware solution.

%prep
%setup -q

%build

%install
mkdir -p \
%if 0%{?plesk} < 1
    %{buildroot}/%{_ap_sysconfdir}/conf.d \
%endif
    %{buildroot}/%{_sysconfdir}/%{name} \
    %{buildroot}/%{_datadir}/%{name} \
    %{buildroot}/%{_localstatedir}/cache/%{name} \
    %{buildroot}/%{_localstatedir}/lib/%{name} \
    %{buildroot}/%{_localstatedir}/log/%{name}

%if 0%{?plesk} < 1
install -pm 644 %{SOURCE1} %{buildroot}/%{_ap_sysconfdir}/conf.d/%{name}.conf
%endif

mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
cp -pr %SOURCE2 %{buildroot}%{_sysconfdir}/logrotate.d/iRony

sed -i \
    -e 's/apache apache/%{httpd_user} %{httpd_group}/g' \
    %{buildroot}%{_sysconfdir}/logrotate.d/iRony

mkdir %{buildroot}/usr/share/%{name}/lib

cp -a public_html %{buildroot}/usr/share/%{name}
cp -a lib/Kolab %{buildroot}/usr/share/%{name}/lib/

pushd %{buildroot}/%{_datadir}/%{name}

ln -s ../../..%{_localstatedir}/cache/%{name} temp
ln -s ../../..%{_localstatedir}/log/%{name} logs

mkdir config
pushd config
ln -s ../../../..%{_sysconfdir}/%{name}/dav.inc.php
ln -s ../../../..%{_sysconfdir}/roundcubemail/defaults.inc.php
ln -s ../../../..%{_sysconfdir}/roundcubemail/config.inc.php
popd

ln -s ../roundcubemail/vendor vendor

rm -rf lib/Roundcube
pushd lib/
ln -s ../../chwala/lib FileAPI
ln -s ../../roundcubemail/program/lib/Roundcube Roundcube
ln -s ../../roundcubemail/plugins plugins
popd

popd

install -pm 640 config/dav.inc.php.sample %{buildroot}/%{_sysconfdir}/%{name}/dav.inc.php

%pretrans
# upgrade path for `vendor` directory -> symlink change. It's a vendor directory, so we don't do the rpmmoved dance.
if [ -d "/usr/share/iRony/vendor" -a ! -L "/usr/share/iRony/vendor" ]; then
    rm -rf /usr/share/iRony/vendor
fi


%post
if [ -f "/etc/php.d/apc.ini" -o -f "%{php_inidir}/apcu.ini" ]; then
    if [ ! -z "`grep ^apc.enabled=1 /etc/php.d/apc{,u}.ini 2>/dev/null`" ]; then
        /sbin/service httpd condrestart
    fi
fi

%files
%doc README.md
%if 0%{?plesk} < 1
%config(noreplace) %{_ap_sysconfdir}/conf.d/%{name}.conf
%endif
%attr(0755,root,%{httpd_group}) %dir %{_sysconfdir}/%{name}
%attr(0644,root,%{httpd_group}) %config(noreplace) %{_sysconfdir}/%{name}/dav.inc.php
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}

%{_datadir}/%{name}

%attr(0770,%{httpd_user},%{httpd_group}) %{_localstatedir}/cache/%{name}
%attr(0770,%{httpd_user},%{httpd_group}) %{_localstatedir}/lib/%{name}
%attr(0770,%{httpd_user},%{httpd_group}) %{_localstatedir}/log/%{name}

%changelog
* Wed Dec 28 2022 Christoph Erhardt <kolab@sicherha.de> - 0.4.6-4
- Fix compatibility with PHP < 7.4.0 (T7097)

* Mon Dec 19 2022 Christian Mollekopf <mollekopf@apheleia-it.ch> - 0.4.6-3
- Updated tarball

* Sat Feb 12 2022 Christoph Erhardt <kolab@sicherha.de> - 0.4.6-2
- Fix transaction error on upgrade

* Sat Dec 25 2021 Christian Mollekopf <mollekopf@kolabsys.com> - 0.4.5-2
- Fixed configuration directory permissions
- Link to roundcubemail vendor directory in ootpa

* Mon Oct 19 2020 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.4.5-1
- Release of version 0.4.5

* Fri Oct 16 2020 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.4.4-1
- Release of version 0.4.4

* Thu Jan 16 2020 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.4.3-1
- Release of version 0.4.3

* Tue Apr 23 2019 Christian Mollekopf (Kolab Systems) <mollekopf@kolabsys.com> - 0.4.2-4
- Support shortlogins via the username_domain configuration option

* Thu Apr 11 2019 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.4.2-2
- Avoid referring to kolab_auth if it isn't actually installed

* Thu Mar 14 2019 Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> - 0.4.2-1
- Release 0.4.2

* Wed Jun 20 2018 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.4.1-2
- Fix marking httpd's conf.d/iRony.conf file as a configuration file not
  to be replaced by package updates
- Require a more narrow range of Sabre packages

* Wed Jun 13 2018 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.4.1-1
- Release of version 0.4.1

* Thu May 25 2017 Timotheus Pokorra <tp@tbits.net> - 0.4.0-3
- Fix build error on Fedora 25, composer needs php-justinrainbow-json-schema4

* Wed May 10 2017 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.4.0-2
- Fix log rotation on Plesk

* Tue May  2 2017 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.4.0-1
- Release of version 0.4.0

* Thu Jan  8 2015 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.3.0-1
- Release of version 0.3.0

* Thu Jan  8 2015 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.9-1
- Release of version 0.2.9
- Fixes bugs #2442, #2787, #2788, #2973, #3049, #3059, #3496,
  #3537, #3598, #3739, #3776, #3837, #4128, #4129

* Thu Apr  3 2014 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.8-1
- New snapshot

* Tue Feb 11 2014 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.7-1
- Fix memory usage on very large result sets (#2827)

* Thu Jan  9 2014 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.6-1
- New upstream release

* Sat Nov 30 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.5-1
- New upstream release

* Tue Nov 26 2013 Daniel Hoffend <dh@dotlan.net> - 0.2.4-3
- Added logrotate script

* Mon Nov 11 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.4-2
- Expect a list of spouses (#2473)

* Fri Nov  1 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.4-1
- New upstream version

* Tue Oct 29 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.3-3
- Require "http_daemon" (*SUSE) or "webserver"

* Wed Oct 16 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.3-2
- Ship fix for #2335

* Tue Oct  8 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.3-1
- New upstream version

* Thu Sep 19 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.1-1
- New upstream release 0.2.1, resolves;

    2238 Custom field data gets lost when updating an object in Roundcube
    2239 Error when saving a task with alarms

* Wed Sep 11 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.2.0-1
- Upstream release 0.2.0

* Wed Sep  4 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.1-0.10
- Ship fix for #2109

* Fri Jul 12 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.1-0.8
- Remove duplicate vendorized libs
- Correct permissions on temp/ and logs/ directory, and create the links
- A second version of iRony

* Tue May  7 2013 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 0.1-0.3
- A first version of iRony