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