File owncloud-client.spec of Package owncloud-client

#
# spec file for package owncloud-client
#
# Copyright (c) 2012 ownCloud, inc.; Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes, issues or comments via http://github.com/owncloud/
#

## Caution: This spec file exists in multiple locations. Keep in sync:
##  isv:ownCloud:desktop
##  isv:ownCloud:community:nightly
##  isv:ownCloud:community:testing
##  github.com/owncloud/administration/jenkins/obs_integration/templates/client/v1_8_1/SHORTNAME-client.spec.in
##  -> you can modify it in testing, and play around for a while, but then merge into the copy on
##     github, which is authorative for the branded clients.
##
## created by: ./genbranding.pl (V1.13) -o -p isv:ownCloud:desktop owncloudclient-2.2.4.tar.xz ownCloud.tar.xz

## One specfile to rule them all:
##  versions 1.6.x or 1.7.x, released or prerelease versions. All rpm based platforms.
##  testing, branding, whatever.
##

%_oc_package_header
%_use_oc_qt5_as_default
%define use_devtoolset 0
%if 0%{?el6} || 0%{?el7}
%define use_devtoolset 1
%endif

Name:           owncloud-client

# Use translations from an external tarball in the package, or build them
# using the Qt tools? For distros where we do not have the tools, disable.

%include %{_sourcedir}/common.inc

%if 0%{?centos_version} == 600 || 0%{?rhel_version} == 600 || 0%{?fedora_version} || "%{prerelease}" == ""
# For beta and rc versions we use the ~ notation, as documented in
# http://en.opensuse.org/openSUSE:Package_naming_guidelines
# Some distro's (centos_6) don't allow ~ characters. There we follow the Fedora guidelines,
# which suggests massaging the buildrelease number.
# Otoh: for openSUSE, this technique is discouraged by the package naming guidelines.
Version:       	2.6.1
%if "" == ""
Release:        2071
%else
# CI_CNT should correspond to BUILD_NUMBER
Release:       	0.<CI_CNT>.<B_CNT>.
%endif
%else
Version:       	2.6.1~
Release:        2071
%endif

License:        GPL-2.0+
Summary:        ownCloud
Url:            https://github.com/owncloud/client
Group:          Productivity/Networking/Other
Source0:        owncloudclient-2.6.1.13407.tar.bz2

Source2:        fix_theme_250.sh
Source3:        99-sync-inotify.conf
Source4:        README.UPDATE.txt

%if 0%{?rhel_version} || 0%{?centos_version} || 0%{?suse_version} == 1110
Patch1:         autostart_use_wrapper.diff
%endif

%if "%{name}" != "owncloud-client" || (0%{?is_opensuse} && 0%{?suse_version} >= 1315 && 0%{?sle_version} > 120100)
# openSUSE_Leap_42.2 or branded client
# (suse_version==1320 is also incorrectly covered here. That is fine, as 13.2 is no longer supported.)
# https://github.com/owncloud/ownbrander/issues/715
# https://github.com/owncloud/enterprise/issues/3318
Patch2:         no_icon_substitution.diff
%endif

# % if 0% {?is_opensuse} && 0% {?suse_version} == 1315 && 0% {?sle_version} == 120200
# # openSUSE_Leap_42.2 only, https://github.com/owncloud/client/issues/5960#issuecomment-322406761
# Patch3:         OWNCLOUD_FORCE_QDBUS_TRAY_WORKAROUND.patch
# % endif

%if 0%{?el6} || 0%{?el7}
Patch5:         sqlite3-no-DETERMINISTIC-compat.diff
%endif

%global cmake_args %nil


# default to have docs, only disable for RHEL/CentOS 6
# global disable for now. all RPMs fail: make: *** No rule to make target 'doc'.  Stop
%define have_doc 0
%if 0%{?el6} || 0%{?rhel_version} == 700 || 0%{?centos_version} == 700 || (0%{?suse_version} && ! 0%{?is_opensuse})
%define have_doc 0
%endif
# https://github.com/owncloud/client/issues/2153
%define have_man 0


# The infamous SUSE matrix:
# -------------------------
# Sorted by 'suse_version'.
#
#                       is_opensuse     suse_version    sle_version
# openSUSE_13.1                         1310
# SLE_12                                1315            120000
# SLE_12_SP1                            1315            120100
# openSUSE_Leap_42.1    1               1315            120100
# openSUSE_Leap_42.2    1               1315            120200
# openSUSE_Leap_42.3    1               1315            120300
# openSUSE_13.2                         1320
# openSUSE_Factory      1               1330
# openSUSE_Tumbleweed   1               1330
# openSUSE_Leap_15.0    1               1500            150000
# openSUSE_Leap_15.1    1               1500            150100



######################################################################### BuildRequires only below here.

BuildRequires:  cmake >= 2.8.11

BuildRequires:  ocqt5125-filesystem
BuildRequires:  ocqt5125-qt5keychain-devel >= 0.7.0, ocqt5125-qt5keychain1 >= 0.7.0
BuildRequires:  ocqt5125-libQt5Core-devel
BuildRequires:  ocqt5125-libQt5Gui-devel
BuildRequires:  ocqt5125-libQt5Network-devel
BuildRequires:  ocqt5125-libQt5Xml-devel
BuildRequires:  ocqt5125-libQt5PrintSupport-devel
BuildRequires:  ocqt5125-libQt5DBus-devel
BuildRequires:  ocqt5125-libQt5Concurrent-devel
# BuildRequires:  ocqt5125-libqt5-linguist-devel
# HACK: Fix qttools spec file
BuildRequires:  ocqt5125-libqt5-linguist
# Needed by https://github.com/owncloud/client/issues/6036
BuildRequires:  ocqt5125-libqt5-qtsvg-devel

%if 0%{?use_devtoolset}
BuildRequires: devtoolset-4-gcc-c++
%else
%if 0%{?is_opensuse} && (0%{?sle_version} == 120100 || 0%{?sle_version} == 120200 || 0%{?sle_version} == 120300)
# Bug alert: openSUSE_Leap 42.1, 42.2, 42.3 install gcc 4.8.5 when we require gcc, although they all have newer compilers too.
# This bug is half fixed in Leap 15.0, there gcc installs 7.2.1, and gcc8 is no longer available, although it was available in Leap 42.3.
%if 0%{?sle_version} == 120100
# We can ask for gcc5 explicitly to get version 5.3.1
BuildRequires: gcc5-c++
%endif
%if 0%{?sle_version} == 120200
# We can ask for gcc6 explicitly to get version 6.2.1
BuildRequires: gcc6-c++ -libgcc_s1
%endif
%if 0%{?sle_version} == 120300
# We can ask for gcc7 explicitly to get version 7.3.1
BuildRequires: gcc7-c++
%endif
%else
BuildRequires: gcc gcc-c++
%endif
%endif

%if 0%{?centos_version} == 600
BuildRequires: ocqt5125-libxkbcommon-x11-0
%endif
%if 0%{?centos_version}
BuildRequires: ocqt5125-libsqlite3-0 >= 3.9.0
%endif

BuildRequires:  openssl-devel
BuildRequires:  zlib-devel
BuildRequires:  desktop-file-utils

# SUSE specific stuff
%if 0%{?suse_version}
BuildRequires:  update-desktop-files
BuildRequires:  libopenssl-devel
%endif

# Version independant package name mapping between suse and fedora/centos
%if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
%if 0%{?centos_version}
BuildRequires:  ocqt5125-sqlite3-devel
%else
BuildRequires:  sqlite-devel >= 3.9.0
%endif
BuildRequires:  desktop-file-utils
%if %have_doc
BuildRequires:  python-sphinx
# sphinx fails on Fedora 25: https://github.com/owncloud/client/issues/5355
BuildRequires: python
%endif
%else
# Documentation
%if 0%{have_doc}
BuildRequires:  python-Sphinx
%endif
%if 0%{?suse_version} == 1315
BuildRequires:  ocqt5125-sqlite3-devel
%else
BuildRequires:  sqlite3-devel >= 3.9.0
%endif
BuildRequires:  update-desktop-files
%endif
%if 0%{?fedora_version} > 30 || 0%{?sle_version} > 150200
# fedora 30 has only 0.2.5
# opensuse leap 15.2 still has only 0.2.5
BuildRequires:  libcloudproviders-devel >= 0.3.0
%endif
%if 0%{?centos_version} >= 800
BuildRequires:  gdb
%endif


######################################################################### Requires only below here.

%if 0%{?centos_version} > 700 || 0%{?suse_version} || 0%{?rhel_version} > 700
# CentOS-6, CentOS-7, RHEL_6,7 don't have Suggests.
# We can do Requires for the nautilus caja and nemo extensions, as they do not pull in any further dependencies.
# We do not want a Requires for the dolphin extension, as this may pull system libQt5Core via Autoreqprov.
Suggests:   %{name}-nautilus
Suggests:   %{name}-caja
Suggests:   %{name}-nemo
Suggests:   %{name}-dolphin
%endif

%if 0%{?fedora_version} > 23
# https://github.com/owncloud/client/issues/5703
Requires:    libgnome-keyring
%endif

## was formerly implicit via libowncloudsync0, somehow...
Requires:       ocqt5125-qt5keychain1 >= 0.7.0
# Needed by https://github.com/owncloud/client/issues/6036
Requires:       ocqt5125-libqt5-qtsvg
# 2 redundant dependencies?
Requires:  	ocqt5125-libQt5Sql5
Requires:       ocqt5125-libQt5PrintSupport5

%if 0%{?el6} || 0%{?el7} || 0%{?suse_version} == 1315
Requires:  	ocqt5125-libsqlite3-0
%endif

Requires: %{name}-l10n
## new in 2.6.0 libowncloudsync0 is included in package owncloud-client
Conflicts: libowncloudsync0
Obsoletes: libowncloudsync0
%if 0%{?centos_version}
# our own build of 3.26.0
Requires:    ocqt5125-libsqlite3-0
%endif

######################################################################### Obsoletes only below here.

Obsoletes: libocsync0
Obsoletes: libocsync-devel
Obsoletes: libocsync-plugin-owncloud
Obsoletes: libocsync-plugin-owncloud
Obsoletes: libocsync-devel-doc
Obsoletes: libocsync-doc
Obsoletes: opt-owncloud-client

# Obsolete the experimental Qt5 packages if this is the unbranded client.
%if %{is_owncloud_client}
Obsoletes: libowncloudqt5sync0 libowncloudqt5sync-devel owncloud-client-qt5 owncloud-client-qt5-doc owncloud-client-qt5-l10n
%endif

######################################################################### Package Descriptions start here.

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This package provides the sync and share desktop client
owncloud

%package -n %{name}-doc
Summary:        Documentation for ownCloud
Group:          Development/Libraries/C and C++
Requires: %{name}%{?_isa} = %{version}-%{release}
Obsoletes:      opt-%{name}-doc

%description -n %{name}-doc
Documentation for the ownCloud desktop application.

%package -n %{name}-l10n
Summary:        Localization for ownCloud
Group:          Development/Libraries/C and C++
Requires: %{name}%{?_isa} = %{version}-%{release}
Obsoletes:      opt-%{name}-l10n

%description -n %{name}-l10n
Localization files for the ownCloud desktop application.

%if ! 0%{?suse_version}
## opensuse wants to test install all built packages. This cannot work with a conflicts...
%package -n libowncloudsync0
Requires:       ocqt5125-qt5keychain1 >= 0.7.0
# Needed by https://github.com/owncloud/client/issues/6036
Requires:       ocqt5125-libqt5-qtsvg
Obsoletes:      opt-libowncloudsync0
Conflicts:      %{name}

Summary:        The ownCloud synchronization library
Group:          Development/Libraries/C and C++

%description -n libowncloudsync0
Synchronization library singled out from the ownCloud desktop application.
%endif

%package -n libowncloudsync-devel
Summary:        Development files for the ownCloud synchronization library
Group:          Development/Libraries/C and C++
Obsoletes:      opt-libowncloudsync-devel

%description -n libowncloudsync-devel
Development files for the ownCloud synchronization library.

%prep
%setup -q -n owncloudclient-2.6.1.13407

# packaging.diff
# %%_oc_client_apply_common_patches

%if 0%{?rhel_version} || 0%{?centos_version} || 0%{?suse_version} == 1110
# autostart_use_wrapper.diff
%patch1 -p1
%endif

%if "%{name}" != "owncloud-client" || (0%{?is_opensuse} && 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100)
# openSUSE_Leap_42.2 or branded client
# https://github.com/owncloud/ownbrander/issues/715
# https://github.com/owncloud/enterprise/issues/3318
# no_icon_substitution.diff
%patch2 -p0
%endif

# % if 0% {?is_opensuse} && 0% {?suse_version} == 1315 && 0% {?sle_version} == 120200
# # openSUSE_Leap_42.2 only, https://github.com/owncloud/client/issues/5960#issuecomment-322406761
# # OWNCLOUD_FORCE_QDBUS_TRAY_WORKAROUND.patch
# % patch3 -p1
# %endif

%if 0%{?el6} || 0%{?el7}
# sqlite3-no-DETERMINISTIC-compat.diff
%patch5 -p1
%endif

%if 0%{?is_opensuse} && 0%{?suse_version} == 1315
# open_SUSE_LEap_42.1, 42.2, 42.3 do not know -fstack-protector-strong, but tumbleweed does.
sed -i -e '/ -fstack-protector-strong/d' src/CMakeLists.txt
%endif

%build
echo centos_version 0%{?centos_version}
echo rhel_version   0%{?rhel_version}
echo fedora_version 0%{?fedora_version}
echo suse_version   0%{?suse_version}
echo have_doc       0%{?have_doc}
echo sle_version    0%{?sle_version}

echo APPLICATION_NAME		ownCloud
echo APPLICATION_EXECUTABLE	owncloud
echo APPLICATION_SHORTNAME	ownCloud
echo LINUX_PACKAGE_SHORTNAME	owncloud
echo THEME			ownCloud
echo PACKAGE_NAME_PREFIX	ocqt5125

%if 0%{?use_devtoolset}
source /opt/rh/devtoolset-4/enable
%endif

export LD_LIBRARY_PATH=/opt/ownCloud/qt-5.12.5/%{_lib}
export PATH=/opt/ownCloud/qt-5.12.5/bin:$PATH

# make https://reproducible-builds.org/specs/source-date-epoch/ happy.
test -f .source_date_epoch && export SOURCE_DATE_EPOCH=$(cat .source_date_epoch)
env

# https://kanboard.owncloud.com/project/1/task/1828
sh %{SOURCE2} */*/theme

mkdir build
pushd build

# http://www.cmake.org/Wiki/CMake_RPATH_handling#Default_RPATH_settings
cmake .. \
%if 0%{have_doc}
  -DWITH_DOC=TRUE \
%else
  -DWITH_DOC=FALSE \
%endif
  -DCMAKE_FIND_ROOT_PATH="/opt/ownCloud/qt-5.12.5" \
%if "%{prerelease}" != ""
  -DMIRALL_VERSION_SUFFIX="%{prerelease}" \
%endif
  -DMIRALL_VERSION_BUILD="2071" \
  -DKDE_INSTALL_USE_QT_SYS_PATHS=1 \
%if 0%{?use_devtoolset}
  -DCMAKE_C_COMPILER:STRING="gcc" \
  -DCMAKE_CXX_COMPILER:STRING="g++" \
%endif
%if 0%{?sle_version} == 120100
  -DCMAKE_C_COMPILER:STRING="gcc-5" \
  -DCMAKE_CXX_COMPILER:STRING="g++-5" \
%endif
%if 0%{?sle_version} == 120200
  -DCMAKE_C_COMPILER:STRING="gcc-6" \
  -DCMAKE_CXX_COMPILER:STRING="g++-6" \
%endif
%if 0%{?sle_version} == 120300
  -DCMAKE_C_COMPILER:STRING="gcc-7" \
  -DCMAKE_CXX_COMPILER:STRING="g++-7" \
%endif
  -DCMAKE_C_FLAGS:STRING="%{optflags}" \
  -DCMAKE_CXX_FLAGS:STRING="%{optflags}" \
  -DCMAKE_SKIP_RPATH=OFF \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DCMAKE_INSTALL_PREFIX=/opt/ownCloud/ownCloud \
  -DCMAKE_INSTALL_DATAROOTDIR:PATH=%{_datadir} \
  -DCMAKE_PLUGIN_INSTALL_DIR="/opt/ownCloud/ownCloud/%{_lib}/ownCloud/plugins" \
  -DDATA_INSTALL_DIR:PATH=%{_datadir} \
  -DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir} \
  -DSYSCONF_INSTALL_DIR=%{_sysconfdir} \
%if %{_lib} == lib64
  -DLIB_SUFFIX=64 \
%endif
%if ! %{is_owncloud_client}
  -DOEM_THEME_DIR=$PWD/../ownCloud/syncclient \
%endif
  -DQTKEYCHAIN_INCLUDE_DIR=/opt/ownCloud/qt-5.12.5/include/qt5keychain \
  -DQTKEYCHAIN_LIBRARY=/opt/ownCloud/qt-5.12.5/%{_lib}/libqt5keychain.so \
  -DGIT_SHA1="HACK FIXME" \
  -DBUILD_SHELL_INTEGRATION=OFF \
  -DPACKAGE="%{name}" \
  -DCMAKE_SKIP_BUILD_RPATH=OFF -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_INSTALL_RPATH="/opt/ownCloud/ownCloud/%{_lib};/opt/ownCloud/qt-5.12.5/%{_lib}" -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
  %cmake_args
# workaround for https://github.com/owncloud/client/issues/5958
find . -name link.txt | xargs sed -i -e 's@-Wl,-rpath,/@-Wl,--disable-new-dtags -Wl,-rpath,/@'

# documentation here?
if [ -e conf.py ];
then
  # for old cmake versions we need to move the conf.py.
  mv conf.py doc/
fi


# opensuse: must call make doc first with -j1, as the parallel make -j causes sphinx errors in mkdir otherwise.
%if 0%{have_doc}
make doc -j1
%endif

env LD_RUN_PATH=%{_libdir}/owncloud:%{_libdir}/owncloud make %{?_smp_mflags} VERBOSE=1

%if 0%{have_doc}
echo "second attempt to make doc"
make doc -j1
%endif
popd

%install
%if 0%{?use_devtoolset}
source /opt/rh/devtoolset-4/enable
%endif

pushd build
make DESTDIR=%{buildroot} install

echo suse_version 0%{?suse_version}
echo sle_version 0%{?sle_version}
echo have_doc %have_doc
echo bindir %_bindir

if [ %{have_doc} != 0 ];
then
  rm ${RPM_BUILD_ROOT}%{_docdir}/%{name}/html/unthemed/.buildinfo
  mv ${RPM_BUILD_ROOT}%{_docdir}/%{name}/html/unthemed/* ${RPM_BUILD_ROOT}%{_docdir}/%{name}/html/
  rmdir ${RPM_BUILD_ROOT}%{_docdir}/%{name}/html/unthemed
fi
popd

%if %{have_man}
if [ -d ${RPM_BUILD_ROOT}%{_mandir}/man1 ]; then
%if ! %{is_owncloud_client}
  mkdir -p ${RPM_BUILD_ROOT}%{_mandir}man1
  mv ${RPM_BUILD_ROOT}%{_mandir}/man1/{owncloud.1,owncloud.1}
  mv ${RPM_BUILD_ROOT}%{_mandir}/man1/{owncloudcmd.1,owncloud.1}
%endif
  gzip ${RPM_BUILD_ROOT}%{_mandir}/man1/*.1
fi
%else
rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/*.1
%endif

# TODO: Move to overlay package if needed at all .. what is it supposed to do?
# %define extdir ${RPM_BUILD_ROOT}%{_datadir}/nautilus-python/extensions
# test -f %{extdir}/ownCloud.py  && mv %{extdir}/ownCloud.py  %{extdir}/owncloud.py  || true
# test -f %{extdir}/ownCloud.pyo && mv %{extdir}/ownCloud.pyo %{extdir}/owncloud.pyo || true
# test -f %{extdir}/ownCloud.pyc && mv %{extdir}/ownCloud.pyc %{extdir}/owncloud.pyc || true

install -d ${RPM_BUILD_ROOT}%{_bindir}
ln -s /opt/ownCloud/ownCloud/bin/owncloud ${RPM_BUILD_ROOT}%{_bindir}/owncloud
ln -s /opt/ownCloud/ownCloud/bin/owncloudcmd ${RPM_BUILD_ROOT}%{_bindir}/owncloudcmd

# FIXME: Install symlinks for plugins. Workaround for https://github.com/owncloud/client/issues/7027
(cd ${RPM_BUILD_ROOT}//opt/ownCloud/ownCloud/bin; ln -s ../%{_lib}/ownCloud/plugins/*.so* .)

# assert https://github.com/owncloud/client/issues/5958
objdump -x ${RPM_BUILD_ROOT}//opt/ownCloud/ownCloud/bin/owncloud | grep RPATH | grep /opt/ownCloud || (echo "RPATH regression"; exit 1)

install -d ${RPM_BUILD_ROOT}%{_docdir}/%{name}/
install -m 0644 %{_builddir}/*/README.md ${RPM_BUILD_ROOT}%{_docdir}/%{name}/
install -m 0644 %{_builddir}/*/COPYING ${RPM_BUILD_ROOT}%{_docdir}/%{name}/

# https://github.com/owncloud/client/issues/4107
install -m 0755 -D %{SOURCE3} ${RPM_BUILD_ROOT}/etc/sysctl.d/99-owncloud-inotify.conf

%if %{?suse_version:1}0
%suse_update_desktop_file -n owncloud
# workaround for https://github.com/owncloud/ownbrander/issues/322
for desktop_icon_dir in $RPM_BUILD_ROOT/usr/share/icons/hicolor/*/apps; do
  # copy shortname to executable name, if missing.
  if [ -f $desktop_icon_dir/owncloud.png -a ! -f $desktop_icon_dir/owncloud.png ]; then
    cp $desktop_icon_dir/owncloud.png $desktop_icon_dir/owncloud.png
  fi
done
%endif

# spit out all the subdirs one after another.
dirparts () {
	prefix=$1
	path=$2
	while [ "$path" != '/' -a "$path" != '.' ]; do
		echo $prefix$path
		path=$(dirname $path)
	done | tac
}

dirparts >> files.list '%dir ' /opt/ownCloud/ownCloud

if [ -d %{_datadir}/cloud-providers/ ]; then
  echo >> files.files "# since 2.6.1 and if with libcloudproviders"
  echo >> files.files "%dir %{_datadir}/cloud-providers/"
  echo >> files.files "%{_datadir}/cloud-providers/*.ini"
fi

%check
## use exit 0 instead of exit 1 to turn this into warnings:
if [ "%{name}" != "testpilotcloud-client" ]; then
  if [ "%{prerelease}" == "" ]; then
    expr match '%{distribution}' '.*:community:\(testing\|nightly\)' && { echo "Warning: Need a prerelease here, not %{version} (okay, if you want to submitpac this as a release today)"; exit 0; }
  else
    expr match '%{distribution}' '.*:community:desktop' && { echo "Error: Must not have a prerelease here, not %{version}"; exit 0; }
  fi
fi
exit 0

%post
/sbin/ldconfig
%if 0%{?fedora_version}
/bin/touch --no-create %{_datadir}/icons/hicolor >/dev/null 2>/dev/null || :
%endif

%postun
/sbin/ldconfig
%if 0%{?fedora_version}
if [ $1 -eq 0 ] ; then
    /bin/touch --no-create %{_datadir}/icons/hicolor >/dev/null  2>/dev/null
    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor >/dev/null 2>/dev/null || :
fi
%endif

%posttrans
# fixing https://github.com/owncloud/enterprise/issues/1714
/usr/bin/gtk-update-icon-cache --quiet --force %{_datadir}/icons/hicolor >/dev/null 2>/dev/null || :

%if ! 0%{?suse_version}
%post   -n libowncloudsync0
/sbin/ldconfig

%postun -n libowncloudsync0
/sbin/ldconfig
%endif

%files -f files.list
%defattr(-,root,root,-)
%dir %{_docdir}/%{name}
%doc %{_docdir}/%{name}/README.md
%doc %{_docdir}/%{name}/COPYING

%dir /opt/ownCloud/ownCloud/bin
%dir /opt/ownCloud/ownCloud/include
%dir /opt/ownCloud/ownCloud/%{_lib}
%dir /opt/ownCloud/ownCloud/%{_lib}/ownCloud
%dir /opt/ownCloud/ownCloud/%{_lib}/ownCloud/plugins

/opt/ownCloud/ownCloud/%{_lib}/libowncloudsync.so.*
/opt/ownCloud/ownCloud/%{_lib}/libowncloud_csync.so.*
# new in 2.6.0: /opt/ownCloud/ownCloud/lib64/ownCloud/plugins/owncloudsync_vfs_suffix.so
#               /opt/ownCloud/testpilotcloud/lib64/testpilotcloud/plugins/testpilotcloudsync_vfs_suffix.so
/opt/ownCloud/ownCloud/%{_lib}/ownCloud/plugins/

%{_bindir}/owncloud
%{_bindir}/owncloudcmd
/opt/ownCloud/ownCloud/bin/owncloud
/opt/ownCloud/ownCloud/bin/owncloudcmd
# new in 2.6.0: FIXME
/opt/ownCloud/ownCloud/bin/*.so*

%{_datadir}/applications/owncloud.desktop
%{_datadir}/icons/hicolor
%{_datadir}/mime/packages/owncloud.xml
%if 0%{have_man}
%{_mandir}/man1/owncloud*
%endif

%config /etc/ownCloud
# https://github.com/owncloud/client/issues/4107
%config /etc/sysctl.d/99-owncloud-inotify.conf

%files -n %{name}-doc
%defattr(-,root,root,-)
%if 0%{have_doc}
%doc %{_docdir}/%{name}/html
%endif

%files -n %{name}-l10n
%defattr(-,root,root,-)
%if 0%{?fedora_version} != 23
# workaround for https://github.com/owncloud/client/issues/4987
%dir %{_datadir}/owncloud/
%{_datadir}/owncloud/i18n
%endif

%if ! 0%{?suse_version}
## opensuse wants to test install all built packages. This cannot work with a conflicts...
%files -n libowncloudsync0
%defattr(-,root,root,-)
## FIXME: lib*sync0 should be part of the main package. Uninstall easily breaks when kept separate.
/opt/ownCloud/ownCloud/%{_lib}/libowncloudsync.so.*
/opt/ownCloud/ownCloud/%{_lib}/libowncloud_csync.so.*
# new in 2.6.0: /opt/ownCloud/ownCloud/lib64/ownCloud/plugins/owncloudsync_vfs_suffix.so
#               /opt/ownCloud/testpilotcloud/lib64/testpilotcloud/plugins/testpilotcloudsync_vfs_suffix.so
/opt/ownCloud/ownCloud/%{_lib}/ownCloud/plugins/
%endif

%files -n libowncloudsync-devel
%defattr(-,root,root,-)
/opt/ownCloud/ownCloud/%{_lib}/libowncloudsync.so
/opt/ownCloud/ownCloud/%{_lib}/libowncloud_csync.so
/opt/ownCloud/ownCloud/include/owncloudsync/

%changelog
openSUSE Build Service is sponsored by