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