Subject: [bug#45889] Nextcloud Client (v18)

From: Raghav Gururajan <[email-masked]>
Date: Tue, 9 Mar 2021 10:16:17 -0500

Hi Leo!

> The comment certainly improved FSVO improved, but it somehow does not
> reduce my bikeshedding mood.  In particular, I feel like we ought to do
> this in the snippet.

Moved to snippet.

> You just masked an install error without actually unvendoring
> dependencies.

Done.

Please find the attached v18.

Regards,
RG.
From daad8ffd22e8f000a1569ca45b415e28b4e20798 Mon Sep 17 00:00:00 2001
From: Raghav Gururajan <[email-masked]>
Date: Thu, 14 Jan 2021 23:32:27 -0500
Subject: [PATCH 1/3] gnu: Add appstream.

* gnu/packages/freedesktop.scm (appstream): New variable.
---
 gnu/packages/freedesktop.scm | 96 ++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index e00454f7b3..60fa080c9d 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -58,8 +58,10 @@
   #:use-module (gnu packages bash)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cryptsetup)
+  #:use-module (gnu packages databases)
   #:use-module (gnu packages disk)
   #:use-module (gnu packages docbook)
   #:use-module (gnu packages documentation)
@@ -75,6 +77,7 @@
   #:use-module (gnu packages gstreamer)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages image)
+  #:use-module (gnu packages language)
   #:use-module (gnu packages libffi)
   #:use-module (gnu packages libunwind)
   #:use-module (gnu packages libusb)
@@ -101,6 +104,99 @@
   #:use-module (gnu packages xorg)
   #:use-module (srfi srfi-1))
 
+(define-public appstream
+  (package
+    (name "appstream")
+    (version "0.13.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append "https://www.freedesktop.org/software/"
+                       "appstream/releases/"
+                       "AppStream-" version ".tar.xz"))
+       (sha256
+        (base32 "09l6ixz1w29pi0nb0flz14m4r3f2hpqpp1fq8y66v9xa4c9fczds"))))
+    (build-system meson-build-system)
+    (arguments
+     `(#:glib-or-gtk? #t
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-libstemmer
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "meson.build"
+               (("/usr/include")
+                (string-append (assoc-ref inputs "libstemmer")
+                               "/include")))
+             #t))
+         (add-after 'patch-libstemmer 'patch-docbook-xml
+           (lambda* (#:key inputs #:allow-other-keys)
+             (with-directory-excursion "docs/api"
+               (substitute* "appstream-docs.xml"
+                 (("http://www.oasis-open.org/docbook/xml/4.3/")
+                  (string-append (assoc-ref inputs "docbook-xml-4.3")
+                                 "/xml/dtd/docbook/"))))
+             (for-each (lambda (file)
+                         (substitute* file
+                           (("http://www.oasis-open.org/docbook/xml/4.5/")
+                            (string-append (assoc-ref inputs "docbook-xml")
+                                           "/xml/dtd/docbook/"))))
+                       (find-files "scripts/desc" "\\.xml$"))
+             #t))
+         (add-after 'patch-docbook-xml 'disable-failing-tests
+           (lambda _
+             (substitute* "tests/test-pool.c"
+               (("[ \t]*g_test_add_func \\(\"/AppStream/PoolRead?.*;")
+                "")
+               (("[ \t]*g_test_add_func \\(\"/AppStream/PoolReadAsync?.*;")
+                "")
+               (("[ \t]*g_test_add_func \\(\"/AppStream/PoolEmpty?.*;")
+                "")
+               (("[ \t]*g_test_add_func \\(\"/AppStream/Cache?.*;")
+                "")
+               (("[ \t]*g_test_add_func \\(\"/AppStream/Merges?.*;")
+                ""))
+             #t))
+         (add-after 'disable-failing-tests 'patch-install-dir
+           (lambda* (#:key outputs #:allow-other-keys)
+             (substitute* "data/meson.build"
+               (("/etc")
+                (string-append (assoc-ref outputs "out")
+                               "/etc")))
+             #t)))))
+    (native-inputs
+     `(("cmake" ,cmake)
+       ("docbook-xml-4.3" ,docbook-xml-4.3)
+       ("docbook-xml" ,docbook-xml)
+       ("docbook-xsl" ,docbook-xsl)
+       ("gettext" ,gettext-minimal)
+       ("glib:bin" ,glib "bin")
+       ("gobject-introspection" ,gobject-introspection)
+       ("gperf" ,gperf)
+       ("gtk-doc" ,gtk-doc)
+       ("pkg-config" ,pkg-config)
+       ("python" ,python-wrapper)
+       ("xsltproc" ,libxslt)))
+    (inputs
+     `(("libsoup" ,libsoup)
+       ("libstemmer" ,libstemmer)
+       ("libxml2" ,libxml2)
+       ("libyaml" ,libyaml)
+       ("lmdb" ,lmdb)))
+    (propagated-inputs
+     `(("glib" ,glib)))
+    (synopsis "Tools and libraries to work with AppStream metadata")
+    (description "AppStream is a cross-distribution effort for enhancing the way
+we interact with the software repositories provided by distributions by
+standardizing software component metadata.  It provides the foundation to build
+software-center applications, by providing metadata necessary for an
+application-centric view on package repositories.  It additionally provides
+specifications for things like an unified software metadata database, screenshot
+services and various other things needed to create user-friendly
+application-centers for distributions.")
+    (home-page "https://www.freedesktop.org/wiki/Distributions/AppStream/")
+    (license license:gpl2+)))
+
 (define-public farstream
   (package
     (name "farstream")
-- 
2.30.1

From 583680270594522b0061d8c5a0f13067180de7a8 Mon Sep 17 00:00:00 2001
From: Raghav Gururajan <[email-masked]>
Date: Tue, 9 Mar 2021 02:14:56 -0500
Subject: [PATCH 2/3] gnu: Add qtsolutions.

* gnu/packages/qt.scm (qtsolutions): New variable.
---
 gnu/packages/qt.scm | 120 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)

diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index 11e69ff5db..4ff1e6a005 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -105,6 +105,126 @@
   #:use-module (gnu packages xml)
   #:use-module (srfi srfi-1))
 
+(define-public qtsolutions
+  (let ((commit "9568abd142d581b67b86a5f63d823a34b0612702")
+        (revision "53"))
+    (package
+      (name "qtsolutions")
+      (version
+       (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri
+          (git-reference
+           (url "https://github.com/qtproject/qt-solutions")
+           (commit commit)))
+         (file-name
+          (git-file-name name version))
+         (sha256
+          (base32 "17fnmassflm3vxi0krpr6fff368jy38cby31a48rban4nqqmgx7n"))
+         (modules '((guix build utils)
+                    (ice-9 ftw)
+                    (srfi srfi-1)))
+         (snippet
+          ;; Unvendor QtLockFile from QtSingleApplication.
+          `(begin
+             (with-directory-excursion "qtsingleapplication/src"
+               (for-each delete-file
+                         (find-files "." "qtlockedfile.*\\.(h|cpp)"))
+                 (substitute* "qtsingleapplication.pri"
+                   ;; Add include path of LockedFile.
+                   (("INCLUDEPATH \\+=")
+                    "INCLUDEPATH += ../../qtlockedfile/src")
+                   ;; Link library of LockedFile.
+                   (("LIBS \\+=")
+                    "LIBS += -lQtSolutions_LockedFile"))
+                 (substitute* '("qtlocalpeer.h" "qtlocalpeer.cpp")
+                   ;; Remove references to deleted LockedFile sources.
+                   (("#include \"qtlockedfile.cpp\"")
+                    "")
+                   (("#include \"qtlockedfile_win.cpp\"")
+                    "")
+                   (("#include \"qtlockedfile_unix.cpp\"")
+                    "")
+                   ;; Fix LockedFile API.
+                   (("QtLP_Private::QtLockedFile")
+                    "QtLockedFile")))
+             #t))))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:tests? #f                    ; No target
+         #:imported-modules
+         ((guix build copy-build-system)
+          ,@%gnu-build-system-modules)
+         #:modules
+         (((guix build copy-build-system)
+           #:prefix copy:)
+          (guix build gnu-build-system)
+          (guix build utils))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'patch-source
+             (lambda* (#:key outputs #:allow-other-keys)
+               (substitute* (find-files "." "common.pri")
+                 ;; Remove prefix in library names.
+                 (("qt5") "qt")
+                 ;; Remove suffix in library names.
+                 (("-head") ""))
+               ;; Disable building of examples.
+               (substitute* (find-files "." "\\.pro$")
+                 (("SUBDIRS\\+=examples") ""))
+               ;; Fix deprecated functions.
+               (substitute* "qtsoap/src/qtsoap.cpp"
+                 (("toAscii") "toUtf8"))
+               #t))
+           (replace 'configure
+             (lambda _
+               (for-each (lambda (solution)
+                           (with-directory-excursion solution
+                             (invoke "./configure" "-library")
+                             (invoke "qmake")))
+                         '("qtlockedfile" "qtpropertybrowser" "qtservice"
+                           "qtsingleapplication" "qtsoap"))
+               #t))
+           (replace 'build
+             (lambda _
+               (for-each (lambda (solution)
+                           (with-directory-excursion solution
+                             (invoke "make")))
+                         '("qtlockedfile" "qtpropertybrowser" "qtservice"
+                           "qtsingleapplication" "qtsoap"))
+               #t))
+           (replace 'install
+             (lambda args
+               (for-each (lambda (solution)
+                           (with-directory-excursion solution
+                             (apply (assoc-ref copy:%standard-phases 'install)
+                                    #:install-plan
+                                    '(("src" "include"
+                                       #:include-regexp ("\\.h$"))
+                                      ("lib" "lib"))
+                                    args)))
+                         '("qtlockedfile" "qtpropertybrowser" "qtservice"
+                           "qtsingleapplication" "qtsoap")))))))
+      (inputs
+       `(("qtbase" ,qtbase)))
+      (synopsis "Qt Solutions")
+      (description "QtSolutions are set of components that extends Qt.
+@itemize
+@item QtLockedFile: A class that extends QFile with advisory locking functions.
+@item QtPropertyBrowser: A framework that enables the user to edit a set of
+properties.
+@item QtService: A component useful for developing Windows services and Unix
+daemons.
+@item QtSingleApplication: A component that provides support for applications
+that can be only started once per user.
+@item QtSoap: A component that provides basic web service support with version
+1.1 of the SOAP protocol.
+@end itemize\n")
+      (home-page "https://doc.qt.io/archives/qq/qq09-qt-solutions.html")
+      (license license:lgpl2.1+))))
+
 (define-public qt5ct
   (package
     (name "qt5ct")
-- 
2.30.1

From 573af53f9a5b69b857daefe3d6471eef42783782 Mon Sep 17 00:00:00 2001
From: Raghav Gururajan <[email-masked]>
Date: Tue, 9 Mar 2021 02:19:00 -0500
Subject: [PATCH 3/3] gnu: Add nextcloud-client.

* gnu/packages/messaging.scm (nextcloud-client): New variable.
---
 gnu/packages/sync.scm | 158 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 158 insertions(+)

diff --git a/gnu/packages/sync.scm b/gnu/packages/sync.scm
index d7c9009f3b..875af6da5a 100644
--- a/gnu/packages/sync.scm
+++ b/gnu/packages/sync.scm
@@ -30,6 +30,7 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system meson)
+  #:use-module (guix build-system qt)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix packages)
@@ -42,8 +43,11 @@
   #:use-module (gnu packages crypto)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages documentation)
+  #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnome)
   #:use-module (gnu packages golang)
+  #:use-module (gnu packages graphviz)
   #:use-module (gnu packages image)
   #:use-module (gnu packages kde-frameworks)
   #:use-module (gnu packages linux)
@@ -52,15 +56,169 @@
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages qt)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages rsync)
+  #:use-module (gnu packages ruby)
   #:use-module (gnu packages selinux)
   #:use-module (gnu packages shells)
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tls))
 
+(define-public nextcloud-client
+  (package
+    (name "nextcloud-client")
+    (version "3.1.3")
+    (source
+     (origin
+       (method git-fetch)
+       (uri
+        (git-reference
+         (url "https://github.com/nextcloud/desktop")
+         (commit
+          (string-append "v" version))))
+       (file-name
+        (git-file-name name version))
+       (sha256
+        (base32 "15ymk3gvfmgwzmqbhlw7jjy9y65ib3391h1dlmpll65iaj2miajk"))
+       (modules '((guix build utils)
+                  (ice-9 ftw)
+                  (srfi srfi-1)))
+       (snippet
+        `(begin
+           ;; Not available in Guix.
+           (let* ((keep '("QProgressIndicator" "qtokenizer")))
+             (with-directory-excursion "src/3rdparty"
+               (for-each delete-file-recursively
+                         (lset-difference string=?
+                                          (scandir ".")
+                                          (cons* "." ".." keep)))))
+           (with-directory-excursion "src/gui"
+             (substitute* "CMakeLists.txt"
+               ;; Remove references of deleted 3rdparties.
+               (("[ \t]*\\.\\./3rdparty/qtlockedfile/?.*\\.cpp")
+                "")
+               (("[ \t]*\\.\\./3rdparty/qtsingleapplication/?.*\\.cpp")
+                "")
+               (("[ \t]*\\.\\./3rdparty/kmessagewidget/?.*\\.cpp")
+                "")
+               (("[ \t]*list\\(APPEND 3rdparty_SRC \\.\\./3rdparty/?.*\\)")
+                "")
+               (("\\$\\{CMAKE_SOURCE_DIR\\}/src/3rdparty/qtlockedfile")
+                "")
+               (("\\$\\{CMAKE_SOURCE_DIR\\}/src/3rdparty/qtsingleapplication")
+                "")
+               ;; Patch include reference of KMessageWidget,
+               ;; to point to KWidgetsAddons, instead of 3rdparty.
+               (("\\$\\{CMAKE_SOURCE_DIR\\}/src/3rdparty/kmessagewidget")
+                "@kwidgetsaddons@/include/KF5/KWidgetsAddons/")
+               ;; Link libraries from inputs, that were deleted in 3rdparty,
+               ;; to wherever synclib gets linked.
+               (("\\$\\{synclib_NAME\\}")
+                (string-append "${synclib_NAME} "
+                               "QtSolutions_LockedFile "
+                               "QtSolutions_SingleApplication "
+                               "KF5WidgetsAddons")))
+             ;; Fix compatibility with QtSingleApplication from QtSolutions.
+             (substitute* '("application.h" "application.cpp")
+               (("SharedTools::QtSingleApplication")
+                "QtSingleApplication")
+               (("slotParseMessage\\(const QString &(msg)?.*\\)")
+                "slotParseMessage(const QString &msg)")))
+           #t))))
+    (build-system qt-build-system)
+    (arguments
+     `(#:configure-flags
+       (list
+        "-DUNIT_TESTING=ON"
+        ;; Upstream Bug: https://github.com/nextcloud/desktop/issues/2885
+        "-DNO_SHIBBOLETH=ON")
+       #:imported-modules
+       ((guix build glib-or-gtk-build-system)
+        ,@%qt-build-system-modules)
+       #:modules
+       (((guix build glib-or-gtk-build-system)
+         #:prefix glib-or-gtk:)
+        (guix build qt-build-system)
+        (guix build utils))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-cmake
+           (lambda* (#:key outputs #:allow-other-keys)
+             ;; Patch install directory for dbus service files.
+             (substitute* "shell_integration/libcloudproviders/CMakeLists.txt"
+               (("PKGCONFIG_GETVAR\\(.+ _install_dir\\)")
+                (string-append "set(_install_dir \"${CMAKE_INSTALL_PREFIX}"
+                               "/share/dbus-1/services\")")))
+             ;; Make sure, that Qt modules are installed under $prefix.
+             (substitute* "shell_integration/dolphin/CMakeLists.txt"
+               (("ON CACHE")
+                "OFF CACHE"))
+             #t))
+         (add-before 'check 'pre-check
+           (lambda _
+             ;; Tests write to $HOME.
+             (setenv "HOME" (getcwd))
+             #t))
+         (add-after 'install 'glib-or-gtk-compile-schemas
+           (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
+         (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
+           (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
+    (native-inputs
+     `(("cmocka" ,cmocka)
+       ("dot" ,graphviz)
+       ("doxygen" ,doxygen)
+       ("extra-cmake-modules" ,extra-cmake-modules)
+       ("glib:bin" ,glib "bin")
+       ("perl" ,perl)
+       ("pkg-config" ,pkg-config)
+       ("python" ,python-wrapper)
+       ("qttools" ,qttools)
+       ("ruby" ,ruby)))
+    (inputs
+     `(("appstream" ,appstream)
+       ("desktop-file-utils" ,desktop-file-utils)
+       ("glib" ,glib)
+       ("kconfig" ,kconfig)
+       ("kcoreaddons" ,kcoreaddons)
+       ("kio" ,kio)
+       ("kjs" ,kjs)
+       ("kwidgetsaddons" ,kwidgetsaddons)
+       ("libcloudproviders" ,libcloudproviders)
+       ("libzip" ,libzip)
+       ("openssl" ,openssl)
+       ("python-nautilus" ,python-nautilus)
+       ("qtbase" ,qtbase)
+       ("qtdeclarative" ,qtdeclarative)
+       ("qtgraphicaleffects" ,qtgraphicaleffects)
+       ("qtkeychain" ,qtkeychain)
+       ("qtquickcontrols2" ,qtquickcontrols2)
+       ("qtsolutions" ,qtsolutions)
+       ("qtsvg" ,qtsvg)
+       ("qtwebchannel" ,qtwebchannel)
+       ("qtwebsockets" ,qtwebsockets)
+       ("qtwebkit" ,qtwebkit)
+       ("sqlite" ,sqlite)
+       ("xdg-utils" ,xdg-utils)
+       ("zlib" ,zlib)))
+    (propagated-inputs
+     `(("qtwebengine" ,qtwebengine)))
+    (synopsis "Desktop sync client for Nextcloud")
+    (description "Nextcloud-Desktop is a tool to synchronize files from
+Nextcloud Server with your computer.")
+    (home-page "https://nextcloud.com/install/#install-clients")
+    (license
+     (list
+      ;; QtProgressIndicator
+      license:expat
+      ;; Qtokenizer
+      license:lgpl2.1+
+      ;; Others
+      license:gpl2+))))
+
 (define-public megacmd
   (package
     (name "megacmd")
-- 
2.30.1