File debian.rules of Package owncloud-client

#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

export QT_SELECT := qt5
export PATH := /opt/ownCloud/qt-5.12.9/lib/$(DEB_HOST_MULTIARCH)/qt5/bin:$(PATH)

export DROOT=$(CURDIR)/debian/owncloud-client
export SRCDIR=/usr/src/packages/SOURCES
export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export LD_LIBRARY_PATH := /opt/ownCloud/qt-5.12.9/lib/$(DEB_HOST_MULTIARCH):$(LD_LIBRARY_PATH)


SHELL=/bin/bash

%:
	dh $@

override_dh_auto_configure:
	# not sure, when which variables are set.
	echo source:Version=${source:Version}
	echo source:Upstream-Version=${source:Upstream-Version}
	echo binary:Version=${binary:Version}
	grep OPENSSL_VERSION_TEXT /usr/include/openssl/opensslv.h

	echo "include_directories(/opt/ownCloud/qt-5.12.9/include/$(DEB_HOST_MULTIARCH))" >> src/libsync/CMakeLists.txt
	echo "include_directories(/opt/ownCloud/qt-5.12.9/include/$(DEB_HOST_MULTIARCH)/qt5)" >> src/libsync/CMakeLists.txt
	echo "include_directories(/opt/ownCloud/qt-5.12.9/include/$(DEB_HOST_MULTIARCH)/qt5/QtCore)" >> src/libsync/CMakeLists.txt
	# Debian 7 does not find #include <QPixmap> in qt5/QtGui/QPixmap -- this helps:
	echo "include_directories(/opt/ownCloud/qt-5.12.9/include/$(DEB_HOST_MULTIARCH)/qt5/QtGui)" >> src/cmd/CMakeLists.txt
	# debian-7 and ubuntu-14.04 don't know -fstack-protector-strong
	test -f /etc/os-release && . /etc/os-release || true; \
	echo "$$ID-$$VERSION_ID" \
	test "$$ID-$$VERSION_ID" = "debian-7"     && sed -i -e '/ -fstack-protector-strong/d' src/CMakeLists.txt || true; \
	test "$$ID-$$VERSION_ID" = "debian-7.0"   && sed -i -e '/ -fstack-protector-strong/d' src/CMakeLists.txt || true; \
	test "$$ID-$$VERSION_ID" = "ubuntu-14.04" && sed -i -e '/ -fstack-protector-strong/d' src/CMakeLists.txt || true

	# protect against poisonous tar-balls.
	if [ -d binary ]; then ls -la; echo; echo "A top level directory named 'binary' exists. This kills dpkg-genchangelog."; echo; echo "... removing that directory."; echo; echo; sleep 3; rm -rf binary; fi
	if [ -d changelog ]; then ls -la; echo; echo "A top level directory named 'changelog' exists. This kills dpkg-genchangelog on debian 8 and 9."; echo; echo "... removing that directory."; echo; echo; sleep 3; rm -rf changelog; fi

	# https://kanboard.owncloud.com/project/1/task/1828
	sh $(SRCDIR)/fix_theme_250.sh */*/theme

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

	# Use at least -std=c99 for Debian_8.0 to compile zsync.
	git_defs=('-DMIRALL_VERSION_BUILD=2841'); \
	if [ -n "daily20200816" -a "daily20200816" != "%nil" ]; then \
	  git_defs=('-DMIRALL_VERSION_SUFFIX=daily20200816' '-DMIRALL_VERSION_BUILD=2841'); \
	fi; \
	CFLAGS="-g -O2 -std=c99 -Wall -pedantic" dh_auto_configure -- \
		"$${git_defs[@]}" \
		-DQT_QMAKE_EXECUTABLE=/opt/ownCloud/qt-5.12.9/bin/qmake \
		-DCMAKE_INSTALL_PREFIX=/opt/ownCloud/ownCloud \
		-DCMAKE_INSTALL_DOCDIR=/usr/share/doc \
		-DCMAKE_INSTALL_DATAROOTDIR:PATH=/usr/share \
		-DDATA_INSTALL_DIR:PATH=/usr/share \
		-DSYSCONF_INSTALL_DIR=/etc \
		-DWITH_DOC=FALSE \
		-DCMAKE_SKIP_BUILD_RPATH=OFF -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_INSTALL_RPATH="/opt/ownCloud/ownCloud/lib/$(DEB_HOST_MULTIARCH);/opt/ownCloud/qt-5.12.9/lib/$(DEB_HOST_MULTIARCH)" -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
		-DOEM_THEME_DIR=$(CURDIR)/ownCloud/syncclient \
		-DCMAKE_FIND_ROOT_PATH=/opt/ownCloud/qt-5.12.9 \
		-DQTKEYCHAIN_INCLUDE_DIR=/opt/ownCloud/qt-5.12.9/include/qt5keychain \
		-DQTKEYCHAIN_LIBRARY=/opt/ownCloud/qt-5.12.9/lib/$(DEB_HOST_MULTIARCH)/libqt5keychain.so \
		-DBUILD_SHELL_INTEGRATION=OFF

	# 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,/@'

override_dh_auto_install:
	dh_auto_install -Xdebian
	# we see the install candidates in debian/tmp after(!) dh_auto_install was run. The *.install file logic picks up the files from there later(!)
	# https://github.com/owncloud/client/issues/7623
	find "$(CURDIR)" -name *.ini || true
	ls $(CURDIR)/debian/tmp/usr/share/cloud-providers/*.ini && echo "usr/share/cloud-providers/*.ini" >> debian/owncloud-client.install || true
	# https://github.com/owncloud/client/issues/4107
	install -m 0755 -D $(SRCDIR)/99-sync-inotify.conf $(DROOT)/etc/sysctl.d/99-owncloud-inotify.conf

	# install symlinks to /usr/bin
	install -m 0644 -d $(CURDIR)/usr/bin/
	ln -s /opt/ownCloud/ownCloud/bin/owncloud $(CURDIR)/usr/bin/owncloud
	ln -s /opt/ownCloud/ownCloud/bin/owncloudcmd $(CURDIR)/usr/bin/owncloudcmd

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

	# https://github.com/owncloud/client/issues/2153
	find $(CURDIR) -name \*.1 | grep man/man1 | tee | xargs rm -f

override_dh_auto_test:
	dh_auto_test || true

override_dh_strip:
	dh_strip --dbg-package=owncloud-client-dbg

override_dh_shlibdeps:
	dh_shlibdeps -O--parallel -l"/opt/ownCloud/ownCloud/lib/$(DEB_HOST_MULTIARCH):/opt/ownCloud/qt-5.12.9/lib/$(DEB_HOST_MULTIARCH)"
openSUSE Build Service is sponsored by