gnu: qemu: Fix CVE-2021-20203.
[jackhill/guix/guix.git] / gnu / packages / virtualization.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015, 2016, 2017, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016, 2017, 2018. 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
6 ;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
7 ;;; Copyright © 2017 Andy Patterson <ajpatter@uwaterloo.ca>
8 ;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
9 ;;; Copyright © 2017–2021 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
11 ;;; Copyright © 2018 Sou Bunnbu <iyzsong@member.fsf.org>
12 ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
13 ;;; Copyright © 2019 Guy Fleury Iteriteka <hoonandon@gmail.com>
14 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
15 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
16 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
17 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
18 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
19 ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
20 ;;;
21 ;;; This file is part of GNU Guix.
22 ;;;
23 ;;; GNU Guix is free software; you can redistribute it and/or modify it
24 ;;; under the terms of the GNU General Public License as published by
25 ;;; the Free Software Foundation; either version 3 of the License, or (at
26 ;;; your option) any later version.
27 ;;;
28 ;;; GNU Guix is distributed in the hope that it will be useful, but
29 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
30 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 ;;; GNU General Public License for more details.
32 ;;;
33 ;;; You should have received a copy of the GNU General Public License
34 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
35
36 (define-module (gnu packages virtualization)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages admin)
39 #:use-module (gnu packages assembly)
40 #:use-module (gnu packages attr)
41 #:use-module (gnu packages autotools)
42 #:use-module (gnu packages backup)
43 #:use-module (gnu packages base)
44 #:use-module (gnu packages bison)
45 #:use-module (gnu packages check)
46 #:use-module (gnu packages cmake)
47 #:use-module (gnu packages compression)
48 #:use-module (gnu packages cross-base)
49 #:use-module (gnu packages curl)
50 #:use-module (gnu packages cyrus-sasl)
51 #:use-module (gnu packages debian)
52 #:use-module (gnu packages disk)
53 #:use-module (gnu packages dns)
54 #:use-module (gnu packages docbook)
55 #:use-module (gnu packages documentation)
56 #:use-module (gnu packages figlet)
57 #:use-module (gnu packages firmware)
58 #:use-module (gnu packages flex)
59 #:use-module (gnu packages fontutils)
60 #:use-module (gnu packages freedesktop)
61 #:use-module (gnu packages gettext)
62 #:use-module (gnu packages gl)
63 #:use-module (gnu packages glib)
64 #:use-module (gnu packages gnome)
65 #:use-module (gnu packages gnupg)
66 #:use-module (gnu packages golang)
67 #:use-module (gnu packages graphviz)
68 #:use-module (gnu packages gtk)
69 #:use-module (gnu packages haskell)
70 #:use-module (gnu packages haskell-apps)
71 #:use-module (gnu packages haskell-check)
72 #:use-module (gnu packages haskell-crypto)
73 #:use-module (gnu packages haskell-web)
74 #:use-module (gnu packages haskell-xyz)
75 #:use-module (gnu packages image)
76 #:use-module (gnu packages libbsd)
77 #:use-module (gnu packages libusb)
78 #:use-module (gnu packages linux)
79 #:use-module (gnu packages m4)
80 #:use-module (gnu packages ncurses)
81 #:use-module (gnu packages nettle)
82 #:use-module (gnu packages networking)
83 #:use-module (gnu packages onc-rpc)
84 #:use-module (gnu packages package-management)
85 #:use-module (gnu packages perl)
86 #:use-module (gnu packages pkg-config)
87 #:use-module (gnu packages polkit)
88 #:use-module (gnu packages protobuf)
89 #:use-module (gnu packages python)
90 #:use-module (gnu packages python-build)
91 #:use-module (gnu packages python-check)
92 #:use-module (gnu packages python-crypto)
93 #:use-module (gnu packages python-web)
94 #:use-module (gnu packages python-xyz)
95 #:use-module (gnu packages pulseaudio)
96 #:use-module (gnu packages selinux)
97 #:use-module (gnu packages sdl)
98 #:use-module (gnu packages sphinx)
99 #:use-module (gnu packages spice)
100 #:use-module (gnu packages ssh)
101 #:use-module (gnu packages texinfo)
102 #:use-module (gnu packages textutils)
103 #:use-module (gnu packages tls)
104 #:use-module (gnu packages web)
105 #:use-module (gnu packages wget)
106 #:use-module (gnu packages xdisorg)
107 #:use-module (gnu packages xml)
108 #:use-module (gnu packages xorg)
109 #:use-module (guix build-system cmake)
110 #:use-module (guix build-system gnu)
111 #:use-module (guix build-system go)
112 #:use-module (guix build-system meson)
113 #:use-module (guix build-system python)
114 #:use-module (guix build-system trivial)
115 #:use-module (guix download)
116 #:use-module (guix git-download)
117 #:use-module ((guix licenses) #:prefix license:)
118 #:use-module (guix packages)
119 #:use-module (guix utils)
120 #:use-module (srfi srfi-1)
121 #:use-module (ice-9 match))
122
123 (define (qemu-patch commit file-name sha256-bv)
124 "Return an origin for COMMIT."
125 (origin
126 (method url-fetch)
127 (uri (string-append
128 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
129 commit))
130 (hash (content-hash sha256-bv sha256))
131 (file-name file-name)))
132
133 (define-public qemu
134 (package
135 (name "qemu")
136 (version "5.1.0")
137 (source (origin
138 (method url-fetch)
139 (uri (string-append "https://download.qemu.org/qemu-"
140 version ".tar.xz"))
141 (sha256
142 (base32
143 "1rd41wwlvp0vpialjp2czs6i3lsc338xc72l3zkbb7ixjfslw5y9"))
144 (patches (search-patches "qemu-build-info-manual.patch"
145 "qemu-CVE-2021-20203.patch"))
146 (modules '((guix build utils)))
147 (snippet
148 '(begin
149 ;; Fix a bug in the do_ioctl_ifconf() function of qemu to
150 ;; make ioctl(…, SIOCGIFCONF, …) work for emulated 64 bit
151 ;; architectures. The size of struct ifreq is handled
152 ;; incorrectly.
153 ;; https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg01545.html
154 (substitute* '("linux-user/syscall.c")
155 (("^([[:blank:]]*)const argtype ifreq_arg_type.*$" line indent)
156 (string-append line indent
157 "const argtype ifreq_max_type[] = { MK_STRUCT(STRUCT_ifmap_ifreq) };\n"))
158 (("^([[:blank:]]*)target_ifreq_size[[:blank:]]=.*$" _ indent)
159 (string-append indent "target_ifreq_size = thunk_type_size(ifreq_max_type, 0);")))
160 #t))))
161 (outputs '("out" "doc")) ;4.7 MiB of HTML docs
162 (build-system gnu-build-system)
163 (arguments
164 `(;; FIXME: Disable tests on i686 to work around
165 ;; <https://bugs.gnu.org/40527>.
166 #:tests? ,(or (%current-target-system)
167 (not (string=? "i686-linux" (%current-system))))
168
169 #:configure-flags (list "--enable-usb-redir" "--enable-opengl"
170 "--enable-docs"
171 (string-append "--smbd="
172 (assoc-ref %outputs "out")
173 "/libexec/samba-wrapper")
174 "--audio-drv-list=alsa,pa,sdl")
175 ;; Make build and test output verbose to facilitate investigation upon failure.
176 #:make-flags '("V=1")
177 #:modules ((srfi srfi-1)
178 (ice-9 match)
179 ,@%gnu-build-system-modules)
180 #:phases
181 (modify-phases %standard-phases
182 (add-after 'set-paths 'hide-glibc
183 (lambda* (#:key inputs #:allow-other-keys)
184 ;; Work around https://issues.guix.info/issue/36882. We need to
185 ;; remove glibc from C_INCLUDE_PATH so that the one hardcoded in GCC,
186 ;; at the bottom of GCC include search-path is used.
187 (let* ((filters '("libc"))
188 (input-directories
189 (filter-map (lambda (input)
190 (match input
191 ((name . dir)
192 (and (not (member name filters))
193 dir))))
194 inputs)))
195 (set-path-environment-variable "C_INCLUDE_PATH"
196 '("include")
197 input-directories)
198 #t)))
199 (add-after 'unpack 'extend-test-time-outs
200 (lambda _
201 ;; These tests can time out on heavily-loaded and/or slow storage.
202 (substitute* (cons* "tests/qemu-iotests/common.qemu"
203 (find-files "tests/qemu-iotests" "^[0-9]+$"))
204 (("QEMU_COMM_TIMEOUT=[0-9]+" match)
205 (string-append match "9")))))
206 (add-after 'unpack 'disable-unusable-tests
207 (lambda _
208 (substitute* "tests/Makefile.include"
209 ;; Comment out the test-qga test, which needs /sys and
210 ;; fails within the build environment.
211 (("check-unit-.* tests/test-qga" all)
212 (string-append "# " all))
213 ;; Comment out the test-char test, which needs networking and
214 ;; fails within the build environment.
215 (("check-unit-.* tests/test-char" all)
216 (string-append "# " all)))
217 (substitute* "tests/qtest/Makefile.include"
218 ;; Disable the following test, which triggers a crash on some
219 ;; x86 CPUs (see https://issues.guix.info/43048 and
220 ;; https://bugs.launchpad.net/qemu/+bug/1896263).
221 (("check-qtest-i386-y \\+= bios-tables-test" all)
222 (string-append "# " all)))
223 #t))
224 (add-after 'patch-source-shebangs 'patch-/bin/sh-references
225 (lambda _
226 ;; Ensure the executables created by these source files reference
227 ;; /bin/sh from the store so they work inside the build container.
228 (substitute* '("block/cloop.c" "migration/exec.c"
229 "net/tap.c" "tests/qtest/libqtest.c")
230 (("/bin/sh") (which "sh")))
231 #t))
232 (replace 'configure
233 (lambda* (#:key inputs outputs (configure-flags '())
234 #:allow-other-keys)
235 ;; The `configure' script doesn't understand some of the
236 ;; GNU options. Thus, add a new phase that's compatible.
237 (let ((out (assoc-ref outputs "out")))
238 (setenv "SHELL" (which "bash"))
239
240 ;; While we're at it, patch for tests.
241 (substitute* "tests/qemu-iotests/check"
242 (("#!/usr/bin/env python3")
243 (string-append "#!" (which "python3"))))
244
245 ;; Ensure config.status gets the correct shebang off the bat.
246 ;; The build system gets confused if we change it later and
247 ;; attempts to re-run the whole configury, and fails.
248 (substitute* "configure"
249 (("#!/bin/sh")
250 (string-append "#!" (which "sh"))))
251
252 ;; The binaries need to be linked against -lrt.
253 (setenv "LDFLAGS" "-lrt")
254 (apply invoke
255 `("./configure"
256 ,(string-append "--cc=" (which "gcc"))
257 ;; Some architectures insist on using HOST_CC
258 ,(string-append "--host-cc=" (which "gcc"))
259 "--disable-debug-info" ; save build space
260 "--enable-virtfs" ; just to be sure
261 ,(string-append "--prefix=" out)
262 ,(string-append "--sysconfdir=/etc")
263 ,@configure-flags)))))
264 ;; Create a wrapper for Samba. This allows QEMU to use Samba without
265 ;; pulling it in as an input. Note that you need to explicitly install
266 ;; Samba in your Guix profile for Samba support.
267 (add-after 'install 'create-samba-wrapper
268 (lambda* (#:key inputs outputs #:allow-other-keys)
269 (let* ((out (assoc-ref outputs "out"))
270 (libexec (string-append out "/libexec")))
271 (call-with-output-file "samba-wrapper"
272 (lambda (port)
273 (format port "#!/bin/sh
274 exec smbd $@")))
275 (chmod "samba-wrapper" #o755)
276 (install-file "samba-wrapper" libexec))
277 #t))
278 (add-after 'install 'move-html-doc
279 (lambda* (#:key inputs outputs #:allow-other-keys)
280 (let* ((out (assoc-ref outputs "out"))
281 (doc (assoc-ref outputs "doc"))
282 (qemu-doc (string-append doc "/share/doc/qemu-" ,version)))
283 (mkdir-p qemu-doc)
284 (rename-file (string-append out "/share/doc/qemu")
285 (string-append qemu-doc "/html")))
286 #t)))))
287 (inputs ; TODO: Add optional inputs.
288 `(("alsa-lib" ,alsa-lib)
289 ("attr" ,attr)
290 ("glib" ,glib)
291 ("gtk+" ,gtk+)
292 ("libaio" ,libaio)
293 ("libattr" ,attr)
294 ("libcacard" ,libcacard) ; smartcard support
295 ("libcap-ng" ,libcap-ng) ; virtfs support requires libcap-ng & libattr
296 ("libdrm" ,libdrm)
297 ("libepoxy" ,libepoxy)
298 ("libjpeg" ,libjpeg-turbo)
299 ("libpng" ,libpng)
300 ("libseccomp" ,libseccomp)
301 ("libusb" ,libusb) ;USB pass-through support
302 ("mesa" ,mesa)
303 ("ncurses" ,ncurses)
304 ;; ("pciutils" ,pciutils)
305 ("pixman" ,pixman)
306 ("pulseaudio" ,pulseaudio)
307 ("sdl2" ,sdl2)
308 ("spice" ,spice)
309 ("usbredir" ,usbredir)
310 ("util-linux" ,util-linux)
311 ("vde2" ,vde2)
312 ("virglrenderer" ,virglrenderer)
313 ("zlib" ,zlib)))
314 (native-inputs `(("gettext" ,gettext-minimal)
315 ("glib:bin" ,glib "bin") ; gtester, etc.
316 ("perl" ,perl)
317 ("flex" ,flex)
318 ("bison" ,bison)
319 ("pkg-config" ,pkg-config)
320 ("python-wrapper" ,python-wrapper)
321 ("python-sphinx" ,python-sphinx)
322 ("texinfo" ,texinfo)))
323 (home-page "https://www.qemu.org")
324 (synopsis "Machine emulator and virtualizer")
325 (description
326 "QEMU is a generic machine emulator and virtualizer.
327
328 When used as a machine emulator, QEMU can run OSes and programs made for one
329 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
330 using dynamic translation, it achieves very good performance.
331
332 When used as a virtualizer, QEMU achieves near native performances by
333 executing the guest code directly on the host CPU. QEMU supports
334 virtualization when executing under the Xen hypervisor or using
335 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
336 server and embedded PowerPC, and S390 guests.")
337
338 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
339 (license license:gpl2)
340
341 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
342 (supported-systems (fold delete %supported-systems
343 '("mips64el-linux" "i586-gnu")))))
344
345 (define-public qemu-minimal
346 ;; QEMU without GUI support, only supporting the host's architecture
347 (package (inherit qemu)
348 (name "qemu-minimal")
349 (synopsis
350 "Machine emulator and virtualizer (without GUI) for the host architecture")
351 (arguments
352 (substitute-keyword-arguments (package-arguments qemu)
353 ((#:configure-flags _ '(list))
354 ;; Restrict to the host's architecture.
355 (let ((system (or (%current-target-system)
356 (%current-system))))
357 (cond
358 ((string-prefix? "i686" system)
359 '(list "--target-list=i386-softmmu"))
360 ((string-prefix? "xasdf86_64" system)
361 '(list "--target-list=i386-softmmu,x86_64-softmmu"))
362 ((string-prefix? "mips64" system)
363 '(list (string-append "--target-list=mips-softmmu,mipsel-softmmu,"
364 "mips64-softmmu,mips64el-softmmu")))
365 ((string-prefix? "mips" system)
366 '(list "--target-list=mips-softmmu,mipsel-softmmu"))
367 ((string-prefix? "aarch64" system)
368 '(list "--target-list=arm-softmmu,aarch64-softmmu"))
369 ((string-prefix? "arm" system)
370 '(list "--target-list=arm-softmmu"))
371 ((string-prefix? "alpha" system)
372 '(list "--target-list=alpha-softmmu"))
373 ((string-prefix? "powerpc64" system)
374 '(list "--target-list=ppc-softmmu,ppc64-softmmu"))
375 ((string-prefix? "powerpc" system)
376 '(list "--target-list=ppc-softmmu"))
377 ((string-prefix? "s390" system)
378 '(list "--target-list=s390x-softmmu"))
379 ((string-prefix? "riscv" system)
380 '(list "--target-list=riscv32-softmmu,riscv64-softmmu"))
381 (else ; An empty list actually builds all the targets.
382 ''()))))))
383
384 ;; Remove dependencies on optional libraries, notably GUI libraries.
385 (native-inputs (fold alist-delete (package-native-inputs qemu)
386 '("gettext")))
387 (inputs (fold alist-delete (package-inputs qemu)
388 '("libusb" "mesa" "sdl2" "spice" "virglrenderer" "gtk+"
389 "usbredir" "libdrm" "libepoxy" "pulseaudio" "vde2"
390 "libcacard")))))
391
392 (define (system->qemu-target system)
393 (cond
394 ((string-prefix? "i686" system)
395 "qemu-system-i386")
396 ((string-prefix? "arm" system)
397 "qemu-system-arm")
398 (else
399 (string-append "qemu-system-" (match (string-split system #\-)
400 ((arch kernel) arch)
401 (_ system))))))
402
403 (define-public ganeti
404 (package
405 (name "ganeti")
406 ;; Note: we use a pre-release for Python 3 compatibility as well as many
407 ;; other fixes.
408 (version "3.0.0beta1-24-g024cc9fa2")
409 (source (origin
410 (method git-fetch)
411 (uri (git-reference
412 (url "https://github.com/ganeti/ganeti")
413 (commit (string-append "v" version))))
414 (sha256
415 (base32 "1ll34qd2mifni3bhg7cnir3xfnkafig8ch33qndqwrsby0y5ssia"))
416 (file-name (git-file-name name version))
417 (patches (search-patches "ganeti-shepherd-support.patch"
418 "ganeti-shepherd-master-failover.patch"
419 "ganeti-deterministic-manual.patch"
420 "ganeti-drbd-compat.patch"
421 "ganeti-os-disk-size.patch"
422 "ganeti-haskell-pythondir.patch"
423 "ganeti-disable-version-symlinks.patch"
424 "ganeti-preserve-PYTHONPATH.patch"))))
425 (build-system gnu-build-system)
426 (arguments
427 `(#:imported-modules (,@%gnu-build-system-modules
428 (guix build haskell-build-system)
429 (guix build python-build-system))
430 #:modules (,@%gnu-build-system-modules
431 ((guix build haskell-build-system) #:prefix haskell:)
432 ((guix build python-build-system) #:select (python-version))
433 (ice-9 rdelim))
434
435 ;; The default test target includes a lot of checks that are only really
436 ;; relevant for developers such as NEWS file checking, line lengths, etc.
437 ;; We are only interested in the "py-tests" and "hs-tests" targets: this
438 ;; is the closest we've got even though it includes a little more.
439 #:test-target "check-TESTS"
440
441 #:configure-flags
442 (list "--localstatedir=/var"
443 "--sharedstatedir=/var"
444 "--sysconfdir=/etc"
445 "--enable-haskell-tests"
446
447 ;; By default, the build system installs everything to versioned
448 ;; directories such as $libdir/3.0 and relies on a $libdir/default
449 ;; symlink pointed from /etc/ganeti/{lib,share} to actually function.
450 ;; This is done to accommodate installing multiple versions in
451 ;; parallel, but is of little use to us as Guix users can just
452 ;; roll back and forth. Thus, disable it for simplicity.
453 "--disable-version-links"
454
455 ;; Ganeti can optionally take control over SSH host keys and
456 ;; distribute them to nodes as they are added, and also rotate keys
457 ;; with 'gnt-cluster renew-crypto --new-ssh-keys'. Thus it needs to
458 ;; know how to restart the SSH daemon.
459 "--with-sshd-restart-command='herd restart ssh-daemon'"
460
461 ;; Look for OS definitions in this directory by default. It can
462 ;; be changed in the cluster configuration.
463 "--with-os-search-path=/run/current-system/profile/share/ganeti/os"
464
465 ;; The default QEMU executable to use. We don't use the package
466 ;; here because this entry is stored in the cluster configuration.
467 (string-append "--with-kvm-path=/run/current-system/profile/bin/"
468 ,(system->qemu-target (%current-system))))
469 #:phases
470 (modify-phases %standard-phases
471 (add-after 'unpack 'create-vcs-version
472 (lambda _
473 ;; If we are building from a git checkout, we need to create a
474 ;; 'vcs-version' file manually because the build system does
475 ;; not have access to the git repository information.
476 (unless (file-exists? "vcs-version")
477 (call-with-output-file "vcs-version"
478 (lambda (port)
479 (format port "v~a~%" ,version))))
480 #t))
481 (add-after 'unpack 'patch-absolute-file-names
482 (lambda _
483 (substitute* '("lib/utils/process.py"
484 "lib/utils/text.py"
485 "src/Ganeti/Constants.hs"
486 "src/Ganeti/HTools/CLI.hs"
487 "test/py/ganeti.config_unittest.py"
488 "test/py/ganeti.hooks_unittest.py"
489 "test/py/ganeti.utils.process_unittest.py"
490 "test/py/ganeti.utils.text_unittest.py"
491 "test/py/ganeti.utils.wrapper_unittest.py")
492 (("/bin/sh") (which "sh"))
493 (("/bin/bash") (which "bash"))
494 (("/usr/bin/env") (which "env"))
495 (("/bin/true") (which "true")))
496
497 ;; This script is called by the node daemon at startup to perform
498 ;; sanity checks on the cluster IP addresses, and it is also used
499 ;; in a master-failover scenario. Add absolute references to
500 ;; avoid propagating these executables.
501 (substitute* "tools/master-ip-setup"
502 (("arping") (which "arping"))
503 (("ndisc6") (which "ndisc6"))
504 (("fping") (which "fping"))
505 (("grep") (which "grep"))
506 (("ip addr") (string-append (which "ip") " addr")))
507 #t))
508 (add-after 'unpack 'override-builtin-PATH
509 (lambda _
510 ;; Ganeti runs OS install scripts and similar with a built-in
511 ;; hard coded PATH. Patch so it works on Guix System.
512 (substitute* "src/Ganeti/Constants.hs"
513 (("/sbin:/bin:/usr/sbin:/usr/bin")
514 "/run/setuid-programs:/run/current-system/profile/sbin:\
515 /run/current-system/profile/bin"))
516 #t))
517 (add-after 'bootstrap 'patch-sphinx-version-detection
518 (lambda _
519 ;; The build system runs 'sphinx-build --version' to verify that
520 ;; the Sphinx is recent enough, but does not expect the
521 ;; .sphinx-build-real executable name created by the Sphinx wrapper.
522 (substitute* "configure"
523 (("\\$SPHINX --version 2>&1")
524 "$SPHINX --version 2>&1 | sed 's/.sphinx-build-real/sphinx-build/g'"))
525 #t))
526
527 ;; The build system invokes Cabal and GHC, which do not work with
528 ;; GHC_PACKAGE_PATH: <https://github.com/haskell/cabal/issues/3728>.
529 ;; Tweak the build system to do roughly what haskell-build-system does.
530 (add-before 'configure 'configure-haskell
531 (assoc-ref haskell:%standard-phases 'setup-compiler))
532 (add-after 'configure 'do-not-use-GHC_PACKAGE_PATH
533 (lambda _
534 (unsetenv "GHC_PACKAGE_PATH")
535 (substitute* "Makefile"
536 (("\\$\\(CABAL\\)")
537 "$(CABAL) --package-db=../package.conf.d")
538 (("\\$\\(GHC\\)")
539 "$(GHC) -package-db=../package.conf.d"))
540 #t))
541 (add-after 'configure 'make-ghc-use-shared-libraries
542 (lambda _
543 (substitute* "Makefile"
544 (("HFLAGS =") "HFLAGS = -dynamic -fPIC"))
545 #t))
546 (add-after 'configure 'fix-installation-directories
547 (lambda _
548 (substitute* "Makefile"
549 ;; Do not attempt to create /var during install.
550 (("\\$\\(DESTDIR\\)\\$\\{localstatedir\\}")
551 "$(DESTDIR)${prefix}${localstatedir}")
552 ;; Similarly, do not attempt to install the sample ifup scripts
553 ;; to /etc/ganeti.
554 (("\\$\\(DESTDIR\\)\\$\\(ifupdir\\)")
555 "$(DESTDIR)${prefix}$(ifupdir)"))
556 #t))
557 (add-before 'build 'adjust-tests
558 (lambda _
559 ;; Disable tests that can not run. Do it early to prevent
560 ;; touching the Makefile later and triggering a needless rebuild.
561 (substitute* "Makefile"
562 ;; These tests expect the presence of a 'root' user (via
563 ;; ganeti/runtime.py), which fails in the build environment.
564 (("test/py/ganeti\\.asyncnotifier_unittest\\.py") "")
565 (("test/py/ganeti\\.backend_unittest\\.py") "")
566 (("test/py/ganeti\\.daemon_unittest\\.py") "")
567 (("test/py/ganeti\\.tools\\.ensure_dirs_unittest\\.py") "")
568 (("test/py/ganeti\\.utils\\.io_unittest-runasroot\\.py") "")
569 ;; Disable the bash_completion test, as it requires the full
570 ;; bash instead of bash-minimal.
571 (("test/py/bash_completion\\.bash")
572 "")
573 ;; This test requires networking.
574 (("test/py/import-export_unittest\\.bash")
575 ""))
576
577 ;; Many of the Makefile targets reset PYTHONPATH before running
578 ;; the Python interpreter, which does not work very well for us.
579 (substitute* "Makefile"
580 (("PYTHONPATH=")
581 (string-append "PYTHONPATH=" (getenv "PYTHONPATH") ":")))
582 #t))
583 (add-after 'build 'build-bash-completions
584 (lambda _
585 (let ((orig-pythonpath (getenv "PYTHONPATH")))
586 (setenv "PYTHONPATH" (string-append ".:" orig-pythonpath))
587 (invoke "./autotools/build-bash-completion")
588 (setenv "PYTHONPATH" orig-pythonpath)
589 #t)))
590 (add-before 'check 'pre-check
591 (lambda* (#:key inputs #:allow-other-keys)
592 ;; Set TZDIR so that time zones are found.
593 (setenv "TZDIR" (string-append (assoc-ref inputs "tzdata")
594 "/share/zoneinfo"))
595
596 ;; This test checks whether PYTHONPATH is untouched, and extends
597 ;; it to include test directories if so. Add an else branch for
598 ;; our modified PYTHONPATH, in order to prevent a confusing test
599 ;; failure where expired certificates are not cleaned because
600 ;; check-cert-expired is silently crashing.
601 (substitute* "test/py/ganeti-cleaner_unittest.bash"
602 (("then export PYTHONPATH=(.*)" all testpath)
603 (string-append all "else export PYTHONPATH="
604 (getenv "PYTHONPATH") ":" testpath "\n")))
605
606 (substitute* "test/py/ganeti.utils.process_unittest.py"
607 ;; This test attempts to run an executable with
608 ;; RunCmd(..., reset_env=True), which fails because the default
609 ;; PATH from Constants.hs does not exist in the build container.
610 ((".*def testResetEnv.*" all)
611 (string-append " @unittest.skipIf(True, "
612 "\"cannot reset env in the build container\")\n"
613 all))
614
615 ;; XXX: Somehow this test fails in the build container, but
616 ;; works in 'guix environment -C', even without /bin/sh?
617 ((".*def testPidFile.*" all)
618 (string-append " @unittest.skipIf(True, "
619 "\"testPidFile fails in the build container\")\n"
620 all)))
621
622 ;; XXX: Why are these links not added automatically.
623 (with-directory-excursion "test/hs"
624 (for-each (lambda (file)
625 (symlink "../../src/htools" file))
626 '("hspace" "hscan" "hinfo" "hbal" "hroller"
627 "hcheck" "hail" "hsqueeze")))
628 #t))
629 (add-after 'install 'install-bash-completions
630 (lambda* (#:key outputs #:allow-other-keys)
631 (let* ((out (assoc-ref outputs "out"))
632 (compdir (string-append out "/etc/bash_completion.d")))
633 (mkdir-p compdir)
634 (copy-file "doc/examples/bash_completion"
635 (string-append compdir "/ganeti"))
636 ;; The one file contains completions for many different
637 ;; executables. Create symlinks for found completions.
638 (with-directory-excursion compdir
639 (for-each
640 (lambda (prog) (symlink "ganeti" prog))
641 (call-with-input-file "ganeti"
642 (lambda (port)
643 (let loop ((line (read-line port))
644 (progs '()))
645 (if (eof-object? line)
646 progs
647 (if (string-prefix? "complete" line)
648 (loop (read-line port)
649 ;; Extract "prog" from lines of the form:
650 ;; "complete -F _prog -o filenames prog".
651 ;; Note that 'burnin' is listed with the
652 ;; absolute file name, which is why we
653 ;; run everything through 'basename'.
654 (cons (basename (car (reverse (string-split
655 line #\ ))))
656 progs))
657 (loop (read-line port) progs))))))))
658 #t)))
659 ;; Wrap all executables with PYTHONPATH. We can't borrow the phase
660 ;; from python-build-system because we also need to wrap the scripts
661 ;; in $out/lib/ganeti such as "node-daemon-setup".
662 (add-after 'install 'wrap
663 (lambda* (#:key inputs outputs #:allow-other-keys)
664 (let* ((out (assoc-ref outputs "out"))
665 (sbin (string-append out "/sbin"))
666 (lib (string-append out "/lib"))
667 (python (assoc-ref inputs "python"))
668 (major+minor (python-version python))
669 (PYTHONPATH (string-append lib "/python" major+minor
670 "/site-packages:"
671 (getenv "PYTHONPATH"))))
672 (define (shell-script? file)
673 (call-with-ascii-input-file file
674 (lambda (port)
675 (let ((shebang (false-if-exception (read-line port))))
676 (and shebang
677 (string-prefix? "#!" shebang)
678 (or (string-contains shebang "/bin/bash")
679 (string-contains shebang "/bin/sh")))))))
680
681 (define (wrap? file)
682 ;; Do not wrap shell scripts because some are meant to be
683 ;; sourced, which breaks if they are wrapped. We do wrap
684 ;; the Haskell executables because some call out to Python
685 ;; directly.
686 (and (executable-file? file)
687 (not (symbolic-link? file))
688 (not (shell-script? file))))
689
690 (for-each (lambda (file)
691 (wrap-program file
692 `("PYTHONPATH" ":" prefix (,PYTHONPATH))))
693 (filter wrap?
694 (append (find-files (string-append lib "/ganeti"))
695 (find-files sbin))))
696 #t))))))
697 (native-inputs
698 `(("haskell" ,ghc)
699 ("cabal" ,cabal-install)
700 ("m4" ,m4)
701
702 ;; These inputs are necessary to bootstrap the package, because we
703 ;; have patched the build system.
704 ("autoconf" ,autoconf)
705 ("automake" ,automake)
706
707 ;; For the documentation.
708 ("python-docutils" ,python-docutils)
709 ("sphinx" ,python-sphinx)
710 ("pandoc" ,pandoc)
711 ("dot" ,graphviz)
712
713 ;; Test dependencies.
714 ("fakeroot" ,fakeroot)
715 ("ghc-temporary" ,ghc-temporary)
716 ("ghc-test-framework" ,ghc-test-framework)
717 ("ghc-test-framework-hunit" ,ghc-test-framework-hunit)
718 ("ghc-test-framework-quickcheck2" ,ghc-test-framework-quickcheck2)
719 ("python-mock" ,python-mock)
720 ("python-pyyaml" ,python-pyyaml)
721 ("openssh" ,openssh)
722 ("procps" ,procps)
723 ("shelltestrunner" ,shelltestrunner)
724 ("tzdata" ,tzdata-for-tests)))
725 (inputs
726 `(("arping" ,iputils) ;must be the iputils version
727 ("curl" ,curl)
728 ("fping" ,fping)
729 ("iproute2" ,iproute)
730 ("ndisc6" ,ndisc6)
731 ("socat" ,socat)
732 ("qemu" ,qemu-minimal) ;for qemu-img
733 ("ghc-attoparsec" ,ghc-attoparsec)
734 ("ghc-base64-bytestring" ,ghc-base64-bytestring)
735 ("ghc-cryptonite" ,ghc-cryptonite)
736 ("ghc-curl" ,ghc-curl)
737 ("ghc-hinotify" ,ghc-hinotify)
738 ("ghc-hslogger" ,ghc-hslogger)
739 ("ghc-json" ,ghc-json)
740 ("ghc-lens" ,ghc-lens)
741 ("ghc-lifted-base" ,ghc-lifted-base)
742 ("ghc-network" ,ghc-network)
743 ("ghc-old-time" ,ghc-old-time)
744 ("ghc-psqueue" ,ghc-psqueue)
745 ("ghc-regex-pcre" ,ghc-regex-pcre)
746 ("ghc-utf8-string" ,ghc-utf8-string)
747 ("ghc-zlib" ,ghc-zlib)
748
749 ;; For the optional metadata daemon.
750 ("ghc-snap-core" ,ghc-snap-core)
751 ("ghc-snap-server" ,ghc-snap-server)
752
753 ("python" ,python)
754 ("python-pyopenssl" ,python-pyopenssl)
755 ("python-simplejson" ,python-simplejson)
756 ("python-pyparsing" ,python-pyparsing)
757 ("python-pyinotify" ,python-pyinotify)
758 ("python-pycurl" ,python-pycurl)
759 ("python-bitarray" ,python-bitarray)
760 ("python-paramiko" ,python-paramiko)
761 ("python-psutil" ,python-psutil)))
762 (home-page "http://www.ganeti.org/")
763 (synopsis "Cluster-based virtual machine management system")
764 (description
765 "Ganeti is a virtual machine management tool built on top of existing
766 virtualization technologies such as Xen or KVM. Ganeti controls:
767
768 @itemize @bullet
769 @item Disk creation management;
770 @item Operating system installation for instances (in co-operation with
771 OS-specific install scripts); and
772 @item Startup, shutdown, and failover between physical systems.
773 @end itemize
774
775 Ganeti is designed to facilitate cluster management of virtual servers and
776 to provide fast and simple recovery after physical failures, using
777 commodity hardware.")
778 (license license:bsd-2)))
779
780 (define-public ganeti-instance-guix
781 (package
782 (name "ganeti-instance-guix")
783 (version "0.6")
784 (home-page "https://github.com/mbakke/ganeti-instance-guix")
785 (source (origin
786 (method git-fetch)
787 (uri (git-reference (url home-page) (commit version)))
788 (file-name (git-file-name name version))
789 (sha256
790 (base32
791 "0aa08irpcpns6mhjgsplc5f0p8ab1qcr9ah1gj5z66kxgqyflzrp"))))
792 (build-system gnu-build-system)
793 (arguments
794 '(#:configure-flags '("--sysconfdir=/etc" "--localstatedir=/var")))
795 (native-inputs
796 `(("autoconf" ,autoconf)
797 ("automake" ,automake)))
798 (inputs
799 `(("util-linux" ,util-linux)
800 ("qemu-img" ,qemu-minimal)))
801 (synopsis "Guix OS integration for Ganeti")
802 (description
803 "This package provides a guest OS definition for Ganeti that uses
804 Guix to build virtual machines.")
805 (license license:gpl3+)))
806
807 (define-public ganeti-instance-debootstrap
808 (package
809 (name "ganeti-instance-debootstrap")
810 ;; We need two commits on top of the latest release for compatibility
811 ;; with newer sfdisk, as well as gnt-network integration.
812 (version "0.16-2-ge145396")
813 (home-page "https://github.com/ganeti/instance-debootstrap")
814 (source (origin
815 (method git-fetch)
816 (uri (git-reference (url home-page) (commit version)))
817 (file-name (git-file-name name version))
818 (sha256
819 (base32
820 "0f2isw9d8lawzj21rrq1q9xhq8xfa65rqbhqmrn59z201x9q1336"))))
821 (build-system gnu-build-system)
822 (arguments
823 '(#:configure-flags '("--sysconfdir=/etc" "--localstatedir=/var")
824 #:phases (modify-phases %standard-phases
825 (add-after 'unpack 'add-absolute-references
826 (lambda _
827 (substitute* "common.sh.in"
828 (("/sbin/blkid") (which "blkid"))
829 (("kpartx -")
830 (string-append (which "kpartx") " -")))
831 (substitute* "import"
832 (("restore -r")
833 (string-append (which "restore") " -r")))
834 (substitute* "export"
835 (("dump -0")
836 (string-append (which "dump") " -0")))
837 (substitute* "create"
838 (("debootstrap") (which "debootstrap"))
839 (("`which run-parts`") (which "run-parts"))
840 ;; Here we actually need to hard code /bin/passwd
841 ;; because it's called via chroot, which fails if
842 ;; "/bin" is not in PATH.
843 (("passwd") "/bin/passwd"))
844 #t))
845 (add-after 'unpack 'set-dpkg-arch
846 (lambda* (#:key system #:allow-other-keys)
847 ;; The create script passes --arch to debootstrap,
848 ;; and defaults to `dpkg --print-architecture` when
849 ;; ARCH is not set in variant.conf. Hard code the
850 ;; build-time architecture to avoid the dpkg dependency.
851 (let ((dpkg-arch
852 (cond ((string-prefix? "x86_64" system)
853 "amd64")
854 ((string-prefix? "i686" system)
855 "i386")
856 ((string-prefix? "aarch64" system)
857 "arm64")
858 (else (car (string-split system #\-))))))
859 (substitute* "create"
860 (("`dpkg --print-architecture`")
861 dpkg-arch))
862 #t)))
863 (add-after 'configure 'adjust-Makefile
864 (lambda _
865 ;; Do not attempt to create /etc/ganeti/instance-debootstrap
866 ;; and /etc/default/ganeti-instance-debootstrap during install.
867 ;; They are created by the Ganeti service.
868 (substitute* "Makefile"
869 (("\\$\\(variantsdir\\)")
870 "$(prefix)/etc/ganeti/instance-debootstrap/variants")
871 (("\\$\\(defaultsdir\\)")
872 "$(prefix)/etc/default/ganeti-instance-debootstrap"))
873 #t))
874 (add-after 'install 'make-variants.list-symlink
875 (lambda* (#:key outputs #:allow-other-keys)
876 ;; The Ganeti OS API mandates a variants.list file that
877 ;; describes all supported "variants" of this OS.
878 ;; Guix generates this file, so make the original file
879 ;; a symlink to it.
880 (with-directory-excursion (string-append
881 (assoc-ref outputs "out")
882 "/share/ganeti/os/debootstrap")
883 (delete-file "variants.list")
884 (symlink "/etc/ganeti/instance-debootstrap/variants/variants.list"
885 "variants.list"))
886 #t)))))
887 (native-inputs
888 `(("autoconf" ,autoconf)
889 ("automake" ,automake)))
890 (inputs
891 `(("debianutils" ,debianutils)
892 ("debootstrap" ,debootstrap)
893 ("dump" ,dump)
894 ("kpartx" ,multipath-tools)
895 ("util-linux" ,util-linux)))
896 (synopsis "Debian OS integration for Ganeti")
897 (description
898 "This package provides a guest OS definition for Ganeti. It installs
899 Debian or a derivative using @command{debootstrap}.")
900 (license license:gpl2+)))
901
902 (define-public libosinfo
903 (package
904 (name "libosinfo")
905 (version "1.7.1")
906 (source
907 (origin
908 (method url-fetch)
909 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
910 version ".tar.xz"))
911 (sha256
912 (base32
913 "1s97sv24bybggjx6hgqba2qdqz3ivfpd4cmkh4zm5y59sim109mv"))))
914 (build-system meson-build-system)
915 (arguments
916 `(#:configure-flags
917 (list (string-append "-Dwith-usb-ids-path="
918 (assoc-ref %build-inputs "usb.ids"))
919 (string-append "-Dwith-pci-ids-path="
920 (assoc-ref %build-inputs "pci.ids")))
921 #:phases
922 (modify-phases %standard-phases
923 (add-after 'unpack 'patch-osinfo-path
924 (lambda* (#:key inputs #:allow-other-keys)
925 (substitute* "osinfo/osinfo_loader.c"
926 (("path = DATA_DIR.*")
927 (string-append "path = \"" (assoc-ref inputs "osinfo-db")
928 "/share/osinfo\";")))
929 #t)))))
930 (inputs
931 `(("libsoup" ,libsoup)
932 ("libxml2" ,libxml2)
933 ("libxslt" ,libxslt)
934 ("osinfo-db" ,osinfo-db)))
935 (native-inputs
936 `(("glib" ,glib "bin") ; glib-mkenums, etc.
937 ("gobject-introspection" ,gobject-introspection)
938 ("gtk-doc" ,gtk-doc)
939 ("vala" ,vala)
940 ("intltool" ,intltool)
941 ("pkg-config" ,pkg-config)
942 ("pci.ids"
943 ,(origin
944 (method url-fetch)
945 (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
946 (sha256
947 (base32
948 "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
949 ("usb.ids"
950 ,(origin
951 (method url-fetch)
952 (uri "https://svn.code.sf.net/p/linux-usb/repo/trunk/htdocs/usb.ids?r=2681")
953 (file-name "usb.ids")
954 (sha256
955 (base32
956 "1m6yhvz5k8aqzxgk7xj3jkk8frl1hbv0h3vgj4wbnvnx79qnvz3r"))))))
957 (home-page "https://libosinfo.org/")
958 (synopsis "Operating system information database")
959 (description "libosinfo is a GObject based library API for managing
960 information about operating systems, hypervisors and the (virtual) hardware
961 devices they can support. It includes a database containing device metadata
962 and provides APIs to match/identify optimal devices for deploying an operating
963 system on a hypervisor. Via GObject Introspection, the API is available in
964 all common programming languages. Vala bindings are also provided.")
965 ;; The library files are released under LGPLv2.1 or later; the source
966 ;; files in the "tools" directory are released under GPLv2+.
967 (license (list license:lgpl2.1+ license:gpl2+))))
968
969 (define-public lxc
970 (package
971 (name "lxc")
972 (version "4.0.6")
973 (source (origin
974 (method url-fetch)
975 (uri (string-append
976 "https://linuxcontainers.org/downloads/lxc/lxc-"
977 version ".tar.gz"))
978 (sha256
979 (base32
980 "0qz4l7mlhq7hx53q606qgvkyzyr01glsw290v8ppzvxn1fydlrci"))))
981 (build-system gnu-build-system)
982 (native-inputs
983 `(("pkg-config" ,pkg-config)))
984 (inputs
985 `(("gnutls" ,gnutls)
986 ("libcap" ,libcap)
987 ("libseccomp" ,libseccomp)
988 ("libselinux" ,libselinux)))
989 (arguments
990 `(#:configure-flags
991 (list (string-append "--docdir=" (assoc-ref %outputs "out")
992 "/share/doc/" ,name "-" ,version)
993 "--sysconfdir=/etc"
994 "--localstatedir=/var")
995 #:phases
996 (modify-phases %standard-phases
997 (replace 'install
998 (lambda* (#:key outputs #:allow-other-keys)
999 (let* ((out (assoc-ref outputs "out"))
1000 (bashcompdir (string-append out "/etc/bash_completion.d")))
1001 (invoke "make" "install"
1002 (string-append "bashcompdir=" bashcompdir)
1003 ;; Don't install files into /var and /etc.
1004 "LXCPATH=/tmp/var/lib/lxc"
1005 "localstatedir=/tmp/var"
1006 "sysconfdir=/tmp/etc"
1007 "sysconfigdir=/tmp/etc/default")))))))
1008 (synopsis "Linux container tools")
1009 (home-page "https://linuxcontainers.org/")
1010 (description
1011 "LXC is a userspace interface for the Linux kernel containment features.
1012 Through a powerful API and simple tools, it lets Linux users easily create and
1013 manage system or application containers.")
1014 (license license:lgpl2.1+)))
1015
1016 (define-public libvirt
1017 (package
1018 (name "libvirt")
1019 (version "5.8.0")
1020 (source
1021 (origin
1022 (method url-fetch)
1023 (uri (string-append "https://libvirt.org/sources/libvirt-"
1024 version ".tar.xz"))
1025 (sha256
1026 (base32 "0m8cqaqflvys5kaqpvb0qr4k365j09jc5xk6x70yvg8qkcl2hcz2"))
1027 (patches
1028 (search-patches "libvirt-create-machine-cgroup.patch"))))
1029 (build-system gnu-build-system)
1030 (arguments
1031 `(#:configure-flags
1032 (list "--with-qemu"
1033 "--with-qemu-user=nobody"
1034 "--with-qemu-group=kvm"
1035 "--with-polkit"
1036 (string-append "--docdir=" (assoc-ref %outputs "out") "/share/doc/"
1037 ,name "-" ,version)
1038 "--sysconfdir=/etc"
1039 "--localstatedir=/var")
1040 #:phases
1041 (modify-phases %standard-phases
1042 (add-before 'configure 'fix-BOURNE_SHELL-definition
1043 ;; BOURNE_SHELL is hard-#defined to ‘/bin/sh’, causing test failures.
1044 (lambda _
1045 (substitute* "config.h.in"
1046 (("/bin/sh") (which "sh")))
1047 #t))
1048 (add-before 'configure 'patch-libtirpc-file-names
1049 (lambda* (#:key inputs #:allow-other-keys)
1050 ;; libvirt uses an m4 macro instead of pkg-config to determine where
1051 ;; the RPC headers are located. Tell it to look in the right place.
1052 (substitute* "configure"
1053 (("/usr/include/tirpc") ;defined in m4/virt-xdr.m4
1054 (string-append (assoc-ref inputs "libtirpc")
1055 "/include/tirpc")))
1056 #t))
1057 (add-before 'configure 'disable-broken-tests
1058 (lambda _
1059 (let ((tests (list "commandtest" ; hangs idly
1060 "qemuxml2argvtest" ; fails
1061 "qemuhotplugtest" ; fails
1062 "virnetsockettest" ; tries to network
1063 "virshtest"))) ; fails
1064 (substitute* "tests/Makefile.in"
1065 (((format #f "(~a)\\$\\(EXEEXT\\)" (string-join tests "|")))
1066 ""))
1067 #t)))
1068 (replace 'install
1069 ;; Since the sysconfdir and localstatedir should be /etc and /var
1070 ;; at runtime, we must prevent writing to them at installation
1071 ;; time.
1072 (lambda* (#:key make-flags #:allow-other-keys)
1073 (apply invoke "make" "install"
1074 "sysconfdir=/tmp/etc"
1075 "localstatedir=/tmp/var"
1076 make-flags))))))
1077 (inputs
1078 `(("libxml2" ,libxml2)
1079 ("eudev" ,eudev)
1080 ("libpciaccess" ,libpciaccess)
1081 ("gnutls" ,gnutls)
1082 ("dbus" ,dbus)
1083 ("libpcap" ,libpcap)
1084 ("libnl" ,libnl)
1085 ("libtirpc" ,libtirpc) ;for <rpc/rpc.h>
1086 ("libuuid" ,util-linux "lib")
1087 ("lvm2" ,lvm2) ;for libdevmapper
1088 ("curl" ,curl)
1089 ("openssl" ,openssl)
1090 ("cyrus-sasl" ,cyrus-sasl)
1091 ("libyajl" ,libyajl)
1092 ("audit" ,audit)
1093 ("dmidecode" ,dmidecode)
1094 ("dnsmasq" ,dnsmasq)
1095 ("ebtables" ,ebtables)
1096 ("iproute" ,iproute)
1097 ("iptables" ,iptables)))
1098 (native-inputs
1099 `(("xsltproc" ,libxslt)
1100 ("perl" ,perl)
1101 ("pkg-config" ,pkg-config)
1102 ("polkit" ,polkit)
1103 ("python" ,python-wrapper)))
1104 (home-page "https://libvirt.org")
1105 (synopsis "Simple API for virtualization")
1106 (description "Libvirt is a C toolkit to interact with the virtualization
1107 capabilities of recent versions of Linux. The library aims at providing long
1108 term stable C API initially for the Xen paravirtualization but should be able
1109 to integrate other virtualization mechanisms if needed.")
1110 (license license:lgpl2.1+)))
1111
1112 (define-public libvirt-glib
1113 (package
1114 (name "libvirt-glib")
1115 (version "3.0.0")
1116 (source (origin
1117 (method url-fetch)
1118 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
1119 "libvirt-glib-" version ".tar.gz"))
1120 (sha256
1121 (base32
1122 "1zpbv4ninc57c9rw4zmmkvvqn7154iv1qfr20kyxn8xplalqrzvz"))))
1123 (build-system gnu-build-system)
1124 (inputs
1125 `(("openssl" ,openssl)
1126 ("cyrus-sasl" ,cyrus-sasl)
1127 ("lvm2" ,lvm2) ; for libdevmapper
1128 ("libyajl" ,libyajl)))
1129 (native-inputs
1130 `(("pkg-config" ,pkg-config)
1131 ("intltool" ,intltool)
1132 ("glib" ,glib "bin")
1133 ("vala" ,vala)))
1134 (propagated-inputs
1135 ;; ‘Required:’ by the installed .pc files.
1136 `(("glib" ,glib)
1137 ("libvirt" ,libvirt)
1138 ("libxml2" ,libxml2)
1139 ("gobject-introspection" ,gobject-introspection)))
1140 (home-page "https://libvirt.org")
1141 (synopsis "GLib wrapper around libvirt")
1142 (description "libvirt-glib wraps the libvirt library to provide a
1143 high-level object-oriented API better suited for glib-based applications, via
1144 three libraries:
1145
1146 @enumerate
1147 @item libvirt-glib - GLib main loop integration & misc helper APIs
1148 @item libvirt-gconfig - GObjects for manipulating libvirt XML documents
1149 @item libvirt-gobject - GObjects for managing libvirt objects
1150 @end enumerate
1151 ")
1152 (license license:lgpl2.1+)))
1153
1154 (define-public python-libvirt
1155 (package
1156 (name "python-libvirt")
1157 (version "5.8.0")
1158 (source
1159 (origin
1160 (method url-fetch)
1161 (uri (string-append "https://libvirt.org/sources/python/libvirt-python-"
1162 version ".tar.gz"))
1163 (sha256
1164 (base32 "0kyz3lx49d8p75mvbzinxc1zgs8g7adn77y9bm15b8b4ad9zl5s6"))))
1165 (build-system python-build-system)
1166 (arguments
1167 `(#:phases
1168 (modify-phases %standard-phases
1169 (add-after 'unpack 'patch-nosetests-path
1170 (lambda* (#:key inputs #:allow-other-keys)
1171 (substitute* "setup.py"
1172 (("\"/usr/bin/nosetests\"")
1173 (string-append "\"" (which "nosetests") "\""))
1174 (("self\\.spawn\\(\\[sys\\.executable, nose\\]\\)")
1175 (format #f "self.spawn([\"~a\", nose])" (which "bash"))))
1176 #t)))))
1177 (inputs
1178 `(("libvirt" ,libvirt)))
1179 (propagated-inputs
1180 `(("python-lxml" ,python-lxml)))
1181 (native-inputs
1182 `(("pkg-config" ,pkg-config)
1183 ("python-nose" ,python-nose)))
1184 (home-page "https://libvirt.org")
1185 (synopsis "Python bindings to libvirt")
1186 (description "This package provides Python bindings to the libvirt
1187 virtualization library.")
1188 (license license:lgpl2.1+)))
1189
1190 (define-public python2-libvirt
1191 (package-with-python2 python-libvirt))
1192
1193 (define-public virt-manager
1194 (package
1195 (name "virt-manager")
1196 (version "2.2.1")
1197 (source (origin
1198 (method url-fetch)
1199 (uri (string-append "https://virt-manager.org/download/sources"
1200 "/virt-manager/virt-manager-"
1201 version ".tar.gz"))
1202 (sha256
1203 (base32
1204 "06ws0agxlip6p6n3n43knsnjyd91gqhh2dadgc33wl9lx1k8vn6g"))))
1205 (build-system python-build-system)
1206 (arguments
1207 `(#:use-setuptools? #f ; uses custom distutils 'install' command
1208 #:test-target "test_ui"
1209 #:tests? #f ; TODO The tests currently fail
1210 ; RuntimeError: Loop condition wasn't
1211 ; met
1212 #:imported-modules ((guix build glib-or-gtk-build-system)
1213 ,@%python-build-system-modules)
1214 #:modules ((ice-9 match)
1215 (srfi srfi-26)
1216 (guix build python-build-system)
1217 ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
1218 (guix build utils))
1219 #:phases
1220 (modify-phases %standard-phases
1221 (add-after 'unpack 'fix-setup
1222 (lambda* (#:key outputs #:allow-other-keys)
1223 (substitute* "virtinst/buildconfig.py"
1224 (("/usr") (assoc-ref outputs "out")))
1225 #t))
1226 (add-after 'unpack 'fix-qemu-img-reference
1227 (lambda* (#:key inputs #:allow-other-keys)
1228 (substitute* "virtconv/formats.py"
1229 (("/usr(/bin/qemu-img)" _ suffix)
1230 (string-append (assoc-ref inputs "qemu") suffix)))
1231 #t))
1232 (add-after 'unpack 'fix-default-uri
1233 (lambda* (#:key inputs #:allow-other-keys)
1234 ;; Xen is not available for now - so only patch qemu.
1235 (substitute* "virtManager/createconn.py"
1236 (("/usr(/bin/qemu-system)" _ suffix)
1237 (string-append (assoc-ref inputs "qemu") suffix)))
1238 #t))
1239 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
1240 (lambda* (#:key inputs outputs #:allow-other-keys)
1241 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
1242 (bin-files (find-files bin ".*"))
1243 (paths (map (match-lambda
1244 ((output . directory)
1245 (let* ((girepodir (string-append
1246 directory
1247 "/lib/girepository-1.0")))
1248 (if (file-exists? girepodir)
1249 girepodir #f))))
1250 inputs)))
1251 (for-each (lambda (file)
1252 (format #t "wrapping ~a\n" file)
1253 (wrap-program file
1254 `("GI_TYPELIB_PATH" ":" prefix
1255 ,(filter identity paths))))
1256 bin-files))
1257 #t))
1258 (replace 'check
1259 (lambda* (#:key tests? #:allow-other-keys)
1260 (when tests?
1261 (setenv "HOME" "/tmp")
1262 (system "Xvfb :1 &")
1263 (setenv "DISPLAY" ":1")
1264 ;; Dogtail requires that Assistive Technology support be enabled
1265 (setenv "GTK_MODULES" "gail:atk-bridge")
1266 (invoke "dbus-run-session" "--" "python" "setup.py" "test_ui"))
1267 #t))
1268 (add-after 'install 'glib-or-gtk-compile-schemas
1269 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
1270 (add-after 'install 'glib-or-gtk-wrap
1271 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
1272 (inputs
1273 `(("dconf" ,dconf)
1274 ("gtk+" ,gtk+)
1275 ("gtk-vnc" ,gtk-vnc)
1276 ("gtksourceview" ,gtksourceview)
1277 ("libvirt" ,libvirt)
1278 ("libvirt-glib" ,libvirt-glib)
1279 ("libosinfo" ,libosinfo)
1280 ("vte" ,vte)
1281 ("python-libvirt" ,python-libvirt)
1282 ("python-requests" ,python-requests)
1283 ("python-pycairo" ,python-pycairo)
1284 ("python-pygobject" ,python-pygobject)
1285 ("python-libxml2" ,python-libxml2)
1286 ("spice-gtk" ,spice-gtk)))
1287 ;; virt-manager searches for qemu-img or kvm-img in the PATH.
1288 (propagated-inputs
1289 `(("qemu" ,qemu)))
1290 (native-inputs
1291 `(("glib" ,glib "bin") ; glib-compile-schemas
1292 ("gobject-introspection" ,gobject-introspection)
1293 ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
1294 ("perl" ,perl) ; pod2man
1295 ("intltool" ,intltool)
1296 ;; The following are required for running the tests
1297 ;; ("python-dogtail" ,python-dogtail)
1298 ;; ("xvfb" ,xorg-server-for-tests)
1299 ;; ("dbus" ,dbus)
1300 ;; ("at-spi2-core" ,at-spi2-core)
1301 ;; ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
1302 ))
1303 (home-page "https://virt-manager.org/")
1304 (synopsis "Manage virtual machines")
1305 (description
1306 "The virt-manager application is a desktop user interface for managing
1307 virtual machines through libvirt. It primarily targets KVM VMs, but also
1308 manages Xen and LXC (Linux containers). It presents a summary view of running
1309 domains, their live performance and resource utilization statistics.")
1310 (license license:gpl2+)))
1311
1312 (define-public criu
1313 (package
1314 (name "criu")
1315 (version "3.15")
1316 (source (origin
1317 (method url-fetch)
1318 (uri (string-append "https://download.openvz.org/criu/criu-"
1319 version ".tar.bz2"))
1320 (sha256
1321 (base32
1322 "09d0j24x0cyc7wkgi7cnxqgfjk7kbdlm79zxpj8d356sa3rw2z24"))))
1323 (build-system gnu-build-system)
1324 (arguments
1325 `(#:test-target "test"
1326 #:tests? #f ; tests require mounting as root
1327 #:make-flags
1328 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
1329 (string-append "LIBDIR=" (assoc-ref %outputs "out")
1330 "/lib")
1331 (string-append "ASCIIDOC=" (assoc-ref %build-inputs "asciidoc")
1332 "/bin/asciidoc")
1333 (string-append "XMLTO=" (assoc-ref %build-inputs "xmlto")
1334 "/bin/xmlto"))
1335 #:phases
1336 (modify-phases %standard-phases
1337 (replace 'configure
1338 (lambda* (#:key inputs #:allow-other-keys)
1339 ;; The includes for libnl are located in a sub-directory.
1340 (setenv "C_INCLUDE_PATH"
1341 (string-append (assoc-ref inputs "libnl")
1342 "/include/libnl3:"
1343 (or (getenv "C_INCLUDE_PATH") "")))
1344 #t))
1345 (add-after 'configure 'fix-documentation
1346 (lambda* (#:key inputs outputs #:allow-other-keys)
1347 (substitute* "Documentation/Makefile"
1348 (("-m custom.xsl")
1349 (string-append
1350 "-m custom.xsl --skip-validation -x "
1351 (assoc-ref inputs "docbook-xsl") "/xml/xsl/"
1352 ,(package-name docbook-xsl) "-"
1353 ,(package-version docbook-xsl)
1354 "/manpages/docbook.xsl")))
1355 #t))
1356 (add-after 'unpack 'hardcode-variables
1357 (lambda* (#:key inputs #:allow-other-keys)
1358 ;; Hardcode arm version detection
1359 (substitute* "Makefile"
1360 (("ARMV.*:=.*") "ARMV := 7\n"))
1361 ;; We are currently using python-2
1362 (substitute* "crit/Makefile"
1363 (("\\$\\(PYTHON\\)") "python2"))
1364 (substitute* "lib/Makefile"
1365 (("\\$\\(PYTHON\\)")
1366 (string-append (assoc-ref inputs "python")
1367 "/bin/python")))
1368 #t))
1369 (add-before 'build 'fix-symlink
1370 (lambda* (#:key inputs #:allow-other-keys)
1371 ;; The file 'images/google/protobuf/descriptor.proto' points to
1372 ;; /usr/include/..., which obviously does not exist.
1373 (let* ((file "google/protobuf/descriptor.proto")
1374 (target (string-append "images/" file))
1375 (source (string-append (assoc-ref inputs "protobuf")
1376 "/include/" file)))
1377 (delete-file target)
1378 (symlink source target)
1379 #t)))
1380 (add-after 'install 'wrap
1381 (lambda* (#:key inputs outputs #:allow-other-keys)
1382 ;; Make sure 'crit' runs with the correct PYTHONPATH.
1383 (let* ((out (assoc-ref outputs "out"))
1384 (path (string-append out
1385 "/lib/python"
1386 (string-take (string-take-right
1387 (assoc-ref inputs "python") 5) 3)
1388 "/site-packages:"
1389 (getenv "PYTHONPATH"))))
1390 (wrap-program (string-append out "/bin/crit")
1391 `("PYTHONPATH" ":" prefix (,path))))
1392 #t)))))
1393 (inputs
1394 `(("protobuf" ,protobuf)
1395 ("python" ,python-2)
1396 ("python2-protobuf" ,python2-protobuf)
1397 ("python2-ipaddr" ,python2-ipaddr)
1398 ("iproute" ,iproute)
1399 ("libaio" ,libaio)
1400 ("libcap" ,libcap)
1401 ("libnet" ,libnet)
1402 ("libnl" ,libnl)
1403 ("libbsd" ,libbsd)
1404 ("nftables" ,nftables)))
1405 (native-inputs
1406 `(("pkg-config" ,pkg-config)
1407 ("perl" ,perl)
1408 ("protobuf-c" ,protobuf-c)
1409 ("asciidoc" ,asciidoc)
1410 ("xmlto" ,xmlto)
1411 ("docbook-xml" ,docbook-xml)
1412 ("docbook-xsl" ,docbook-xsl)))
1413 (home-page "https://criu.org")
1414 (synopsis "Checkpoint and restore in user space")
1415 (description "Using this tool, you can freeze a running application (or
1416 part of it) and checkpoint it to a hard drive as a collection of files. You
1417 can then use the files to restore and run the application from the point it
1418 was frozen at. The distinctive feature of the CRIU project is that it is
1419 mainly implemented in user space.")
1420 ;; The project is licensed under GPLv2; files in the lib/ directory are
1421 ;; LGPLv2.1.
1422 (license (list license:gpl2 license:lgpl2.1))))
1423
1424 (define-public qmpbackup
1425 (package
1426 (name "qmpbackup")
1427 (version "0.2")
1428 (source (origin
1429 (method git-fetch)
1430 (uri (git-reference
1431 (url "https://github.com/abbbi/qmpbackup")
1432 (commit version)))
1433 (file-name (git-file-name name version))
1434 (sha256
1435 (base32
1436 "0swhp5byz44brhyis1a39p11fyn9q84xz5q6v2fah29r7d71kmmx"))))
1437 (build-system python-build-system)
1438 (arguments
1439 `(#:python ,python-2))
1440 (home-page "https://github.com/abbbi/qmpbackup")
1441 (synopsis "Backup and restore QEMU machines")
1442 (description "qmpbackup is designed to create and restore full and
1443 incremental backups of running QEMU virtual machines via QMP, the QEMU
1444 Machine Protocol.")
1445 (license license:gpl3+)))
1446
1447 (define-public looking-glass-client
1448 (let ((commit "182c4752d57690da7f99d5e788de9b8baea33895"))
1449 (package
1450 (name "looking-glass-client")
1451 (version (string-append "a12-" (string-take commit 7)))
1452 (source
1453 (origin
1454 (method git-fetch)
1455 (uri (git-reference (url "https://github.com/gnif/LookingGlass")
1456 (commit commit)))
1457 (file-name (git-file-name name version))
1458 (sha256
1459 (base32
1460 "02bq46ndmzq9cihazzn7xq1x7q5nzm7iw4l9lqzihxcxp9famkhw"))
1461 (modules '((guix build utils)))
1462 (snippet
1463 '(begin
1464 ;; Do not create binaries optimized for the CPU of the build machine,
1465 ;; for reproducibility and compatibility. TODO: in the next version
1466 ;; of looking glass, this is exposed as a CMake configure option.
1467 (substitute* "client/CMakeLists.txt"
1468 (("-march=native")
1469 ""))
1470 #t))))
1471 (build-system cmake-build-system)
1472 (inputs `(("fontconfig" ,fontconfig)
1473 ("glu" ,glu)
1474 ("mesa" ,mesa)
1475 ("openssl" ,openssl)
1476 ("sdl2" ,sdl2)
1477 ("sdl2-ttf" ,sdl2-ttf)
1478 ("spice-protocol" ,spice-protocol)
1479 ("wayland" ,wayland)))
1480 (native-inputs `(("libconfig" ,libconfig)
1481 ("nettle" ,nettle)
1482 ("pkg-config" ,pkg-config)))
1483 (arguments
1484 `(#:tests? #f ;; No tests are available.
1485 #:make-flags '("CC=gcc")
1486 #:phases (modify-phases %standard-phases
1487 (add-before 'configure 'chdir-to-client
1488 (lambda* (#:key outputs #:allow-other-keys)
1489 (chdir "client")
1490 #t))
1491 (add-after 'chdir-to-client 'add-missing-include
1492 (lambda _
1493 ;; Mimic upstream commit b9797529893, required since the
1494 ;; update to Mesa 19.2.
1495 (substitute* "renderers/egl/shader.h"
1496 (("#include <stdbool\\.h>")
1497 "#include <stdbool.h>\n#include <stddef.h>"))
1498 #t))
1499 (replace 'install
1500 (lambda* (#:key outputs #:allow-other-keys)
1501 (install-file "looking-glass-client"
1502 (string-append (assoc-ref outputs "out")
1503 "/bin"))
1504 #t)))))
1505 (home-page "https://looking-glass.hostfission.com")
1506 (synopsis "KVM Frame Relay (KVMFR) implementation")
1507 (description "Looking Glass allows the use of a KVM (Kernel-based Virtual
1508 Machine) configured for VGA PCI Pass-through without an attached physical
1509 monitor, keyboard or mouse. It displays the VM's rendered contents on your main
1510 monitor/GPU.")
1511 ;; This package requires SSE instructions.
1512 (supported-systems '("i686-linux" "x86_64-linux"))
1513 (license license:gpl2+))))
1514
1515 (define-public runc
1516 (package
1517 (name "runc")
1518 (version "1.0.0-rc6")
1519 (source (origin
1520 (method url-fetch)
1521 (uri (string-append
1522 "https://github.com/opencontainers/runc/releases/"
1523 "download/v" version "/runc.tar.xz"))
1524 (file-name (string-append name "-" version ".tar.xz"))
1525 (patches (search-patches "runc-CVE-2019-5736.patch"))
1526 (sha256
1527 (base32
1528 "1c7832dq70slkjh8qp2civ1wxhhdd2hrx84pq7db1mmqc9fdr3cc"))))
1529 (build-system go-build-system)
1530 (arguments
1531 '(#:import-path "github.com/opencontainers/runc"
1532 #:install-source? #f
1533 ;; XXX: 20/139 tests fail due to missing /var, cgroups and apparmor in
1534 ;; the build environment.
1535 #:tests? #f
1536 #:phases
1537 (modify-phases %standard-phases
1538 (replace 'unpack
1539 (lambda* (#:key source import-path #:allow-other-keys)
1540 ;; Unpack the tarball into 'runc' instead of 'runc-1.0.0-rc5'.
1541 (let ((dest (string-append "src/" import-path)))
1542 (mkdir-p dest)
1543 (invoke "tar" "-C" (string-append "src/" import-path)
1544 "--strip-components=1"
1545 "-xvf" source))))
1546 (replace 'build
1547 (lambda* (#:key import-path #:allow-other-keys)
1548 (with-directory-excursion (string-append "src/" import-path)
1549 ;; XXX: requires 'go-md2man'.
1550 ;; (invoke "make" "man")
1551 (invoke "make"))))
1552 ;; (replace 'check
1553 ;; (lambda _
1554 ;; (invoke "make" "localunittest")))
1555 (replace 'install
1556 (lambda* (#:key import-path outputs #:allow-other-keys)
1557 (with-directory-excursion (string-append "src/" import-path)
1558 (let ((out (assoc-ref outputs "out")))
1559 (invoke "make" "install" "install-bash"
1560 (string-append "PREFIX=" out)))))))))
1561 (native-inputs
1562 `(("pkg-config" ,pkg-config)))
1563 (inputs
1564 `(("libseccomp" ,libseccomp)))
1565 (synopsis "Open container initiative runtime")
1566 (home-page "https://www.opencontainers.org/")
1567 (description
1568 "@command{runc} is a command line client for running applications
1569 packaged according to the
1570 @uref{https://github.com/opencontainers/runtime-spec/blob/master/spec.md, Open
1571 Container Initiative (OCI) format} and is a compliant implementation of the
1572 Open Container Initiative specification.")
1573 (license license:asl2.0)))
1574
1575 (define-public umoci
1576 (package
1577 (name "umoci")
1578 (version "0.4.6")
1579 (source
1580 (origin
1581 (method url-fetch)
1582 (uri (string-append
1583 "https://github.com/opencontainers/umoci/releases/download/v"
1584 version "/umoci.tar.xz"))
1585 (file-name (string-append "umoci-" version ".tar.xz"))
1586 (sha256
1587 (base32 "06q7xfwnqysc013hapx31jhlzmyg8qb467qfkynj673qc7p9bd6h"))))
1588 (build-system go-build-system)
1589 (arguments
1590 '(#:import-path "github.com/opencontainers/umoci"
1591 #:install-source? #f
1592 #:phases
1593 (modify-phases %standard-phases
1594 (replace 'unpack
1595 (lambda* (#:key source import-path #:allow-other-keys)
1596 ;; Unpack the tarball into 'umoci' instead of "runc-${version}".
1597 (let ((dest (string-append "src/" import-path)))
1598 (mkdir-p dest)
1599 (invoke "tar" "-C" (string-append "src/" import-path)
1600 "--strip-components=1"
1601 "-xvf" source))))
1602 (replace 'build
1603 (lambda* (#:key import-path #:allow-other-keys)
1604 (with-directory-excursion (string-append "src/" import-path)
1605 ;; TODO: build manpages with 'go-md2man'.
1606 (invoke "make" "SHELL=bash"))))
1607 (replace 'install
1608 (lambda* (#:key import-path outputs #:allow-other-keys)
1609 (let* ((out (assoc-ref outputs "out"))
1610 (bindir (string-append out "/bin")))
1611 (install-file (string-append "src/" import-path "/umoci")
1612 bindir)
1613 #t))))))
1614 (home-page "https://umo.ci/")
1615 (synopsis "Tool for modifying Open Container images")
1616 (description
1617 "@command{umoci} is a tool that allows for high-level modification of an
1618 Open Container Initiative (OCI) image layout and its tagged images.")
1619 (license license:asl2.0)))
1620
1621 (define-public skopeo
1622 (package
1623 (name "skopeo")
1624 (version "1.2.1")
1625 (source (origin
1626 (method git-fetch)
1627 (uri (git-reference
1628 (url "https://github.com/containers/skopeo")
1629 (commit (string-append "v" version))))
1630 (file-name (git-file-name name version))
1631 (sha256
1632 (base32
1633 "1y9pmijazbgxzriymrm7zrifmkd1x1wad9b3zjcj7zwr6c999dhg"))))
1634 (build-system go-build-system)
1635 (native-inputs
1636 `(("pkg-config" ,pkg-config)
1637 ("go-github-com-go-md2man" ,go-github-com-go-md2man)))
1638 (inputs
1639 `(("btrfs-progs" ,btrfs-progs)
1640 ("eudev" ,eudev)
1641 ("libassuan" ,libassuan)
1642 ("libselinux" ,libselinux)
1643 ("libostree" ,libostree)
1644 ("lvm2" ,lvm2)
1645 ("glib" ,glib)
1646 ("gpgme" ,gpgme)))
1647 (arguments
1648 '(#:import-path "github.com/containers/skopeo"
1649 #:install-source? #f
1650 #:tests? #f ; The tests require Docker
1651 #:phases
1652 (modify-phases %standard-phases
1653 (replace 'build
1654 (lambda* (#:key import-path #:allow-other-keys)
1655 (with-directory-excursion (string-append "src/" import-path)
1656 (invoke "make" "bin/skopeo"))))
1657 (add-after 'build 'build-docs
1658 (lambda* (#:key import-path #:allow-other-keys)
1659 (with-directory-excursion (string-append "src/" import-path)
1660 (invoke "make" "docs"))))
1661 (replace 'install
1662 (lambda* (#:key import-path outputs #:allow-other-keys)
1663 (with-directory-excursion (string-append "src/" import-path)
1664 (let ((out (assoc-ref outputs "out")))
1665 (install-file "default-policy.json"
1666 (string-append out "/etc/containers"))
1667 (invoke "make" "install-binary" "install-completions" "install-docs"
1668 (string-append "PREFIX=" out)))))))))
1669 (home-page "https://github.com/containers/skopeo")
1670 (synopsis "Interact with container images and container image registries")
1671 (description
1672 "@command{skopeo} is a command line utility providing various operations
1673 with container images and container image registries. It can:
1674 @enumerate
1675
1676 @item Copy container images between various containers image stores,
1677 converting them as necessary.
1678
1679 @item Convert a Docker schema 2 or schema 1 container image to an OCI image.
1680
1681 @item Inspect a repository on a container registry without needlessly pulling
1682 the image.
1683
1684 @item Sign and verify container images.
1685
1686 @item Delete container images from a remote container registry.
1687
1688 @end enumerate")
1689 (license license:asl2.0)))
1690
1691 (define-public python-vagrant
1692 (package
1693 (name "python-vagrant")
1694 (version "0.5.15")
1695 (source
1696 (origin
1697 (method url-fetch)
1698 (uri (pypi-uri "python-vagrant" version))
1699 (sha256
1700 (base32
1701 "1ikrh6canhcxg5y7pzmkcnnydikppv7s6sm9prfx90nk0ac8m6mg"))))
1702 (build-system python-build-system)
1703 (arguments
1704 '(#:tests? #f)) ; tests involve running vagrant.
1705 (home-page "https://github.com/todddeluca/python-vagrant")
1706 (synopsis "Python bindings for Vagrant")
1707 (description
1708 "Python-vagrant is a Python module that provides a thin wrapper around the
1709 @code{vagrant} command line executable, allowing programmatic control of Vagrant
1710 virtual machines.")
1711 (license license:expat)))
1712
1713 (define-public bubblewrap
1714 (package
1715 (name "bubblewrap")
1716 (version "0.4.1")
1717 (source (origin
1718 (method url-fetch)
1719 (uri (string-append "https://github.com/containers/bubblewrap/"
1720 "releases/download/v" version "/bubblewrap-"
1721 version ".tar.xz"))
1722 (sha256
1723 (base32
1724 "00ycgi6q2yngh06bnz50wkvar6r2jnjf3j158grhi9k13jdrpimr"))))
1725 (build-system gnu-build-system)
1726 (arguments
1727 `(#:phases
1728 (modify-phases %standard-phases
1729 (add-after 'unpack 'fix-test
1730 (lambda* (#:key outputs #:allow-other-keys)
1731 ;; Tests try to access /var/tmp, which is not possible in our build
1732 ;; environment. Let's give them another directory.
1733 ;; /tmp gets overriden in some tests, so we need another directory.
1734 ;; the only possibility is the output directory.
1735 (let ((tmp-dir (string-append (assoc-ref outputs "out") "/tmp")))
1736 (mkdir-p tmp-dir)
1737 (substitute* "tests/test-run.sh"
1738 (("/var/tmp") tmp-dir)
1739 ;; Tests create a temporary python script, so fix its shebang.
1740 (("/usr/bin/env python") (which "python"))
1741 ;; Some tests try to access /usr, but that doesn't exist.
1742 ;; Give them /gnu instead.
1743 (("/usr") "/gnu")
1744 (("--ro-bind /bin /bin") "--ro-bind /gnu /bin")
1745 (("--ro-bind /sbin /sbin") "--ro-bind /gnu /sbin")
1746 (("--ro-bind /lib /lib") "--ro-bind /gnu /lib")
1747 ((" */bin/bash") (which "bash"))
1748 (("/bin/sh") (which "sh"))
1749 (("findmnt") (which "findmnt"))))
1750 #t))
1751 ;; Remove the directory we gave to tests to have a clean package.
1752 (add-after 'check 'remove-tmp-dir
1753 (lambda* (#:key outputs #:allow-other-keys)
1754 (delete-file-recursively (string-append (assoc-ref outputs "out") "/tmp"))
1755 #t)))))
1756 (inputs
1757 `(("libcap" ,libcap)))
1758 (native-inputs
1759 `(("python" ,python-wrapper)
1760 ("util-linux" ,util-linux)))
1761 (home-page "https://github.com/containers/bubblewrap")
1762 (synopsis "Unprivileged sandboxing tool")
1763 (description "Bubblewrap is aimed at running applications in a sandbox,
1764 restricting their access to parts of the operating system or user data such as
1765 the home directory. Bubblewrap always creates a new mount namespace, and the
1766 user can specify exactly what parts of the file system should be made visible
1767 in the sandbox. These directories are mounted with the @code{nodev} option
1768 by default and can be made read-only.")
1769 (license license:lgpl2.0+)))
1770
1771 (define-public bochs
1772 (package
1773 (name "bochs")
1774 (version "2.6.11")
1775 (source
1776 (origin
1777 (method url-fetch)
1778 (uri (string-append "https://sourceforge.net/projects/bochs/files/bochs/"
1779 version "/bochs-" version ".tar.gz"))
1780 (sha256
1781 (base32 "0ql8q6y1k356li1g9gbvl21448mlxphxxi6kjb2b3pxvzd0pp2b3"))))
1782 (build-system gnu-build-system)
1783 (arguments
1784 `(#:tests? #f)) ; no tests exist
1785 (inputs
1786 `(("libxrandr" ,libxrandr)))
1787 (home-page "http://bochs.sourceforge.net/")
1788 (synopsis "Emulator for x86 PC")
1789 (description
1790 "Bochs is an emulator which can emulate Intel x86 CPU, common I/O
1791 devices, and a custom BIOS. It can also be compiled to emulate many different
1792 x86 CPUs, from early 386 to the most recent x86-64 Intel and AMD processors.
1793 Bochs can run most Operating Systems inside the emulation including Linux,
1794 DOS or Microsoft Windows.")
1795 (license license:lgpl2.0+)))
1796
1797 (define-public xen
1798 (package
1799 (name "xen")
1800 (version "4.14.1")
1801 (source (origin
1802 (method git-fetch)
1803 (uri (git-reference
1804 (url "git://xenbits.xenproject.org/xen.git")
1805 (commit (string-append "RELEASE-" version))))
1806 (file-name (git-file-name name version))
1807 (sha256
1808 (base32
1809 "1r90rvypw76ya9clqw5p02gm1k8hxz73f7gr95ca778nnzvb7xjw"))))
1810 (build-system gnu-build-system)
1811 (arguments
1812 `(#:configure-flags
1813 (list "--enable-rpath"
1814 "--disable-qemu-traditional" ; It tries to do "git clone"
1815 "--disable-rombios" ; would try to "git clone" via etherboot.
1816 ;; TODO: Re-enable stubdom (it's "more secure" to use it).
1817 "--disable-stubdom" ; tries to "git clone" old patched newlib.
1818 (string-append "--with-initddir="
1819 (assoc-ref %outputs "out")
1820 "/etc/init.d")
1821 (string-append "--with-system-qemu="
1822 (assoc-ref %build-inputs "qemu")
1823 "/bin/qemu-system-i386")
1824 (string-append "--with-system-seabios="
1825 (assoc-ref %build-inputs "seabios")
1826 "/share/firmware/bios.bin")
1827 (string-append "--with-system-ovmf="
1828 (assoc-ref %build-inputs "ovmf")
1829 "/share/firmware/ovmf_ia32.bin"))
1830 #:make-flags (list "-j" "1"
1831 "XEN_BUILD_DATE=Thu Jan 1 01:00:01 CET 1970"
1832 "XEN_BUILD_TIME=01:00:01"
1833 "XEN_BUILD_HOST="
1834 "ETHERBOOT_NICS="
1835 "SMBIOS_REL_DATE=01/01/1970"
1836 "VGABIOS_REL_DATE=01 Jan 1970"
1837 ; QEMU_TRADITIONAL_LOC
1838 ; QEMU_UPSTREAM_LOC
1839 "SYSCONFIG_DIR=/tmp/etc/default"
1840 (string-append "BASH_COMPLETION_DIR="
1841 (assoc-ref %outputs "out")
1842 "/etc/bash_completion.d")
1843 (string-append "BOOT_DIR="
1844 (assoc-ref %outputs "out")
1845 "/boot")
1846 (string-append "DEBUG_DIR="
1847 (assoc-ref %outputs "out")
1848 "/lib/debug")
1849 (string-append "EFI_DIR="
1850 (assoc-ref %outputs "out")
1851 "/lib/efi") ; TODO lib64 ?
1852 "MINIOS_UPSTREAM_URL="
1853 ;(string-append "DISTDIR="
1854 ; (assoc-ref %outputs "out"))
1855 )
1856 #:test-target "test"
1857 #:phases
1858 (modify-phases %standard-phases
1859 (add-after 'unpack 'unpack-mini-os
1860 (lambda* (#:key inputs #:allow-other-keys)
1861 (copy-recursively (assoc-ref inputs "mini-os") "extras/mini-os")
1862 #t))
1863 (add-after 'unpack-mini-os 'patch
1864 (lambda* (#:key inputs outputs #:allow-other-keys)
1865 (substitute* "tools/firmware/Rules.mk"
1866 (("override XEN_TARGET_ARCH = x86_32")
1867 (string-append "override XEN_TARGET_ARCH = x86_32
1868 override CC = " (assoc-ref inputs "cross-gcc") "/bin/i686-linux-gnu-gcc"))
1869 (("^CFLAGS =$")
1870 (string-append "CFLAGS=-I" (assoc-ref inputs "cross-libc")
1871 "/include\n")))
1872 (substitute* "config/x86_32.mk"
1873 (("CFLAGS += -m32 -march=i686")
1874 (string-append "CFLAGS += -march=i686 -I"
1875 (assoc-ref inputs "cross-libc")
1876 "/include")))
1877 ;; /var is not in /gnu/store , so don't try to create it.
1878 (substitute* '("tools/Makefile"
1879 "tools/xenstore/Makefile"
1880 "tools/xenpaging/Makefile")
1881 (("\\$\\(INSTALL_DIR\\) .*XEN_(DUMP|LOG|RUN|LIB|PAGING)_DIR.*")
1882 "\n")
1883 (("\\$\\(INSTALL_DIR\\) .*XEN_(RUN|LIB)_STORED.*")
1884 "\n"))
1885 ;; Prevent xen from creating /etc .
1886 (substitute* "tools/examples/Makefile"
1887 ((" install-readmes") "")
1888 ((" install-configs") ""))
1889 ;; Set rpath.
1890 (substitute* "tools/pygrub/setup.py"
1891 (("library_dirs =")
1892 ; TODO: extra_link_args = ['-Wl,-rpath=/opt/foo'],
1893 (string-append "runtime_library_dirs = ['"
1894 (assoc-ref outputs "out")
1895 "/lib'],\nlibrary_dirs =")))
1896 #t))
1897 (add-before 'configure 'patch-xen-script-directory
1898 (lambda* (#:key outputs #:allow-other-keys)
1899 (substitute* '("configure"
1900 "tools/configure"
1901 "docs/configure")
1902 (("XEN_SCRIPT_DIR=.*")
1903 (string-append "XEN_SCRIPT_DIR="
1904 (assoc-ref outputs "out")
1905 "/etc/xen/scripts")))
1906 #t))
1907 (add-before 'configure 'set-environment-up
1908 (lambda* (#:key make-flags #:allow-other-keys)
1909 (define (cross? x)
1910 (string-contains x "cross-i686-linux"))
1911 (define (filter-environment! filter-predicate
1912 environment-variable-names)
1913 (for-each
1914 (lambda (env-name)
1915 (let* ((env-value (getenv env-name))
1916 (search-path (search-path-as-string->list env-value))
1917 (new-search-path (filter filter-predicate
1918 search-path))
1919 (new-env-value (list->search-path-as-string
1920 new-search-path ":")))
1921 (setenv env-name new-env-value)))
1922 environment-variable-names))
1923 (setenv "CROSS_C_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
1924 (setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH"))
1925 (setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
1926 (filter-environment! cross?
1927 '("CROSS_C_INCLUDE_PATH" "CROSS_CPLUS_INCLUDE_PATH"
1928 "CROSS_LIBRARY_PATH"))
1929 (filter-environment! (lambda (e) (not (cross? e)))
1930 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
1931 "LIBRARY_PATH"))
1932 ;; Guix tries to be helpful and automatically adds
1933 ;; mini-os-git-checkout/include to the include path,
1934 ;; but actually we don't want it to be there (yet).
1935 (filter-environment! (lambda (e)
1936 (not
1937 (string-contains e
1938 "mini-os-git-checkout")))
1939 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
1940 "LIBRARY_PATH"))
1941 (setenv "EFI_VENDOR" "guix")
1942 #t))
1943 (replace 'build
1944 (lambda* (#:key make-flags #:allow-other-keys)
1945 (apply invoke "make" "world" make-flags))))))
1946 (inputs
1947 `(("acpica" ,acpica) ; TODO: patch iasl invocation.
1948 ("bridge-utils" ,bridge-utils) ; TODO: patch invocations.
1949 ("glib" ,glib)
1950 ("iproute" ,iproute) ; TODO: patch invocations.
1951 ("libaio" ,libaio)
1952 ("libx11" ,libx11)
1953 ("libyajl" ,libyajl)
1954 ("ncurses" ,ncurses)
1955 ("openssl" ,openssl)
1956 ("ovmf" ,ovmf)
1957 ("pixman" ,pixman)
1958 ("qemu" ,qemu-minimal)
1959 ("seabios" ,seabios)
1960 ("util-linux" ,util-linux "lib") ; uuid
1961 ; TODO: ocaml-findlib, ocaml-nox.
1962 ("xz" ,xz) ; for liblzma
1963 ("zlib" ,zlib)))
1964 (native-inputs
1965 `(("dev86" ,dev86)
1966 ("bison" ,bison)
1967 ("cmake" ,cmake-minimal)
1968 ("figlet" ,figlet)
1969 ("flex" ,flex)
1970 ("gettext" ,gettext-minimal)
1971 ("libnl" ,libnl)
1972 ("mini-os"
1973 ,(origin
1974 (method git-fetch)
1975 (uri (git-reference
1976 (url "http://xenbits.xen.org/git-http/mini-os.git")
1977 (commit (string-append "xen-RELEASE-" version))))
1978 (sha256
1979 (base32
1980 "1i8pcl19n60i2m9vlg79q3nknpj209c9ic5x10wxaicx45kc107f"))
1981 (file-name "mini-os-git-checkout")))
1982 ("perl" ,perl)
1983 ; TODO: markdown
1984 ("pkg-config" ,pkg-config)
1985 ("python" ,python-2)
1986 ("wget" ,wget)
1987 ("cross-gcc" ,(cross-gcc "i686-linux-gnu"
1988 #:xbinutils (cross-binutils "i686-linux-gnu")
1989 #:libc (cross-libc "i686-linux-gnu")))
1990 ("cross-libc" ,(cross-libc "i686-linux-gnu")) ; header files
1991 ("cross-libc-static" ,(cross-libc "i686-linux-gnu") "static")))
1992 (home-page "https://xenproject.org/")
1993 (synopsis "Xen Virtual Machine Monitor")
1994 (description "This package provides the Xen Virtual Machine Monitor
1995 which is a hypervisor.")
1996 ;; TODO: Some files are licensed differently. List those.
1997 (license license:gpl2)
1998 (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))))
1999
2000 (define-public osinfo-db-tools
2001 (package
2002 (name "osinfo-db-tools")
2003 (version "1.8.0")
2004 (source (origin
2005 (method url-fetch)
2006 (uri (string-append "https://releases.pagure.org/libosinfo/osinfo-db-tools-"
2007 version ".tar.xz"))
2008
2009 (sha256
2010 (base32
2011 "038q3gzdbkfkhpicj0755mw1q4gbvn57pslpw8n2dp3lds9im0g9"))))
2012 (build-system meson-build-system)
2013 (inputs
2014 `(("libsoup" ,libsoup)
2015 ("libxml2" ,libxml2)
2016 ("libxslt" ,libxslt)
2017 ("json-glib" ,json-glib)
2018 ("libarchive" ,libarchive)))
2019 (native-inputs
2020 `(("perl" ,perl)
2021 ("gobject-introspection" ,gobject-introspection)
2022 ("gettext" ,gettext-minimal)
2023 ("pkg-config" ,pkg-config)
2024 ;; Tests
2025 ("python" ,python)
2026 ("pytest" ,python-pytest)
2027 ("requests" ,python-requests)))
2028 (home-page "https://gitlab.com/libosinfo/osinfo-db-tools")
2029 (synopsis "Tools for managing the osinfo database")
2030 (description "This package contains a set of tools to assist
2031 administrators and developers in managing the database.")
2032 (license license:lgpl2.0+)))
2033
2034 (define-public osinfo-db
2035 (package
2036 (name "osinfo-db")
2037 (version "20201218")
2038 (source (origin
2039 (method url-fetch)
2040 (uri (string-append "https://releases.pagure.org/libosinfo/osinfo-db-"
2041 version ".tar.xz"))
2042 (sha256
2043 (base32
2044 "0ydbindwgw7kg861rqii5036gq0dbbbmv35dzrmmv937ddfsxwh0"))))
2045 (build-system trivial-build-system)
2046 (arguments
2047 `(#:modules ((guix build utils))
2048 #:builder
2049 (begin
2050 (use-modules (guix build utils))
2051 (let* ((out (assoc-ref %outputs "out"))
2052 (osinfo-dir (string-append out "/share/osinfo"))
2053 (source (assoc-ref %build-inputs "source"))
2054 (osinfo-db-import
2055 (string-append (assoc-ref %build-inputs "osinfo-db-tools")
2056 "/bin/osinfo-db-import")))
2057 (mkdir-p osinfo-dir)
2058 (invoke osinfo-db-import "--dir" osinfo-dir source)
2059 #t))))
2060 (native-inputs
2061 `(("intltool" ,intltool)
2062 ("osinfo-db-tools" ,osinfo-db-tools)))
2063 (home-page "https://gitlab.com/libosinfo/osinfo-db")
2064 (synopsis "Database of information about operating systems")
2065 (description "Osinfo-db provides the database files for use with the
2066 libosinfo library. It provides information about guest operating systems for
2067 use with virtualization provisioning tools")
2068 (license license:lgpl2.0+)))
2069
2070 (define-public python-transient
2071 (package
2072 (name "python-transient")
2073 (version "0.12")
2074 (source
2075 (origin
2076 (method url-fetch)
2077 (uri (pypi-uri "transient" version))
2078 (sha256
2079 (base32
2080 "148yiqrmcscsi6787y0f27i1y9cf0gcw3mqfv5frhpmsmv62mv5z"))))
2081 (build-system python-build-system)
2082 (arguments
2083 `(#:tests? #f ; Requires behave
2084 #:phases (modify-phases %standard-phases
2085 (add-after 'unpack 'fix-dependencies
2086 (lambda _
2087 (substitute* "setup.py"
2088 (("==")
2089 ">="))
2090 #t)))))
2091 (propagated-inputs
2092 `(("python-beautifultable" ,python-beautifultable)
2093 ("python-click" ,python-click)
2094 ("python-importlib-resources"
2095 ,python-importlib-resources)
2096 ("python-lark-parser" ,python-lark-parser)
2097 ("python-marshmallow" ,python-marshmallow)
2098 ("python-progressbar2" ,python-progressbar2)
2099 ("python-requests" ,python-requests)
2100 ("python-toml" ,python-toml)))
2101 (native-inputs
2102 `(("python-black" ,python-black)
2103 ("python-mypy" ,python-mypy)
2104 ("python-pyhamcrest" ,python-pyhamcrest)
2105 ("python-twine" ,python-twine)))
2106 (home-page
2107 "https://github.com/ALSchwalm/transient")
2108 (synopsis
2109 "QEMU Wrapper written in Python")
2110 (description
2111 "@code{transient} is a wrapper for QEMU allowing the creation of virtual
2112 machines with shared folder, ssh, and disk creation support.")
2113 (license license:expat)))