From fbc5bdd16c02689a725085665de6453ea3c8b08a Mon Sep 17 00:00:00 2001
From: Amin Bandali <amin.bandali@savoirfairelinux.com>
Date: Fri, 7 Oct 2022 17:42:04 -0400
Subject: [PATCH] packaging: jami-qt to jami rename

The jami-qt executable has been renamed to jami:
https://review.jami.net/c/jami-client-qt/+/21906

Change-Id: Ibfae8f9cbfefa47eae3af1a2ad03f2331e306c11
---
 Makefile                                      |  6 +-
 build.py                                      |  2 +-
 guix/guix-pack-manifest.scm                   |  2 +-
 packaging/rules/rpm/jami-qt.spec              | 77 +++--------------
 packaging/rules/rpm/jami.spec                 | 82 +++++++++++++++++++
 .../scripts/{jami-qt-wrapper => jami-wrapper} |  0
 packaging/rules/snap/jami/snapcraft.yaml      | 16 ++--
 scripts/build-package-rpm.sh                  |  9 +-
 8 files changed, 109 insertions(+), 85 deletions(-)
 create mode 100644 packaging/rules/rpm/jami.spec
 rename packaging/rules/snap/common/scripts/{jami-qt-wrapper => jami-wrapper} (100%)

diff --git a/Makefile b/Makefile
index da541306..500efc0e 100644
--- a/Makefile
+++ b/Makefile
@@ -243,11 +243,11 @@ DEB_PACK_TARGETS =
 
 define guix-pack-command
 guix pack -C xz -f deb -m $(CURDIR)/guix/guix-pack-manifest.scm -v3 \
-  -S /usr/bin/jami-qt=bin/jami-qt \
-  -S /usr/share/applications/jami-qt.desktop=share/applications/jami-qt.desktop \
+  -S /usr/bin/jami=bin/jami \
+  -S /usr/share/applications/jami.desktop=share/applications/jami.desktop \
   -S /usr/share/icons/hicolor/scalable/apps/jami.svg=share/icons/hicolor/scalable/apps/jami.svg \
   -S /usr/share/icons/hicolor/48x48/apps/jami.png=share/icons/hicolor/48x48/apps/jami.png \
-  -S /usr/share/metainfo/jami-qt.appdata.xml=share/metainfo/jami-qt.appdata.xml \
+  -S /usr/share/metainfo/jami.appdata.xml=share/metainfo/jami.appdata.xml \
   --postinst-file=$(CURDIR)/guix/guix-pack-deb.postinst
 endef
 
diff --git a/build.py b/build.py
index 78dfcd48..26d55555 100755
--- a/build.py
+++ b/build.py
@@ -489,7 +489,7 @@ def run_run(args):
         client_log = open('jami-qt.log', 'a')
         client_log.write('=== Starting client (%s) ===' %
                          time.strftime("%d/%m/%Y %H:%M:%S"))
-        client_process = subprocess.Popen(["./install/client-qt/bin/jami-qt", "-d"],
+        client_process = subprocess.Popen(["./install/client-qt/bin/jami", "-d"],
                                           stdout=client_log,
                                           stderr=client_log,
                                           env=run_env)
diff --git a/guix/guix-pack-manifest.scm b/guix/guix-pack-manifest.scm
index c3278465..8337247f 100644
--- a/guix/guix-pack-manifest.scm
+++ b/guix/guix-pack-manifest.scm
@@ -86,7 +86,7 @@
         #~(modify-phases #$phases
             (add-after 'qt-wrap 'wrap-ssl-cert-dir
               (lambda* (#:key inputs outputs #:allow-other-keys)
-                (substitute* (search-input-file outputs "bin/jami-qt")
+                (substitute* (search-input-file outputs "bin/jami")
                   (("^exec.*" exec-line)
                    (format #f "export SSL_CERT_DIR=~a~%"
                            (search-input-directory inputs "etc/ssl/certs")
diff --git a/packaging/rules/rpm/jami-qt.spec b/packaging/rules/rpm/jami-qt.spec
index 411fb7ba..5cc25e89 100644
--- a/packaging/rules/rpm/jami-qt.spec
+++ b/packaging/rules/rpm/jami-qt.spec
@@ -1,3 +1,8 @@
+# Made into a transitional package on 2022-10-12, after the 'jami-qt'
+# to 'jami' rename, to provide an upgrade path to existing users.
+# Feel free to remove this package later into the future, some time
+# after 2023-10-12 perhaps.
+
 %define name        jami-qt
 %define version     RELEASE_VERSION
 %define release     0
@@ -5,79 +10,17 @@
 Name:          %{name}
 Version:       %{version}
 Release:       %{release}%{?dist}
-Summary:       Qt client for Jami
+Summary:       Transitional package for Jami; can be safely removed
 Group:         Applications/Internet
 License:       GPLv3+
 Vendor:        Savoir-faire Linux
 URL:           https://jami.net/
 Source:        jami_%{version}.tar.gz
-Requires:      jami-daemon = %{version}
-Requires:      jami-libqt
-Provides:      jami
-Obsoletes:     jami < %{version}-%{release}
-Obsoletes:     jami-libclient <= 20220516.0214.9b42ad3-1
-
-# Build dependencies.
-%if 0%{?fedora} >= 32
-BuildRequires: cmake
-BuildRequires: gcc-c++
-%endif
-BuildRequires: make
-
-# For generating resources.qrc in build time.
-BuildRequires: python3
-
-# Build and runtime dependencies.
-BuildRequires: qrencode-devel
+Requires:      jami
 
 %description
-This package contains the Qt desktop client of Jami. Jami is a free
-software for universal communication which respects freedoms and
-privacy of its users.
-
-%prep
-%setup -n jami-project
-
-%build
-# Configure and build bundled ffmpeg (for libavutil/avframe).
-mkdir -p %{_builddir}/jami-project/daemon/contrib/native
-cd %{_builddir}/jami-project/daemon/contrib/native && \
-    ../bootstrap \
-        --no-checksums \
-        --disable-ogg \
-        --disable-flac \
-        --disable-vorbis \
-        --disable-vorbisenc \
-        --disable-speex \
-        --disable-sndfile \
-        --disable-gsm \
-        --disable-speexdsp \
-        --disable-natpmp && \
-    make list && \
-    make fetch && \
-    make %{_smp_mflags} V=1 .ffmpeg
-# Qt-related variables
-cd %{_builddir}/jami-project/client-qt && \
-    mkdir build && cd build && \
-    cmake -DENABLE_LIBWRAP=true \
-          -DLIBJAMI_BUILD_DIR=%{_builddir}/jami-project/daemon/src \
-          -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-          -DCMAKE_INSTALL_LIBDIR=%{_libdir} \
-          -DCMAKE_BUILD_TYPE=Release \
-          ..
-make -C %{_builddir}/jami-project/client-qt/build %{_smp_mflags} V=1
-
-%install
-DESTDIR=%{buildroot} make -C %{_builddir}/jami-project/client-qt/build install
+This is a transitional package. The Jami Qt client is now packaged
+under the name 'jami', and this package can be safely removed.
 
+# Required, otherwise no rpm is generated.
 %files
-%defattr(-,root,root,-)
-%{_bindir}/jami
-%{_bindir}/jami-qt
-%{_datadir}/applications/jami-qt.desktop
-%{_datadir}/jami-qt/jami-qt.desktop
-%{_datadir}/icons/hicolor/scalable/apps/jami.svg
-%{_datadir}/icons/hicolor/48x48/apps/jami.png
-%{_datadir}/pixmaps/jami.xpm
-%{_datadir}/metainfo/jami-qt.appdata.xml
-%{_datadir}/jami/translations/*
diff --git a/packaging/rules/rpm/jami.spec b/packaging/rules/rpm/jami.spec
new file mode 100644
index 00000000..78cebffd
--- /dev/null
+++ b/packaging/rules/rpm/jami.spec
@@ -0,0 +1,82 @@
+%define name        jami
+%define version     RELEASE_VERSION
+%define release     0
+
+Name:          %{name}
+Version:       %{version}
+Release:       %{release}%{?dist}
+Summary:       Qt client for Jami
+Group:         Applications/Internet
+License:       GPLv3+
+Vendor:        Savoir-faire Linux
+URL:           https://jami.net/
+Source:        jami_%{version}.tar.gz
+Requires:      jami-daemon = %{version}
+Requires:      jami-libqt
+Provides:      jami-qt = %{version}
+Obsoletes:     jami-qt < 20221010.1109.641d67d-2
+Obsoletes:     jami-libclient <= 20220516.0214.9b42ad3-1
+
+# Build dependencies.
+%if 0%{?fedora} >= 32
+BuildRequires: cmake
+BuildRequires: gcc-c++
+%endif
+BuildRequires: make
+
+# For generating resources.qrc in build time.
+BuildRequires: python3
+
+# Build and runtime dependencies.
+BuildRequires: qrencode-devel
+
+%description
+This package contains the Qt desktop client of Jami. Jami is a free
+software for universal communication which respects freedoms and
+privacy of its users.
+
+%prep
+%setup -n jami-project
+
+%build
+# Configure and build bundled ffmpeg (for libavutil/avframe).
+mkdir -p %{_builddir}/jami-project/daemon/contrib/native
+cd %{_builddir}/jami-project/daemon/contrib/native && \
+    ../bootstrap \
+        --no-checksums \
+        --disable-ogg \
+        --disable-flac \
+        --disable-vorbis \
+        --disable-vorbisenc \
+        --disable-speex \
+        --disable-sndfile \
+        --disable-gsm \
+        --disable-speexdsp \
+        --disable-natpmp && \
+    make list && \
+    make fetch && \
+    make %{_smp_mflags} V=1 .ffmpeg
+# Qt-related variables
+cd %{_builddir}/jami-project/client-qt && \
+    mkdir build && cd build && \
+    cmake -DENABLE_LIBWRAP=true \
+          -DLIBJAMI_BUILD_DIR=%{_builddir}/jami-project/daemon/src \
+          -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+          -DCMAKE_INSTALL_LIBDIR=%{_libdir} \
+          -DCMAKE_BUILD_TYPE=Release \
+          ..
+make -C %{_builddir}/jami-project/client-qt/build %{_smp_mflags} V=1
+
+%install
+DESTDIR=%{buildroot} make -C %{_builddir}/jami-project/client-qt/build install
+
+%files
+%defattr(-,root,root,-)
+%{_bindir}/jami
+%{_datadir}/applications/jami.desktop
+%{_datadir}/jami/jami.desktop
+%{_datadir}/icons/hicolor/scalable/apps/jami.svg
+%{_datadir}/icons/hicolor/48x48/apps/jami.png
+%{_datadir}/pixmaps/jami.xpm
+%{_datadir}/metainfo/jami.appdata.xml
+%{_datadir}/jami/translations/*
diff --git a/packaging/rules/snap/common/scripts/jami-qt-wrapper b/packaging/rules/snap/common/scripts/jami-wrapper
similarity index 100%
rename from packaging/rules/snap/common/scripts/jami-qt-wrapper
rename to packaging/rules/snap/common/scripts/jami-wrapper
diff --git a/packaging/rules/snap/jami/snapcraft.yaml b/packaging/rules/snap/jami/snapcraft.yaml
index f0ddf051..ea5f5c1f 100644
--- a/packaging/rules/snap/jami/snapcraft.yaml
+++ b/packaging/rules/snap/jami/snapcraft.yaml
@@ -130,14 +130,14 @@ environment:
 
 apps:
   jami:
-    command: usr/bin/jami-qt
+    command: usr/bin/jami
     command-chain:
     - bin/desktop-launch
     - snap/command-chain/alsa-launch
-    - bin/jami-qt-wrapper
-    autostart: jami-qt.desktop
+    - bin/jami-wrapper
+    autostart: extras/data/jami.desktop
     common-id: net.jami.Jami
-    desktop: usr/share/applications/jami-qt.desktop
+    desktop: usr/share/applications/jami.desktop
     slots:
     - dbus-jami
     - dbus-ring
@@ -216,7 +216,7 @@ parts:
     plugin: dump
     source: ../common/scripts
     organize:
-      jami-qt-wrapper: bin/jami-qt-wrapper
+      jami-wrapper: bin/jami-wrapper
 
   alsa-mixin:
     plugin: dump
@@ -239,7 +239,7 @@ parts:
     source: ../../../..
     source-type: local
     plugin: nil
-    parse-info: [usr/share/metainfo/jami-qt.appdata.xml]
+    parse-info: [usr/share/metainfo/jami.appdata.xml]
     stage:
       - -usr/lib/x86_64-linux-gnu/liblber-2.4.so*
       - -usr/lib/x86_64-linux-gnu/libldap_r-2.4.so*
@@ -253,9 +253,7 @@ parts:
     override-pull: |
       snapcraftctl pull
       sed -i -E 's|(tmpName) << (PACKAGE_NAME << "_shm_")|\1 << "snap.jami." << \2|' daemon/src/media/video/sinkclient.cpp
-      for file in jami-qt.desktop jami-qt.desktop.autostart; do
-        sed -i -E 's|^Icon=.*|Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/jami.svg|' client-qt/$file
-      done
+      sed -i -E 's|^Icon=.*|Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/jami.svg|' client-qt/extras/data/jami.desktop
     override-build: |
       cd $SNAPCRAFT_PART_BUILD/daemon/contrib
       mkdir -p native
diff --git a/scripts/build-package-rpm.sh b/scripts/build-package-rpm.sh
index 3f51b0f3..b4a965db 100755
--- a/scripts/build-package-rpm.sh
+++ b/scripts/build-package-rpm.sh
@@ -128,14 +128,15 @@ rpmdev-bumpspec --comment="Automatic nightly release" \
                 --userstring="Jenkins <jami@lists.savoirfairelinux.net>" ./*.spec
 
 # Build the daemon and install it.
-rpmbuild --define "debug_package %{nil}"  -ba jami-daemon.spec
+rpmbuild --define "debug_package %{nil}" -ba jami-daemon.spec
 rpm --install /root/rpmbuild/RPMS/x86_64/jami-daemon-*
 
-# Build the transitional libclient package.
-rpmbuild --define "debug_package %{nil}"  -ba jami-libclient.spec
+# Build the temporary transitional packages.
+rpmbuild --define "debug_package %{nil}" -ba jami-libclient.spec
+rpmbuild --define "debug_package %{nil}" -ba jami-qt.spec
 
 # Build the Qt client.
-rpmbuild --define "debug_package %{nil}" -ba jami-qt.spec
+rpmbuild --define "debug_package %{nil}" -ba jami.spec
 
 # Move the built packages to the output directory.
 mv /root/rpmbuild/RPMS/*/* /opt/output
-- 
GitLab