Subject: [bug#67257] [PATCH 2/2] Add x2goclient

From: nicodebo <[email-masked]>
Date: Sat, 18 Nov 2023 08:59:18 +0100

From: nicodebo <[email-masked]>

Change-Id: Ib0ff6328ede3fb4a0b48462ac1a003438c53c862
---
 gnu/packages/nx.scm | 89 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)

diff --git a/gnu/packages/nx.scm b/gnu/packages/nx.scm
index 9a2ec68ee9..dd336b309f 100644
--- a/gnu/packages/nx.scm
+++ b/gnu/packages/nx.scm
@@ -16,19 +16,25 @@
 (define-module (gnu packages nx)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages commencement)
+  #:use-module (gnu packages cups)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages image)
+  #:use-module (gnu packages man)
   #:use-module (gnu packages onc-rpc)
+  #:use-module (gnu packages openldap)
   #:use-module (gnu packages patchutils)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages qt)
+  #:use-module (gnu packages ssh)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg)
   #:use-module (guix build utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix licenses)
   #:use-module (guix packages))
@@ -138,3 +144,86 @@ (define-public nx-libs
 developpers and TheQVD.")
     (home-page "https://github.com/ArcticaProject/nx-libs")
     (license gpl2)))
+
+(define-public x2goclient
+  (package
+    (name "x2goclient")
+    (version "4.1.2.3")
+    (source
+     (origin
+       (method url-fetch)
+       ;; the tar.gz was checked against x2goclient-4.1.2.3.tar.gz.md5
+       ;; provided by x2go team
+       (uri (string-append
+             "https://code.x2go.org/releases/source/x2goclient/x2goclient-"
+             version ".tar.gz"))
+       (sha256
+        (base32 "0g6aba8kpsixq4486a8mga945lp31y0mzwa2krs5qqiiip3v72xb"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f
+       #:phases (modify-phases %standard-phases
+                  (delete 'configure)
+                  (add-before 'build 'fix-makefile
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let* ((out (assoc-ref outputs "out"))
+                             (etc (string-append out "/etc")))
+                        (mkdir-p etc)
+                        (substitute* "Makefile"
+                          (("= 4")
+                           "= 5") ;use qt5 instead of qt4
+                          (("-o root -g root") ;from archlinux
+                           "")
+                          (("/usr/local")
+                           out)
+                          (("/etc/x2go")
+                           etc)
+                          ;; KLUDGE part1 (from guix package smplayer)
+                          ;; A KLUDGE to turn off invoking lrelease on the
+                          ;; project for now, because it fails consistently
+                          ;; with "WARNING: Could not find qmake spec
+                          ;; 'default'". See below.
+                          (("lrelease")
+                           "true")
+                          (("qmake")
+                           (which "qmake")))
+                        (substitute* "src/onmainwindow.cpp"
+                          (("/usr/sbin/sshd")
+                           (which "sshd"))) ;x2goclient nix package does this substitution
+                        #t)))
+                  ;; I could not succeed in packaging the man2html program
+                  ;; needed to build the html version of the documentation.
+                  ;; That's why instead of running the bare make which needs
+                  ;; man2html in one of its target, I run build_client then install_man.
+                  (replace 'build
+                    (lambda _
+                      (invoke "make" "build_client") #t))
+                  (add-after 'build 'build-man
+                    (lambda _
+                      (invoke "make" "install_man") #t))
+                  ;; KLUDGE part2
+                  ;; Due to the above, we must run lrelease separately on each .ts file
+                  ;; (as opposed to running `lrelease-pro smplayer.pro` for the entire
+                  ;; project, as the Makefile does normally without the above kludge).
+                  (add-after 'build 'compile-ts-files
+                    (lambda _
+                      (for-each (lambda (file)
+                                  (invoke "lrelease" file))
+                                (find-files "./" "\\.ts$")))))))
+    (native-inputs (list pkg-config
+                         qttools-5
+                         qtbase-5
+                         qtx11extras
+                         qtsvg-5
+                         libssh
+                         cups
+                         libxpm
+                         openldap
+                         gcc-toolchain))
+    (propagated-inputs (list perl nx-libs openssh xauth))
+    (synopsis "Remote Desktop/Remote Application solution")
+    (description
+     "x2goclient allows you to connect to a remote graphical desktop over the
+network through ssh")
+    (home-page "http://x2go.org/")
+    (license gpl2)))
-- 
2.41.0