gnu: tigervnc-server: Move source production into origin snippet.

This will make it possible to patch command references in source files, and
also makes it more transparent as to what sources get used.

* gnu/packages/vnc.scm (tigervnc-server): Re-flow comment.
[source]: Inherit from xorg-server.  Add a snippet.  Use a patch to apply the
xserver patch.  Fix file name.
[phases]{copy-tvnc-xserver, patch-xserver}: Delete phases.
{build-tigervnc, install-tigervnc-aux}: Adjust accordingly.
This commit is contained in:
Maxim Cournoyer 2022-07-28 15:44:49 -04:00
parent c93b249dc0
commit 0debec9f2d
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -210,20 +210,49 @@ (define-public tigervnc-client
(define %tigervnc-client-source (package-source tigervnc-client))
;; A VNC server is, in fact, an X server so it seems like a good idea
;; to build on the work already done for xorg-server package. This is
;; not entirely compatible with the recommendation in BUILDING.txt
;; where the client is built first, then the source code of the X
;; server is copied into a subdir of the build directory, patched with
;; VNC additions and then build and installed as Xvnc. The procedure
;; was turned around, where TigerVNC code is downloaded and built
;; inside the Guix X server build dir. Also, the VNC patching process
;; for the X server is automated in a straightforward manner.
;; A VNC server is, in fact, an X server so it seems like a good idea to build
;; on the work already done for xorg-server package. This is not entirely
;; compatible with the recommendation in BUILDING.txt where the client is
;; built first, then the source code of the X server is copied into a subdir
;; of the build directory, patched with VNC additions and then build and
;; installed as Xvnc. The procedure was turned around, where TigerVNC code is
;; downloaded and built inside the Guix X server build dir. Also, the VNC
;; patching process for the X server is automated in a straightforward manner.
(define-public tigervnc-server
(package
(inherit xorg-server)
(name "tigervnc-server")
(version (package-version tigervnc-client))
(source
(origin
(inherit (package-source xorg-server))
(modules '((guix build utils)))
(snippet
#~(begin
;; Copy the VNC extension into the xorg-server sources.
(copy-recursively #$(file-append %tigervnc-client-source
"/unix/xserver")
".")
;; Include a full copy of tigervnc-client sources, so that the
;; complete sources involved are available and can be edited during
;; the build.
(copy-recursively #$%tigervnc-client-source "tigervnc-client")
;; Adjust the VNC extension build system files so that it refers
;; to it.
(substitute* "hw/vnc/Makefile.am"
(("(TIGERVNC_SRCDIR=).*" _ head)
(string-append head "$(CURDIR)/../../tigervnc-client\n"))
(("(TIGERVNC_BUILDDIR=).*" _ head)
(string-append head
"$(CURDIR)/../../tigervnc-client/build\n")))
;; Ensure the Autotools build system gets re-bootstrapped.
(delete-file "configure")))
;; Patch the xorg-server build system so that it builds the VNC
;; extension.
(patches (cons (file-append %tigervnc-client-source
"/unix/xserver21.1.1.patch")
(origin-patches (package-source xorg-server))))
(file-name (string-append name "-" version ".tar.xz"))))
(arguments
(substitute-keyword-arguments
(package-arguments xorg-server)
@ -254,28 +283,13 @@ (define-public tigervnc-server
((#:phases phases)
#~(modify-phases #$phases
(delete 'check) ;no test suite
(add-after 'unpack 'copy-tvnc-xserver
(lambda* (#:key inputs #:allow-other-keys)
(copy-recursively (search-input-directory inputs "unix/xserver")
".")
;; Adjust Makefile variables default values to simplify usage.
(substitute* "hw/vnc/Makefile.am"
(("(TIGERVNC_SRCDIR=).*" _ head)
(string-append head #$%tigervnc-client-source "\n"))
(("(TIGERVNC_BUILDDIR=).*" _ head)
(string-append head (getcwd) "/tigervnc-build\n")))))
(add-after 'copy-tvnc-xserver 'patch-xserver
(lambda* (#:key inputs #:allow-other-keys)
(invoke "patch" "-p1" "-i"
(search-input-file inputs "unix/xserver21.1.1.patch"))
(invoke "autoreconf" "-fiv")))
(add-before 'build 'build-tigervnc
(lambda* (#:key parallel-build? #:allow-other-keys)
(mkdir-p "tigervnc-build")
(with-directory-excursion "tigervnc-build"
(mkdir-p "tigervnc-client/build")
(with-directory-excursion "tigervnc-client/build"
(invoke "cmake" "-G" "Unix Makefiles"
(string-append "-DCMAKE_INSTALL_PREFIX=" #$output)
#$%tigervnc-client-source)
"..")
(invoke "make" "-j" (number->string (if parallel-build?
(parallel-job-count)
1))))))
@ -286,7 +300,7 @@ (define-public tigervnc-server
1)))))
(add-before 'install 'install-tigervnc-aux
(lambda _
(invoke "make" "-C" "tigervnc-build/unix" "install")))
(invoke "make" "-C" "tigervnc-client/build/unix" "install")))
(replace 'install
(lambda _
(invoke "make" "install")))))))