1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Leo Famulari <leo@famulari.name>
5 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;; Copyright © 2016, 2017, 2018 Marius Bakke <mbakke@fastmail.com>
7 ;;; Copyright © 2016, 2017 Danny Milosavljevic <dannym@scratchpost.org>
8 ;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
9 ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
10 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;; Copyright © 2019 nee <nee@cock.li>
13 ;;; This file is part of GNU Guix.
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28 (define-module (gnu packages bootloaders)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages admin)
31 #:use-module ((gnu packages algebra) #:select (bc))
32 #:use-module (gnu packages assembly)
33 #:use-module (gnu packages base)
34 #:use-module (gnu packages disk)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages cdrom)
37 #:use-module (gnu packages check)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages cross-base)
40 #:use-module (gnu packages disk)
41 #:use-module (gnu packages firmware)
42 #:use-module (gnu packages flex)
43 #:use-module (gnu packages fontutils)
44 #:use-module (gnu packages gcc)
45 #:use-module (gnu packages gettext)
46 #:use-module (gnu packages linux)
47 #:use-module (gnu packages man)
48 #:use-module (gnu packages mtools)
49 #:use-module (gnu packages ncurses)
50 #:use-module (gnu packages perl)
51 #:use-module (gnu packages pkg-config)
52 #:use-module (gnu packages python)
53 #:use-module (gnu packages texinfo)
54 #:use-module (gnu packages tls)
55 #:use-module (gnu packages sdl)
56 #:use-module (gnu packages swig)
57 #:use-module (gnu packages valgrind)
58 #:use-module (gnu packages virtualization)
59 #:use-module (gnu packages xorg)
60 #:use-module (gnu packages web)
61 #:use-module (guix build-system gnu)
62 #:use-module (guix download)
63 #:use-module (guix git-download)
64 #:use-module ((guix licenses) #:prefix license:)
65 #:use-module (guix packages)
66 #:use-module (guix utils)
67 #:use-module (srfi srfi-1)
68 #:use-module (srfi srfi-26)
69 #:use-module (ice-9 regex))
72 ;; GNU Unifont, <http://gnu.org/s/unifont>.
73 ;; GRUB needs it for its graphical terminal, gfxterm.
77 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
80 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
88 (uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz"))
91 "03vvdfhdmf16121v7xs8is2krwnv15wpkhkf16a4yf8nsfc3f2w1"))
92 (patches (search-patches "grub-check-error-efibootmgr.patch"
93 "grub-binutils-compat.patch"))))
94 (build-system gnu-build-system)
96 `(#:phases (modify-phases %standard-phases
97 (add-after 'unpack 'patch-stuff
98 (lambda* (#:key inputs #:allow-other-keys)
99 (substitute* "grub-core/Makefile.in"
100 (("/bin/sh") (which "sh")))
102 ;; Give the absolute file name of 'mdadm', used to
103 ;; determine the root file system when it's a RAID
104 ;; device. Failing to do that, 'grub-probe' silently
105 ;; fails if 'mdadm' is not in $PATH.
106 (substitute* "grub-core/osdep/linux/getroot.c"
107 (("argv\\[0\\] = \"mdadm\"")
108 (string-append "argv[0] = \""
109 (assoc-ref inputs "mdadm")
112 ;; Make the font visible.
113 (copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz")
114 (system* "gunzip" "unifont.bdf.gz")
116 ;; Give the absolute file name of 'ckbcomp'.
117 (substitute* "util/grub-kbdcomp.in"
119 (string-append (assoc-ref inputs "console-setup")
122 (add-before 'check 'disable-flaky-test
124 ;; This test is unreliable. For more information, see:
125 ;; <https://bugs.gnu.org/26936>.
126 (substitute* "Makefile.in"
127 (("grub_cmd_date grub_cmd_set_date grub_cmd_sleep")
128 "grub_cmd_date grub_cmd_sleep"))
130 ;; Disable tests on ARM and AARCH64 platforms.
131 #:tests? ,(not (any (cute string-prefix? <> (or (%current-target-system)
133 '("arm" "aarch64")))))
135 `(("gettext" ,gettext-minimal)
137 ;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and
138 ;; 'grub-install' to recognize mapped devices (LUKS, etc.)
141 ;; Depend on mdadm, which is invoked by 'grub-probe' and 'grub-install'
142 ;; to determine whether the root file system is RAID.
145 ;; Console-setup's ckbcomp is invoked by grub-kbdcomp. It is required
146 ;; for generating alternative keyboard layouts.
147 ("console-setup" ,console-setup)
149 ("freetype" ,freetype)
150 ;; ("libusb" ,libusb)
152 ("ncurses" ,ncurses)))
154 `(("pkg-config" ,pkg-config)
157 ;; Due to a bug in flex >= 2.6.2, GRUB must be built with an older flex:
158 ;; <http://lists.gnu.org/archive/html/grub-devel/2017-02/msg00133.html>
159 ;; TODO Try building with flex > 2.6.4.
162 ("help2man" ,help2man)
164 ;; XXX: When building GRUB 2.02 on 32-bit x86, we need a binutils
165 ;; capable of assembling 64-bit instructions. However, our default
166 ;; binutils on 32-bit x86 is not 64-bit capable.
167 ,@(if (string-match "^i[3456]86-" (%current-system))
168 (let ((binutils (package/inherit
170 (name "binutils-i386")
172 (substitute-keyword-arguments (package-arguments binutils)
173 ((#:configure-flags flags ''())
174 `(cons "--enable-64-bit-bfd" ,flags)))))))
175 `(("ld-wrapper" ,(make-ld-wrapper "ld-wrapper-i386"
176 #:binutils binutils))
177 ("binutils" ,binutils)))
180 ;; Dependencies for the test suite. The "real" QEMU is needed here,
181 ;; because several targets are used.
183 ("qemu" ,qemu-minimal-2.10)
184 ("xorriso" ,xorriso)))
185 (home-page "https://www.gnu.org/software/grub/")
186 (synopsis "GRand Unified Boot loader")
188 "GRUB is a multiboot bootloader. It is used for initially loading the
189 kernel of an operating system and then transferring control to it. The kernel
190 then goes on to load the rest of the operating system. As a multiboot
191 bootloader, GRUB handles the presence of multiple operating systems installed
192 on the same computer; upon booting the computer, the user is presented with a
193 menu to select one of the installed operating systems.")
194 (license license:gpl3+)
195 (properties '((cpe-name . "grub2")))))
197 (define-public grub-efi
201 (synopsis "GRand Unified Boot loader (UEFI version)")
203 `(("efibootmgr" ,efibootmgr)
205 ,@(package-inputs grub)))
207 `(;; TODO: Tests need a UEFI firmware for qemu. There is one at
208 ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
209 ;; Search for 'OVMF' in "tests/util/grub-shell.in".
210 ,@(substitute-keyword-arguments (package-arguments grub)
212 ((#:configure-flags flags ''())
213 `(cons "--with-platform=efi" ,flags))
215 `(modify-phases ,phases
216 (add-after 'patch-stuff 'use-absolute-efibootmgr-path
217 (lambda* (#:key inputs #:allow-other-keys)
218 (substitute* "grub-core/osdep/unix/platform.c"
220 (string-append (assoc-ref inputs "efibootmgr")
221 "/sbin/efibootmgr")))
223 (add-after 'patch-stuff 'use-absolute-mtools-path
224 (lambda* (#:key inputs #:allow-other-keys)
225 (let ((mtools (assoc-ref inputs "mtools")))
226 (substitute* "util/grub-mkrescue.c"
228 (string-append "\"" mtools
230 (substitute* "util/grub-mkrescue.c"
232 (string-append "\"" mtools
236 ;; Because grub searches hardcoded paths it's easiest to just build grub
237 ;; again to make it find both grub-pc and grub-efi. There is a command
238 ;; line argument which allows you to specify ONE platform - but
239 ;; grub-mkrescue will use multiple platforms if they are available
240 ;; in the installation directory (without command line argument).
241 (define-public grub-hybrid
245 (synopsis "GRand Unified Boot loader (hybrid version)")
248 ,@(package-inputs grub-efi)))
250 (substitute-keyword-arguments (package-arguments grub-efi)
251 ((#:modules modules `((guix build utils) (guix build gnu-build-system)))
252 `((ice-9 ftw) ,@modules))
254 `(modify-phases ,phases
255 (add-after 'install 'install-non-efi
256 (lambda* (#:key inputs outputs #:allow-other-keys)
257 (let ((input-dir (string-append (assoc-ref inputs "grub")
259 (output-dir (string-append (assoc-ref outputs "out")
263 (if (not (or (string-prefix? "." basename)
264 (file-exists? (string-append output-dir "/" basename))))
265 (symlink (string-append input-dir "/" basename)
266 (string-append output-dir "/" basename))))
270 (define-public syslinux
271 (let ((commit "bb41e935cc83c6242de24d2271e067d76af3585c"))
274 (version (git-version "6.04-pre" "1" commit))
278 (url "https://github.com/geneC/syslinux")
280 (file-name (git-file-name name version))
283 "0k8dvafd6410kqxf3kyr4y8jzmpmrih6wbjqg6gklak7945yflrc"))))
284 (build-system gnu-build-system)
288 ("python-2" ,python-2)))
290 `(("libuuid" ,util-linux)
293 `(#:parallel-build? #f
295 (list (string-append "BINDIR=" %output "/bin")
296 (string-append "SBINDIR=" %output "/sbin")
297 (string-append "LIBDIR=" %output "/lib")
298 (string-append "INCDIR=" %output "/include")
299 (string-append "DATADIR=" %output "/share")
300 (string-append "MANDIR=" %output "/share/man")
304 (modify-phases %standard-phases
305 (add-after 'unpack 'patch-files
306 (lambda* (#:key inputs #:allow-other-keys)
307 (substitute* (find-files "." "Makefile.*|ppmtolss16")
308 (("/bin/pwd") (which "pwd"))
309 (("/bin/echo") (which "echo"))
310 (("/usr/bin/perl") (which "perl")))
311 (let ((mtools (assoc-ref inputs "mtools")))
312 (substitute* (find-files "." "\\.c$")
314 (string-append mtools "/bin/mcopy"))
316 (string-append mtools "/bin/mattrib"))))
319 (add-before 'build 'set-permissions
321 (invoke "chmod" "a+w" "utils/isohybrid.in")))
325 (substitute* "tests/unittest/include/unittest/unittest.h"
326 ;; Don't look up headers under /usr.
327 (("/usr/include/") ""))
328 (invoke "make" "unittest"))))))
329 (home-page "https://www.syslinux.org")
330 (synopsis "Lightweight Linux bootloader")
331 (description "Syslinux is a lightweight Linux bootloader.")
332 ;; The Makefile specifically targets i386 and x86_64 using nasm.
333 (supported-systems '("i686-linux" "x86_64-linux"))
334 (license (list license:gpl2+
335 license:bsd-3 ; gnu-efi/*
336 license:bsd-4 ; gnu-efi/inc/* gnu-efi/lib/*
338 license:expat license:isc license:zlib)))))
347 "mirror://kernel.org/software/utils/dtc/"
348 "dtc-" version ".tar.xz"))
351 "0wh10p42hf5403ipvs0dsxddb6kzfyk2sq4fgid9zqzpr51y8wn6"))))
352 (build-system gnu-build-system)
357 ("pkg-config" ,pkg-config)
359 ("valgrind" ,valgrind)))
361 `(("python-2" ,python-2)))
365 (string-append "PREFIX=" (assoc-ref %outputs "out"))
366 (string-append "SETUP_PREFIX=" (assoc-ref %outputs "out"))
369 (modify-phases %standard-phases
370 (delete 'configure)))) ; no configure script
371 (home-page "https://www.devicetree.org")
372 (synopsis "Compiles device tree source files")
373 (description "@command{dtc} compiles
374 @uref{http://elinux.org/Device_Tree_Usage, device tree source files} to device
375 tree binary files. These are board description files used by Linux and BSD.")
376 (license license:gpl2+)))
385 "ftp://ftp.denx.de/pub/u-boot/"
386 "u-boot-" version ".tar.bz2"))
389 "08hwsmh5xsb1gcxsv8gvx00bai938dm5y3889n8jif3a8rd7xgah"))))
396 ("python-2" ,python-2)
397 ("python2-coverage" ,python2-coverage)
398 ("python2-pytest" ,python2-pytest)
401 (build-system gnu-build-system)
402 (home-page "https://www.denx.de/wiki/U-Boot/")
403 (synopsis "ARM bootloader")
404 (description "U-Boot is a bootloader used mostly for ARM boards. It
405 also initializes the boards (RAM etc).")
406 (license license:gpl2+)))
408 (define-public u-boot-tools
411 (name "u-boot-tools")
413 `(#:make-flags '("HOSTCC=gcc")
414 #:test-target "tests"
416 (modify-phases %standard-phases
417 (add-after 'unpack 'patch
418 (lambda* (#:key inputs #:allow-other-keys)
419 (substitute* "Makefile"
420 (("/bin/pwd") (which "pwd"))
421 (("/bin/false") (which "false")))
422 (substitute* "tools/dtoc/fdt_util.py"
424 (substitute* "tools/patman/test_util.py"
425 ;; python-coverage is simply called coverage in guix.
426 (("python-coverage") "coverage")
427 ;; XXX Allow for only 99% test coverage.
428 ;; TODO: Find out why that is needed.
429 (("if coverage != '100%':") "if not int(coverage.rstrip('%')) >= 99:"))
430 (substitute* "test/run"
431 ;; Make it easier to find test failures.
432 (("#!/bin/bash") "#!/bin/bash -x")
433 ;; pytest doesn't find it otherwise.
434 (("test/py/tests/test_ofplatdata.py")
435 "tests/test_ofplatdata.py")
436 ;; This test would require git.
437 (("\\./tools/patman/patman") (which "true"))
438 ;; This test would require internet access.
439 (("\\./tools/buildman/buildman") (which "true")))
440 (substitute* "test/py/tests/test_sandbox_exit.py"
442 "@pytest.mark.skip(reason='Guix has problems with SIGINT')
444 (for-each (lambda (file)
446 ;; Disable signatures, due to GPL/Openssl
447 ;; license incompatibilities. See
448 ;; https://bugs.gnu.org/34717 for details.
449 (("CONFIG_FIT_SIGNATURE=y") "CONFIG_FIT_SIGNATURE=n")
450 ;; This test requires a sound system, which is un-used
452 (("CONFIG_SOUND=y") "CONFIG_SOUND=n")))
453 (find-files "configs" "sandbox_.*defconfig$"))
456 (lambda* (#:key make-flags #:allow-other-keys)
457 (call-with-output-file "configs/tools_defconfig"
459 (display "CONFIG_SYS_TEXT_BASE=0\n" port)))
460 (apply invoke "make" "tools_defconfig" make-flags)))
462 (lambda* (#:key inputs make-flags #:allow-other-keys)
463 (apply invoke "make" "tools-all" make-flags)))
465 (lambda* (#:key outputs #:allow-other-keys)
466 (let* ((out (assoc-ref outputs "out"))
467 (bin (string-append out "/bin")))
468 (for-each (lambda (name)
469 (install-file name bin))
473 "tools/gen_ethaddr_crc"
480 "tools/env/fw_printenv"
481 "tools/sunxi-spl-image-builder"))
484 (add-after 'install 'check
485 (lambda* (#:key make-flags test-target #:allow-other-keys)
486 (apply invoke "make" "mrproper" make-flags)
487 (setenv "SDL_VIDEODRIVER" "dummy")
488 (setenv "PAGER" "cat")
489 (apply invoke "make" test-target make-flags)
490 (symlink "build-sandbox_spl" "sandbox")
491 (invoke "test/image/test-imagetools.sh"))))))
492 (description "U-Boot is a bootloader used mostly for ARM boards. It
493 also initializes the boards (RAM etc). This package provides its
494 board-independent tools.")))
496 (define-public (make-u-boot-package board triplet)
497 "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
498 (let ((same-arch? (if (string-prefix? (%current-system)
499 (gnu-triplet->nix-system triplet))
504 (name (string-append "u-boot-"
505 (string-replace-substring (string-downcase board)
508 `(,@(if (not same-arch?)
509 `(("cross-gcc" ,(cross-gcc triplet #:xgcc gcc-7))
510 ("cross-binutils" ,(cross-binutils triplet)))
512 ,@(package-native-inputs u-boot)))
514 `(#:modules ((ice-9 ftw)
517 (guix build gnu-build-system))
521 ,@(if (not same-arch?)
522 `((string-append "CROSS_COMPILE=" ,triplet "-"))
525 (modify-phases %standard-phases
527 (lambda* (#:key outputs make-flags #:allow-other-keys)
528 (let ((config-name (string-append ,board "_defconfig")))
529 (if (file-exists? (string-append "configs/" config-name))
530 (apply invoke "make" `(,@make-flags ,config-name))
532 (display "Invalid board name. Valid board names are:"
533 (current-error-port))
534 (let ((suffix-len (string-length "_defconfig"))
535 (entries (scandir "configs")))
536 (for-each (lambda (file-name)
537 (when (string-suffix? "_defconfig" file-name)
538 (format (current-error-port)
540 (string-drop-right file-name
542 (sort entries string-ci<)))
543 (error "Invalid boardname ~s." ,board))))))
545 (lambda* (#:key outputs #:allow-other-keys)
546 (let* ((out (assoc-ref outputs "out"))
547 (libexec (string-append out "/libexec"))
550 ;; Those would not be reproducible
551 ;; because of the randomness used
553 ;; It's expected that the user will
554 ;; use u-boot-tools to generate them
558 "sunxi-spl-with-ecc.bin"
560 (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
561 (find-files "." "^(MLO|SPL)$"))))
563 (install-file ".config" libexec)
564 ;; Useful for "qemu -kernel".
565 (install-file "u-boot" libexec)
568 (let ((target-file (string-append libexec "/" file)))
569 (mkdir-p (dirname target-file))
570 (copy-file file target-file)))
574 (define-public u-boot-vexpress
575 (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
577 (define-public u-boot-malta
578 (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
580 (define-public u-boot-beagle-bone-black
581 (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))
583 (define-public (make-u-boot-sunxi64-package board triplet)
584 (let ((base (make-u-boot-package board triplet)))
588 (substitute-keyword-arguments (package-arguments base)
590 `(modify-phases ,phases
591 (add-after 'unpack 'set-environment
592 (lambda* (#:key inputs #:allow-other-keys)
593 (let ((bl31 (string-append (assoc-ref inputs "firmware")
596 ;; This is necessary when we're using the bundled dtc.
597 ;(setenv "PATH" (string-append (getenv "PATH") ":"
602 `(("firmware" ,arm-trusted-firmware-sun50i-a64)
603 ,@(package-native-inputs base))))))
605 (define-public u-boot-pine64-plus
606 (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu"))
608 (define-public u-boot-pinebook
609 (make-u-boot-sunxi64-package "pinebook" "aarch64-linux-gnu"))
611 (define-public u-boot-bananapi-m2-ultra
612 (make-u-boot-package "Bananapi_M2_Ultra" "arm-linux-gnueabihf"))
614 (define-public u-boot-a20-olinuxino-lime
615 (make-u-boot-package "A20-OLinuXino-Lime" "arm-linux-gnueabihf"))
617 (define-public u-boot-a20-olinuxino-lime2
618 (make-u-boot-package "A20-OLinuXino-Lime2" "arm-linux-gnueabihf"))
620 (define-public u-boot-a20-olinuxino-micro
621 (make-u-boot-package "A20-OLinuXino_MICRO" "arm-linux-gnueabihf"))
623 (define-public u-boot-nintendo-nes-classic-edition
624 (make-u-boot-package "Nintendo_NES_Classic_Edition" "arm-linux-gnueabihf"))
626 (define-public u-boot-wandboard
627 (make-u-boot-package "wandboard" "arm-linux-gnueabihf"))
629 (define-public u-boot-mx6cuboxi
630 (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf"))
632 (define-public u-boot-novena
633 (let ((base (make-u-boot-package "novena" "arm-linux-gnueabihf")))
636 (description "U-Boot is a bootloader used mostly for ARM boards. It
637 also initializes the boards (RAM etc).
639 This U-Boot is built for Novena. Be advised that this version, contrary
640 to Novena upstream, does not load u-boot.img from the first patition.")
642 (substitute-keyword-arguments (package-arguments base)
644 `(modify-phases ,phases
645 (add-after 'unpack 'patch-novena-defconfig
646 ;; Patch configuration to disable loading u-boot.img from FAT partition,
647 ;; allowing it to be installed at a device offset.
649 (substitute* "configs/novena_defconfig"
650 (("CONFIG_SPL_FAT_SUPPORT=y") "# CONFIG_SPL_FAT_SUPPORT is not set"))
653 (define-public u-boot-cubieboard
654 (make-u-boot-package "Cubieboard" "arm-linux-gnueabihf"))
656 (define-public u-boot-cubietruck
657 (make-u-boot-package "Cubietruck" "arm-linux-gnueabihf"))
659 (define-public u-boot-puma-rk3399
660 (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu")))
664 (substitute-keyword-arguments (package-arguments base)
666 `(modify-phases ,phases
667 (add-after 'unpack 'set-environment
668 (lambda* (#:key inputs #:allow-other-keys)
669 ;; Need to copy the firmware into u-boot build
671 (copy-file (string-append (assoc-ref inputs "firmware")
672 "/bl31.bin") "bl31-rk3399.bin")
673 (copy-file (string-append (assoc-ref inputs "firmware-m0")
674 "/rk3399m0.bin") "rk3399m0.bin")
676 (add-after 'build 'build-itb
677 (lambda* (#:key make-flags #:allow-other-keys)
678 ;; The u-boot.itb is not built by default.
679 (apply invoke "make" `(,@make-flags ,"u-boot.itb"))))
680 (add-after 'build-itb 'build-rksd
681 (lambda* (#:key inputs #:allow-other-keys)
682 ;; Build Rockchip SD card images.
683 (invoke "./tools/mkimage" "-T" "rksd" "-n" "rk3399" "-d"
684 "spl/u-boot-spl.bin" "u-boot-spl.rksd")))))))
686 `(("firmware" ,arm-trusted-firmware-puma-rk3399)
687 ("firmware-m0" ,rk3399-cortex-m0)
688 ,@(package-native-inputs base))))))
690 (define-public vboot-utils
693 (version "R63-10032.B")
695 ;; XXX: Snapshots are available but changes timestamps every download.
698 (url (string-append "https://chromium.googlesource.com"
699 "/chromiumos/platform/vboot_reference"))
700 (commit (string-append "release-" version))))
701 (file-name (string-append name "-" version "-checkout"))
704 "0h0m3l69vp9dr6xrs1p6y7ilkq3jq8jraw2z20kqfv7lvc9l1lxj"))
706 (search-patches "vboot-utils-skip-test-workbuf.patch"
707 "vboot-utils-fix-tests-show-contents.patch"
708 "vboot-utils-fix-format-load-address.patch"))))
709 (build-system gnu-build-system)
711 `(#:make-flags (list "CC=gcc"
712 ;; On ARM, we must pass "HOST_ARCH=arm" so that the
713 ;; ${HOST_ARCH} and ${ARCH} variables in the makefile
714 ;; match. Otherwise, ${HOST_ARCH} will be assigned
715 ;; "armv7l", the value of `uname -m`, and will not
716 ;; match ${ARCH}, which will make the tests require
718 ,@(if (string-prefix? "arm"
719 (or (%current-target-system)
723 (string-append "DESTDIR=" (assoc-ref %outputs "out")))
724 #:phases (modify-phases %standard-phases
725 (add-after 'unpack 'patch-hard-coded-paths
726 (lambda* (#:key inputs outputs #:allow-other-keys)
727 (let ((coreutils (assoc-ref inputs "coreutils"))
728 (diffutils (assoc-ref inputs "diffutils")))
729 (substitute* "futility/misc.c"
730 (("/bin/cp") (string-append coreutils "/bin/cp")))
731 (substitute* "tests/bitmaps/TestBmpBlock.py"
732 (("/usr/bin/cmp") (string-append diffutils "/bin/cmp")))
733 (substitute* "vboot_host.pc.in"
735 (string-append "prefix=" (assoc-ref outputs "out"))))
738 (add-before 'check 'patch-tests
740 ;; These tests compare diffs against known-good values.
741 ;; Patch the paths to match those in the build container.
742 (substitute* (find-files "tests/futility/expect_output")
743 (("/mnt/host/source/src/platform/vboot_reference")
744 (string-append "/tmp/guix-build-" ,name "-" ,version
746 ;; Tests require write permissions to many of these files.
747 (for-each make-file-writable (find-files "tests/futility"))
749 (add-after 'install 'install-devkeys
750 (lambda* (#:key outputs #:allow-other-keys)
751 (let* ((out (assoc-ref outputs "out"))
752 (share (string-append out "/share/vboot-utils")))
753 (copy-recursively "tests/devkeys"
754 (string-append share "/devkeys"))
756 #:test-target "runtests"))
758 `(("pkg-config" ,pkg-config)
761 ("diffutils" ,diffutils)
762 ("python@2" ,python-2)))
764 `(("coreutils" ,coreutils)
767 ("openssl:static" ,openssl "static")
768 ("util-linux" ,util-linux)))
770 "https://dev.chromium.org/chromium-os/chromiumos-design-docs/verified-boot")
771 (synopsis "ChromiumOS verified boot utilities")
773 "vboot-utils is a collection of tools to facilitate booting of
774 Chrome-branded devices. This includes the @command{cgpt} partitioning
775 program, the @command{futility} and @command{crossystem} firmware management
777 (license license:bsd-3)))
779 (define-public os-prober
786 (uri (string-append "mirror://debian/pool/main/o/os-prober/os-prober_"
790 "0pvhrw4h05n21zw7ig3a3bi8aqdh6zxs0x1znz4g7vhspsps93ld"))))
791 (build-system gnu-build-system)
793 `(#:modules ((guix build gnu-build-system)
795 (ice-9 regex) ; for string-match
796 (srfi srfi-26)) ; for cut
797 #:make-flags (list "CC=gcc")
798 #:tests? #f ; no tests
800 (modify-phases %standard-phases
802 (lambda* (#:key outputs #:allow-other-keys)
803 (substitute* (find-files ".")
804 (("/usr") (assoc-ref outputs "out")))
805 (substitute* (find-files "." "50mounted-tests$")
806 (("mkdir") "mkdir -p"))
809 (lambda* (#:key outputs #:allow-other-keys)
810 (define (find-files-non-recursive directory)
811 (find-files directory
813 (string-match (string-append "^" directory "/[^/]*$")
817 (let* ((out (assoc-ref outputs "out"))
818 (bin (string-append out "/bin"))
819 (lib (string-append out "/lib"))
820 (share (string-append out "/share")))
821 (for-each (cut install-file <> bin)
822 (list "linux-boot-prober" "os-prober"))
823 (install-file "newns" (string-append lib "/os-prober"))
824 (install-file "common.sh" (string-append share "/os-prober"))
825 (install-file "os-probes/mounted/powerpc/20macosx"
826 (string-append lib "/os-probes/mounted"))
831 (let ((destination (string-append lib "/" directory
832 "/" (basename file))))
833 (mkdir-p (dirname destination))
834 (copy-recursively file destination)))
835 (append (find-files-non-recursive (string-append directory "/common"))
836 (find-files-non-recursive (string-append directory "/x86")))))
837 (list "os-probes" "os-probes/mounted" "os-probes/init"
838 "linux-boot-probes" "linux-boot-probes/mounted"))
840 (home-page "https://joeyh.name/code/os-prober")
841 (synopsis "Detect other operating systems")
842 (description "os-prober probes disks on the system for other operating
843 systems so that they can be added to the bootloader. It also works out how to
844 boot existing GNU/Linux systems and detects what distribution is installed in
845 order to add a suitable bootloader menu entry.")
846 (license license:gpl2+)))