Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / vnc.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Todor Kondić <tk.code@protonmail.com>
3 ;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
4 ;;; Copyright © 2020 Hartmut Goebel <h.goebel@crazy-compilers.com>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages vnc)
22 #:use-module (guix build-system cmake)
23 #:use-module (guix download)
24 #:use-module (guix git-download)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix utils)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages autotools)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages cmake)
32 #:use-module (gnu packages commencement)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages fltk)
35 #:use-module (gnu packages gettext)
36 #:use-module (gnu packages gnupg)
37 #:use-module (gnu packages image)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages perl)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages sdl)
42 #:use-module (gnu packages tls)
43 #:use-module (gnu packages xorg))
44
45 (define-public tigervnc-client
46 (package
47 (name "tigervnc-client")
48 (version "1.10.1")
49 (source
50 (origin
51 (method git-fetch)
52 (uri
53 (git-reference
54 (url "https://github.com/TigerVNC/tigervnc.git")
55 (commit (string-append "v" version))))
56 (file-name (git-file-name name version))
57 (sha256
58 (base32
59 "001n189d2f3psn7nxgl8188ml6f7jbk26cxn2835y3mnlk5lmhgr"))))
60 (build-system cmake-build-system)
61 (arguments
62 '(#:tests? #f ; Tests that do exists are not automated.
63 #:phases (modify-phases %standard-phases
64 (replace 'install
65 (lambda* (#:key outputs #:allow-other-keys)
66 (with-directory-excursion "vncviewer"
67 (invoke "make" "install")))))))
68 (native-inputs
69 `(("autoconf" ,autoconf)
70 ("gettext-minimal" ,gettext-minimal)
71 ("automake" ,automake)))
72 (inputs
73 `(("zlib" ,zlib)
74 ("gnutls" ,gnutls)
75 ("libjpeg-turbo" ,libjpeg-turbo)
76 ("fltk" ,fltk)
77 ("linux-pam" ,linux-pam)
78 ("libx11" ,libx11)
79 ("libxext" ,libxext)
80 ("libxtst" ,libxtst)
81 ("libxrandr" ,libxrandr)
82 ("libxdamage" ,libxdamage)))
83 (home-page "https://tigervnc.org/")
84 (synopsis "High-performance, platform-neutral
85 implementation of VNC (client)")
86 (description "TigerVNC is a client/server implementation of VNC (Virtual
87 Network Computing). It provides enough performance to run even 3D and video
88 applications. It also provides extensions for advanced authentication methods
89 and TLS encryption. This package installs only the VNC client, the
90 application which is needed to connect to VNC servers.")
91 (license license:gpl2)))
92
93 ;; A VNC server is, in fact, an X server so it seems like a good idea
94 ;; to build on the work already done for xorg-server package. This is
95 ;; not entirely compatible with the recommendation in BUILDING.txt
96 ;; where the client is built first, then the source code of the X
97 ;; server is copied into a subdir of the build directory, patched with
98 ;; VNC additions and then build and installed as Xvnc. The procedure
99 ;; was turned around, where TigerVNC code is downloaded and built
100 ;; inside the Guix X server build dir. Also, the VNC patching process
101 ;; for the X server is automated in a straightforward manner.
102 (define-public tigervnc-server
103 (package
104 (inherit xorg-server)
105 (name "tigervnc-server")
106 (version "1.10.1")
107 (native-inputs
108 `(("tigervnc-src" ,(origin
109 (method git-fetch)
110 (uri
111 (git-reference
112 (url "https://github.com/TigerVNC/tigervnc.git")
113 (commit "v1.9.0")))
114 (sha256
115 (base32
116 "0b47fg3741qs3zdpl2zr0s6jz46dypp2j6gqrappbzm3ywnnmm1x"))))
117 ("autoconf" ,autoconf)
118 ("automake" ,automake)
119 ("libtool" ,libtool)
120 ("gettext-minimal" ,gettext-minimal)
121 ("font-util" ,font-util)
122 ("cmake" ,cmake)
123 ("gcc-toolchain" ,gcc-toolchain)
124 ("perl" ,perl)
125 ,@(package-native-inputs tigervnc-client)
126 ,@(package-inputs tigervnc-client)
127 ,@(package-native-inputs xorg-server)))
128 (inputs
129 `(("perl" ,perl)
130 ("coreutils" ,coreutils)
131 ("xauth" ,xauth)
132 ,@(package-inputs xorg-server)))
133 (propagated-inputs
134 `(("xauth" ,xauth)
135 ,@(package-propagated-inputs xorg-server)))
136 (arguments
137 (substitute-keyword-arguments
138 (package-arguments xorg-server)
139 ((#:configure-flags flags)
140 `(append '("--with-pic" ; Taken from BUILDING.txt
141 "--without-dtrace"
142 "--disable-static"
143 "--disable-dri2"
144 "--disable-xinerama"
145 "--disable-xvfb"
146 "--disable-xnest"
147 "--disable-xorg"
148 "--disable-dmx"
149 "--disable-xwin"
150 "--disable-xephyr"
151 "--disable-kdrive"
152 ;; "--disable-config-dbus" ; This was a warning.
153 "--disable-config-hal"
154 "--disable-config-udev"
155 "--disable-dri2"
156 ;; "--enable-install-libxf86config" ; This, too, was a warning.
157 "--enable-glx")
158 (delete "--enable-xephyr" ,flags)))
159 ((#:modules modules)
160 `(append '((ice-9 ftw)
161 (ice-9 match)
162 (guix build utils)
163 (guix build gnu-build-system))
164 modules))
165 ((#:phases phases)
166 `(modify-phases ,phases
167 (delete 'check) ;)
168 (add-after 'unpack 'copy-tvnc-xserver
169 (lambda _
170 (let*
171 ((tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
172 (tvnc-xserver (string-append tvnc-src "/unix/xserver")))
173 (copy-recursively tvnc-xserver ".")
174 #t)))
175 (add-after 'copy-tvnc-xserver 'patch-xserver
176 (lambda _
177 (let*
178 ((tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
179 (xorg-server-version ,(package-version xorg-server))
180 (which-patch (lambda ()
181 (let*
182 ((patch-num (apply string-append
183 (list-head (string-split xorg-server-version
184 #\.)
185 2)))
186 (fn (format "~a/unix/xserver~a.patch" tvnc-src patch-num)))
187 (when (not (file-exists? fn))
188 (error (format "Patch file, ~a,
189 corresponding to the input xorg-server version, does not exist. Installation
190 will fail. " fn)))
191
192 fn))) ; VNC patches for xserver have the
193 ; form xserverXY[Y].patch, where
194 ; X.Y[Y].Z is the Xorg server
195 ; version.
196 (xserver-patch (which-patch)))
197 (invoke "patch" "-p1" "-i" xserver-patch)
198 (invoke "autoreconf" "-fiv"))))
199 (add-before 'build 'build-tigervnc
200 (lambda _
201 (let* ((out (assoc-ref %outputs "out"))
202 (tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
203 (tvnc-build (string-append (getcwd) "/tigervnc-build")))
204 (mkdir-p tvnc-build)
205 (with-directory-excursion tvnc-build
206 (invoke "cmake" "-G" "Unix Makefiles"
207 (string-append "-DCMAKE_INSTALL_PREFIX=" out)
208 tvnc-src)
209 (invoke "make" "-j" (number->string (parallel-job-count)))))))
210 (replace 'build
211 (lambda _
212 (let* ((tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
213 (tvnc-build (string-append (getcwd) "/tigervnc-build"))
214 (srcarg (string-append "TIGERVNC_SRCDIR=" tvnc-src))
215 (buildarg (string-append "TIGERVNC_BUILDDIR=" tvnc-build)))
216 (invoke "make" srcarg buildarg "-j"
217 (number->string (parallel-job-count))))))
218 (add-before 'install 'install-tigervnc-aux
219 (lambda _
220 (let* ((out (assoc-ref %outputs 'out))
221 (tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
222 (tvnc-build (string-append (getcwd) "/tigervnc-build"))
223 (srcarg (string-append "TIGERVNC_SRCDIR=" tvnc-src))
224 (buildarg (string-append "TIGERVNC_BUILDDIR=" tvnc-build)))
225 (with-directory-excursion (string-append tvnc-build "/unix")
226 (invoke "make" srcarg buildarg "install")))))
227 (replace 'install
228 (lambda* _
229 (let* ((tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
230 (tvnc-build (string-append (getcwd) "/tigervnc-build"))
231 (srcarg (string-append "TIGERVNC_SRCDIR=" tvnc-src))
232 (buildarg (string-append "TIGERVNC_BUILDDIR=" tvnc-build)))
233 (invoke "make" "install" srcarg buildarg))))))))
234 (description "TigerVNC is a client/server implementation of VNC (Virtual
235 Network Computing). It provides enough performance to run even 3D and video
236 applications. It also provides extensions for advanced authentication methods
237 and TLS encryption. This package installs the VNC server, a program that will
238 enable users with VNC clients to log into a graphical session on the machine
239 where the server is installed.")))
240
241 (define-public libvnc
242 (package
243 (name "libvnc")
244 (version "0.9.12")
245 (source
246 (origin
247 (method git-fetch)
248 (uri (git-reference
249 (url "https://github.com/LibVNC/libvncserver.git")
250 (commit (string-append "LibVNCServer-" version))))
251 (file-name (git-file-name name version))
252 (sha256
253 (base32 "1226hb179l914919f5nm2mlf8rhaarqbf48aa649p4rwmghyx9vm"))
254 (patches (search-patches "libvnc-CVE-2018-20750.patch"
255 "libvnc-CVE-2019-15681.patch"))))
256 (build-system cmake-build-system)
257 (native-inputs
258 `(("pkg-config" ,pkg-config)))
259 (inputs
260 `(("gnutls" ,gnutls)
261 ("libgcrypt" ,libgcrypt)
262 ("libjpeg" ,libjpeg-turbo)
263 ("libpng" ,libpng)
264 ("lzo" ,lzo)
265 ("sdl2" ,sdl2)))
266 (home-page "https://libvnc.github.io/")
267 (synopsis "Cross-platform C libraries for implementing VNC server or
268 client")
269 (description "This package provides @code{LibVNCServer} and
270 @code{LibVNCClient}. These are cross-platform C libraries that allow you to
271 easily implement VNC server or client functionality in your program.")
272 (license ;; GPL for programs, FDL for documentation
273 (list license:gpl2+ license:fdl1.2+))))