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