From fd10998d2d015377a8bad0d3f188773552d37dde Mon Sep 17 00:00:00 2001
From: Amin Bandali <amin.bandali@savoirfairelinux.com>
Date: Thu, 10 Mar 2022 16:49:33 -0500
Subject: [PATCH] build: add separate lrc-gnome submodule for client-gnome

After the recent merge of the video renderer changes into lrc and
client-qt, the build for client-gnome is currently broken because it
has not yet been updated to follow the new API, a non-trivial task.
Thus, we add a separate lrc-gnome submodule for use by client-gnome,
as a temporary measure until the future vendoring of lrc into the two
clients.

With this change, the users of the Qt client ('jami' package) would
continue using 'jami-libclient' as a dependency, whereas for users of
the GNOME client ('jami-gnome') they would install and use the new
'jami-libclient-gnome' package.

Change-Id: I6aacb6c495c9a2953c328f2e9bfe6acd2b8cc645
---
 .gitmodules                                   |  3 +
 Jenkinsfile                                   |  2 +-
 Makefile                                      |  2 +-
 lrc-gnome                                     |  1 +
 packaging/rules/debian/control                | 20 +++++-
 packaging/rules/debian/rules                  | 25 ++++++-
 packaging/rules/rpm/jami-gnome.spec           |  2 +-
 packaging/rules/rpm/jami-libclient-gnome.spec | 71 +++++++++++++++++++
 scripts/build-package-rpm.sh                  | 10 ++-
 9 files changed, 127 insertions(+), 9 deletions(-)
 create mode 160000 lrc-gnome
 create mode 100644 packaging/rules/rpm/jami-libclient-gnome.spec

diff --git a/.gitmodules b/.gitmodules
index a2a8a724..368c3d59 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -25,3 +25,6 @@
 [submodule "plugins"]
 	path = plugins
 	url = https://review.jami.net/jami-plugins
+[submodule "lrc-gnome"]
+	path = lrc-gnome
+	url = https://review.jami.net/jami-libclient
diff --git a/Jenkinsfile b/Jenkinsfile
index 5db8a85b..ce870dbb 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -32,7 +32,7 @@
 // - Allow publishing from any node, to avoid relying on a single machine.
 
 // Configuration globals.
-def SUBMODULES = ['daemon', 'lrc', 'client-gnome', 'client-qt']
+def SUBMODULES = ['daemon', 'lrc', 'lrc-gnome', 'client-gnome', 'client-qt']
 def TARGETS = [:]
 def REMOTE_HOST = env.SSH_HOST_DL_RING_CX
 def REMOTE_BASE_DIR = '/srv/repository/ring'
diff --git a/Makefile b/Makefile
index f56a0367..59a76003 100644
--- a/Makefile
+++ b/Makefile
@@ -125,7 +125,7 @@ $(RELEASE_TARBALL_FILENAME): tarballs.manifest
 	rm -f "$@"
 	mkdir $(TMPDIR)/jami-project
 	git archive HEAD | tar xf - -C $(TMPDIR)/jami-project
-	for m in daemon lrc client-gnome client-qt; do \
+	for m in daemon lrc lrc-gnome client-gnome client-qt; do \
 		(cd "$$m" && git archive --prefix "$$m/" HEAD \
 			| tar xf - -C $(TMPDIR)/jami-project); \
 	done
diff --git a/lrc-gnome b/lrc-gnome
new file mode 160000
index 00000000..74fcb074
--- /dev/null
+++ b/lrc-gnome
@@ -0,0 +1 @@
+Subproject commit 74fcb074357421dad30181ee5b46cebd79166ca9
diff --git a/packaging/rules/debian/control b/packaging/rules/debian/control
index 8b7ef62a..f8219c37 100644
--- a/packaging/rules/debian/control
+++ b/packaging/rules/debian/control
@@ -80,6 +80,7 @@ Replaces: jami,
           libqt-jami (>= 6.2.3),
 Conflicts: jami,
            jami-libclient,
+           jami-libclient-gnome,
            jami-daemon,
            jami-gnome,
            libqt-jami
@@ -108,7 +109,7 @@ Package: jami-gnome
 Architecture: any
 Depends: ${shlibs:Depends},
          ${misc:Depends},
-         jami-libclient (=${binary:Version})
+         jami-libclient-gnome (=${binary:Version})
 Description: Secure and distributed voice, video and chat platform - desktop client
  Jami (jami.net) is a secure and distributed voice, video and chat communication
  platform that requires no centralized server and leaves the power of privacy
@@ -122,12 +123,27 @@ Depends: ${shlibs:Depends},
          ${misc:Depends},
          jami-daemon (=${binary:Version}),
          libqt-jami (>= 6.2.3)
+Conflicts: jami-libclient-gnome
 Description: Secure and distributed voice, video and chat platform - daemon
  Jami (jami.net) is a secure and distributed voice, video and chat communication
  platform that requires no centralized server and leaves the power of privacy
  in the hands of the user.
  .
- This package contains the Jami client library: lrc.
+ This package contains the Jami client library, lrc, for the Qt client.
+
+Package: jami-libclient-gnome
+Architecture: any
+Depends: ${shlibs:Depends},
+         ${misc:Depends},
+         jami-daemon (=${binary:Version}),
+         libqt-jami (>= 6.2.3)
+Conflicts: jami-libclient
+Description: Secure and distributed voice, video and chat platform - daemon
+ Jami (jami.net) is a secure and distributed voice, video and chat communication
+ platform that requires no centralized server and leaves the power of privacy
+ in the hands of the user.
+ .
+ This package contains the Jami client library, lrc, for the GNOME client.
 
 Package: jami-daemon
 Architecture: any
diff --git a/packaging/rules/debian/rules b/packaging/rules/debian/rules
index c6852139..766589a6 100755
--- a/packaging/rules/debian/rules
+++ b/packaging/rules/debian/rules
@@ -26,6 +26,7 @@ JAMI_ALL_IN_ONE_PKG_NAME="jami-all"
 JAMI_CLIENT_PKG_NAME="jami"
 JAMI_CLIENT_GNOME_PKG_NAME="jami-gnome"
 JAMI_LIB_CLIENT_PKG_NAME="jami-libclient"
+JAMI_LIB_CLIENT_GNOME_PKG_NAME="jami-libclient-gnome"
 JAMI_DAEMON_PKG_NAME="jami-daemon"
 
 # Bundled packages from contrib
@@ -100,20 +101,36 @@ override_dh_auto_build:
 	  -DCMAKE_INSTALL_LIBDIR=lib \
 	  $(CMAKE_OPTIONS) ..
 
+	# Libringclient configure (for GNOME client)
+	cd lrc-gnome && \
+	mkdir build && \
+	cd build && \
+	cmake  \
+	  -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
+	  -DENABLE_LIBWRAP=true \
+	  -DCMAKE_INSTALL_PREFIX=/usr \
+	  -DCMAKE_INSTALL_LIBDIR=lib \
+	  $(CMAKE_OPTIONS) ..
+
 	# libringclient build
 	make -C lrc/build -j$(NO_CPUS) V=1
 
+	# libringclient build (for GNOME client)
+	make -C lrc-gnome/build -j$(NO_CPUS) V=1
+
 	# GNOME client configure
 	cd client-gnome && \
 	  mkdir build && \
 	  cd build && \
 	  cmake -DCMAKE_INSTALL_PREFIX=/usr \
 		-DCMAKE_INSTALL_LIBDIR=lib \
-		-DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
+		-DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc-gnome \
 		-DGSETTINGS_LOCALCOMPILE=OFF \
 		$(CMAKE_OPTIONS) ..
 
 	# GNOME client build
+	cd client-gnome/web && \
+	  for f in ../../lrc-gnome/src/web-chatview/*.*; do ln -sf "$$f" .; done
 	make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1
 
 	# Qt client configure and build
@@ -141,6 +158,8 @@ override_dh_auto_clean:
 	# CMake build system has no distclean target, so use clean.
 	[ -f lrc/build/Makefile ] && make -C lrc/build clean || true
 	rm -rfv lrc/build
+	[ -f lrc-gnome/build/Makefile ] && make -C lrc-gnome/build clean || true
+	rm -rfv lrc-gnome/build
 
 	###########################
 	##### gnome client clean ##
@@ -172,9 +191,13 @@ override_dh_auto_install:
         ## LibRingClient
 	cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME) install
 	rm -rfv $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/include
+        ## LibRingClient (for GNOME client)
+	cd lrc-gnome/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_LIB_CLIENT_GNOME_PKG_NAME) install
+	rm -rfv $(CURDIR)/debian/$(JAMI_LIB_CLIENT_GNOME_PKG_NAME)/usr/include
 
 	# This is a symlink, should be in -dev package
 	rm -v $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/lib/libringclient.so
+	rm -v $(CURDIR)/debian/$(JAMI_LIB_CLIENT_GNOME_PKG_NAME)/usr/lib/libringclient.so
 
 	# cmake files
 	rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME)/usr/lib/cmake
diff --git a/packaging/rules/rpm/jami-gnome.spec b/packaging/rules/rpm/jami-gnome.spec
index b7b3f8c1..4f9f7284 100644
--- a/packaging/rules/rpm/jami-gnome.spec
+++ b/packaging/rules/rpm/jami-gnome.spec
@@ -11,7 +11,7 @@ License:       GPLv3+
 Vendor:        Savoir-faire Linux
 URL:           https://jami.net/
 Source:        jami_%{version}.tar.gz
-Requires:      jami-libclient = %{version}
+Requires:      jami-libclient-gnome = %{version}
 
 # Build dependencies.
 BuildRequires: make
diff --git a/packaging/rules/rpm/jami-libclient-gnome.spec b/packaging/rules/rpm/jami-libclient-gnome.spec
new file mode 100644
index 00000000..91dd8655
--- /dev/null
+++ b/packaging/rules/rpm/jami-libclient-gnome.spec
@@ -0,0 +1,71 @@
+%define name        jami-libclient-gnome
+%define version     RELEASE_VERSION
+%define release     0
+
+Name:          %{name}
+Version:       %{version}
+Release:       %{release}%{?dist}
+Summary:       Client library for Jami GNOME
+Group:         Applications/Internet
+License:       GPLv3+
+Vendor:        Savoir-faire Linux
+URL:           https://jami.net/
+Source:        jami_%{version}.tar.gz
+Requires:      jami-daemon = %{version}
+
+# Build dependencies
+BuildRequires: jami-daemon-devel = %{version}
+Requires:      jami-libqt
+BuildRequires: make
+%if 0%{?fedora} >= 32
+BuildRequires: NetworkManager-libnm-devel
+BuildRequires: cmake
+BuildRequires: gcc-c++
+%endif
+
+%description
+This package contains the client library of Jami GNOME, a free
+software for universal communication which respects freedoms and
+privacy of its users.
+
+%prep
+%setup -n jami-project
+
+%build
+# Qt-related variables
+cd %{_builddir}/jami-project/lrc-gnome && \
+    mkdir build && cd build && \
+    cmake -DRING_BUILD_DIR=%{_builddir}/jami-project/daemon/src \
+          -DENABLE_LIBWRAP=true \
+          -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+          -DCMAKE_INSTALL_LIBDIR=%{_libdir} \
+          -DCMAKE_BUILD_TYPE=Release \
+          ..
+make -C %{_builddir}/jami-project/lrc-gnome/build %{_smp_mflags} V=1
+
+%install
+DESTDIR=%{buildroot} make -C lrc-gnome/build install
+
+%files
+%defattr(-,root,root,-)
+%{_libdir}/libringclient.so.1.0.0
+%{_datadir}/libringclient
+
+%package devel
+Summary: Development files of the Jami GNOME client library
+
+%description devel
+This package contains the header files and the unversioned shared
+library for developing with the Jami client library.
+
+%files devel
+%{_includedir}/libringclient
+%{_libdir}/cmake/LibRingClient
+# The following is a symbolic link.
+%{_libdir}/libringclient.so
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
diff --git a/scripts/build-package-rpm.sh b/scripts/build-package-rpm.sh
index e4212289..82644546 100755
--- a/scripts/build-package-rpm.sh
+++ b/scripts/build-package-rpm.sh
@@ -127,12 +127,16 @@ rpmdev-bumpspec --comment="Automatic nightly release" \
 rpmbuild --define "debug_package %{nil}"  -ba jami-daemon.spec
 rpm --install /root/rpmbuild/RPMS/x86_64/jami-daemon-*
 
-# Build the client library and install it.
+# Build the client library, install it, and build the Qt client.
 rpmbuild --define "debug_package %{nil}"  -ba jami-libclient.spec
 rpm --install /root/rpmbuild/RPMS/x86_64/jami-libclient-*
-
-# Build the GNOME and Qt clients.
 rpmbuild --define "debug_package %{nil}" -ba jami-qt.spec
+
+# Uninstall the client library, build and install the client library
+# version specific to the GNOME client, and build the GNOME client.
+rpm --erase $(rpm --query --all 'jami-libclient*')
+rpmbuild --define "debug_package %{nil}"  -ba jami-libclient-gnome.spec
+rpm --install /root/rpmbuild/RPMS/x86_64/jami-libclient-gnome-*
 rpmbuild --define "debug_package %{nil}" -ba jami-gnome.spec
 
 # Move the built packages to the output directory.
-- 
GitLab