File iRony.spec of Package iRony-old

# 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:	    80%{?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

BuildArch:      noarch

Requires:       chwala >= 0.5.2
Requires:       roundcubemail(core) >= 1.3
%if 0%{?plesk} < 1
Requires:       roundcubemail-plugin-kolab_auth >= 3.3.6
%endif
Requires:       roundcubemail-plugin-kolab_folders >= 3.3.6
Requires:       roundcubemail-plugin-libcalendaring >= 3.3.6
Requires:       roundcubemail-plugin-libkolab >= 3.3.6
%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

%if 0%{?rhel} < 8
BuildRequires:  composer
%if 0%{?fedora}
# fix issue:
# have choice for php-composer(justinrainbow/json-schema) >= 2.0 needed by composer: php-justinrainbow-json-schema4 php-justinrainbow-json-schema
# have choice for php-composer(justinrainbow/json-schema) < 5 needed by composer: php-justinrainbow-json-schema4 php-justinrainbow-json-schema php-JsonSchema
BuildRequires:  php-justinrainbow-json-schema4
%endif

BuildRequires:  roundcubemail(core) >= 1.3
BuildRequires:  roundcubemail-plugins-kolab >= 3.3.6
%if 0%{?rhel} < 8
BuildRequires:  php-sabre-dav >= 2.1.11, php-sabre-dav < 3.0
BuildRequires:  php-sabre-event >= 2.0.2
BuildRequires:  php-sabre-http >= 3.0.5, php-sabre-http < 4.0
BuildRequires:  php-sabre-vobject >= 3.5.3
Requires:  php-sabre-dav >= 2.1.11, php-sabre-dav < 3.0
Requires:  php-sabre-http >= 3.0.5, php-sabre-http < 4.0
%endif

%if 0%{?fedora} >= 21
# Fedora 21 has qca2 and qca, qca2 has been renamed to qca, required by kdelibs
BuildRequires: qca
%endif
%endif

%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 vendor %{buildroot}/usr/share/%{name}
cp -a lib/Kolab %{buildroot}/usr/share/%{name}/lib/

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

rm -rf vendor/sabre/dav/bin/naturalselection
rm -rf vendor/sabre/dav/bin/googlecode_upload.py

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

%if 0%{?rhel} < 8
rm -rf vendor
ln -s ../roundcubemail/vendor vendor
%endif

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

# Fix upgrade path for `vendor` directory -> symlink change
%if 0%{?rhel} < 8
%pretrans -p <lua>
-- Define the path to directory being replaced below.
-- DO NOT add a trailing slash at the end.
path = "%{_datadir}/%{name}/vendor"
st = posix.stat(path)
if st and st.type == "directory" then
  status = os.rename(path, path .. ".rpmmoved")
  if not status then
    suffix = 0
    while not status do
      suffix = suffix + 1
      status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
    end
    os.rename(path, path .. ".rpmmoved")
  end
end
%endif

%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
* 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