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 "grub-efi-fat-serial-number.patch"))))
95 (build-system gnu-build-system)
97 `(#:phases (modify-phases %standard-phases
98 (add-after 'unpack 'patch-stuff
99 (lambda* (#:key inputs #:allow-other-keys)
100 (substitute* "grub-core/Makefile.in"
101 (("/bin/sh") (which "sh")))
103 ;; Give the absolute file name of 'mdadm', used to
104 ;; determine the root file system when it's a RAID
105 ;; device. Failing to do that, 'grub-probe' silently
106 ;; fails if 'mdadm' is not in $PATH.
107 (substitute* "grub-core/osdep/linux/getroot.c"
108 (("argv\\[0\\] = \"mdadm\"")
109 (string-append "argv[0] = \""
110 (assoc-ref inputs "mdadm")
113 ;; Make the font visible.
114 (copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz")
115 (system* "gunzip" "unifont.bdf.gz")
117 ;; Give the absolute file name of 'ckbcomp'.
118 (substitute* "util/grub-kbdcomp.in"
120 (string-append (assoc-ref inputs "console-setup")
123 (add-before 'check 'disable-flaky-test
125 ;; This test is unreliable. For more information, see:
126 ;; <https://bugs.gnu.org/26936>.
127 (substitute* "Makefile.in"
128 (("grub_cmd_date grub_cmd_set_date grub_cmd_sleep")
129 "grub_cmd_date grub_cmd_sleep"))
131 ;; Disable tests on ARM and AARCH64 platforms.
132 #:tests? ,(not (any (cute string-prefix? <> (or (%current-target-system)
134 '("arm" "aarch64")))))
136 `(("gettext" ,gettext-minimal)
138 ;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and
139 ;; 'grub-install' to recognize mapped devices (LUKS, etc.)
142 ;; Depend on mdadm, which is invoked by 'grub-probe' and 'grub-install'
143 ;; to determine whether the root file system is RAID.
146 ;; Console-setup's ckbcomp is invoked by grub-kbdcomp. It is required
147 ;; for generating alternative keyboard layouts.
148 ("console-setup" ,console-setup)
150 ("freetype" ,freetype)
151 ;; ("libusb" ,libusb)
153 ("ncurses" ,ncurses)))
155 `(("pkg-config" ,pkg-config)
158 ;; Due to a bug in flex >= 2.6.2, GRUB must be built with an older flex:
159 ;; <http://lists.gnu.org/archive/html/grub-devel/2017-02/msg00133.html>
160 ;; TODO Try building with flex > 2.6.4.
163 ("help2man" ,help2man)
165 ;; XXX: When building GRUB 2.02 on 32-bit x86, we need a binutils
166 ;; capable of assembling 64-bit instructions. However, our default
167 ;; binutils on 32-bit x86 is not 64-bit capable.
168 ,@(if (string-match "^i[3456]86-" (%current-system))
169 (let ((binutils (package/inherit
171 (name "binutils-i386")
173 (substitute-keyword-arguments (package-arguments binutils)
174 ((#:configure-flags flags ''())
175 `(cons "--enable-64-bit-bfd" ,flags)))))))
176 `(("ld-wrapper" ,(make-ld-wrapper "ld-wrapper-i386"
177 #:binutils binutils))
178 ("binutils" ,binutils)))
181 ;; Dependencies for the test suite. The "real" QEMU is needed here,
182 ;; because several targets are used.
184 ("qemu" ,qemu-minimal-2.10)
185 ("xorriso" ,xorriso)))
186 (home-page "https://www.gnu.org/software/grub/")
187 (synopsis "GRand Unified Boot loader")
189 "GRUB is a multiboot bootloader. It is used for initially loading the
190 kernel of an operating system and then transferring control to it. The kernel
191 then goes on to load the rest of the operating system. As a multiboot
192 bootloader, GRUB handles the presence of multiple operating systems installed
193 on the same computer; upon booting the computer, the user is presented with a
194 menu to select one of the installed operating systems.")
195 (license license:gpl3+)
196 (properties '((cpe-name . "grub2")))))
198 (define-public grub-efi
202 (synopsis "GRand Unified Boot loader (UEFI version)")
204 `(("efibootmgr" ,efibootmgr)
206 ,@(package-inputs grub)))
208 `(;; TODO: Tests need a UEFI firmware for qemu. There is one at
209 ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
210 ;; Search for 'OVMF' in "tests/util/grub-shell.in".
211 ,@(substitute-keyword-arguments (package-arguments grub)
213 ((#:configure-flags flags ''())
214 `(cons "--with-platform=efi" ,flags))
216 `(modify-phases ,phases
217 (add-after 'patch-stuff 'use-absolute-efibootmgr-path
218 (lambda* (#:key inputs #:allow-other-keys)
219 (substitute* "grub-core/osdep/unix/platform.c"
221 (string-append (assoc-ref inputs "efibootmgr")
222 "/sbin/efibootmgr")))
224 (add-after 'patch-stuff 'use-absolute-mtools-path
225 (lambda* (#:key inputs #:allow-other-keys)
226 (let ((mtools (assoc-ref inputs "mtools")))
227 (substitute* "util/grub-mkrescue.c"
229 (string-append "\"" mtools
231 (substitute* "util/grub-mkrescue.c"
233 (string-append "\"" mtools
237 ;; Because grub searches hardcoded paths it's easiest to just build grub
238 ;; again to make it find both grub-pc and grub-efi. There is a command
239 ;; line argument which allows you to specify ONE platform - but
240 ;; grub-mkrescue will use multiple platforms if they are available
241 ;; in the installation directory (without command line argument).
242 (define-public grub-hybrid
246 (synopsis "GRand Unified Boot loader (hybrid version)")
249 ,@(package-inputs grub-efi)))
251 (substitute-keyword-arguments (package-arguments grub-efi)
252 ((#:modules modules `((guix build utils) (guix build gnu-build-system)))
253 `((ice-9 ftw) ,@modules))
255 `(modify-phases ,phases
256 (add-after 'install 'install-non-efi
257 (lambda* (#:key inputs outputs #:allow-other-keys)
258 (let ((input-dir (string-append (assoc-ref inputs "grub")
260 (output-dir (string-append (assoc-ref outputs "out")
264 (if (not (or (string-prefix? "." basename)
265 (file-exists? (string-append output-dir "/" basename))))
266 (symlink (string-append input-dir "/" basename)
267 (string-append output-dir "/" basename))))
271 (define-public syslinux
272 (let ((commit "bb41e935cc83c6242de24d2271e067d76af3585c"))
275 (version (git-version "6.04-pre" "1" commit))
279 (url "https://github.com/geneC/syslinux")
281 (file-name (git-file-name name version))
284 "0k8dvafd6410kqxf3kyr4y8jzmpmrih6wbjqg6gklak7945yflrc"))))
285 (build-system gnu-build-system)
289 ("python-2" ,python-2)))
291 `(("libuuid" ,util-linux)
294 `(#:parallel-build? #f
296 (list (string-append "BINDIR=" %output "/bin")
297 (string-append "SBINDIR=" %output "/sbin")
298 (string-append "LIBDIR=" %output "/lib")
299 (string-append "INCDIR=" %output "/include")
300 (string-append "DATADIR=" %output "/share")
301 (string-append "MANDIR=" %output "/share/man")
305 (modify-phases %standard-phases
306 (add-after 'unpack 'patch-files
307 (lambda* (#:key inputs #:allow-other-keys)
308 (substitute* (find-files "." "Makefile.*|ppmtolss16")
309 (("/bin/pwd") (which "pwd"))
310 (("/bin/echo") (which "echo"))
311 (("/usr/bin/perl") (which "perl")))
312 (let ((mtools (assoc-ref inputs "mtools")))
313 (substitute* (find-files "." "\\.c$")
315 (string-append mtools "/bin/mcopy"))
317 (string-append mtools "/bin/mattrib"))))
320 (add-before 'build 'set-permissions
322 (invoke "chmod" "a+w" "utils/isohybrid.in")))
326 (substitute* "tests/unittest/include/unittest/unittest.h"
327 ;; Don't look up headers under /usr.
328 (("/usr/include/") ""))
329 (invoke "make" "unittest"))))))
330 (home-page "https://www.syslinux.org")
331 (synopsis "Lightweight Linux bootloader")
332 (description "Syslinux is a lightweight Linux bootloader.")
333 ;; The Makefile specifically targets i386 and x86_64 using nasm.
334 (supported-systems '("i686-linux" "x86_64-linux"))
335 (license (list license:gpl2+
336 license:bsd-3 ; gnu-efi/*
337 license:bsd-4 ; gnu-efi/inc/* gnu-efi/lib/*
339 license:expat license:isc license:zlib)))))
348 "mirror://kernel.org/software/utils/dtc/"
349 "dtc-" version ".tar.xz"))
352 "0wh10p42hf5403ipvs0dsxddb6kzfyk2sq4fgid9zqzpr51y8wn6"))))
353 (build-system gnu-build-system)
358 ("pkg-config" ,pkg-config)
360 ("valgrind" ,valgrind)))
362 `(("python-2" ,python-2)))
366 (string-append "PREFIX=" (assoc-ref %outputs "out"))
367 (string-append "SETUP_PREFIX=" (assoc-ref %outputs "out"))
370 (modify-phases %standard-phases
371 (delete 'configure)))) ; no configure script
372 (home-page "https://www.devicetree.org")
373 (synopsis "Compiles device tree source files")
374 (description "@command{dtc} compiles
375 @uref{http://elinux.org/Device_Tree_Usage, device tree source files} to device
376 tree binary files. These are board description files used by Linux and BSD.")
377 (license license:gpl2+)))
386 "ftp://ftp.denx.de/pub/u-boot/"
387 "u-boot-" version ".tar.bz2"))
390 "1vwv4bgbl7fjcm073zrphn17hnz5h5h778f88ivdsgbb2lnpgdvn"))
393 "u-boot-fix-mkimage-header-verification.patch"))))
400 ("python-2" ,python-2)
401 ("python2-coverage" ,python2-coverage)
402 ("python2-pytest" ,python2-pytest)
405 (build-system gnu-build-system)
406 (home-page "https://www.denx.de/wiki/U-Boot/")
407 (synopsis "ARM bootloader")
408 (description "U-Boot is a bootloader used mostly for ARM boards. It
409 also initializes the boards (RAM etc).")
410 (license license:gpl2+)))
412 (define-public u-boot-tools
415 (name "u-boot-tools")
417 `(#:make-flags '("HOSTCC=gcc")
418 #:test-target "tests"
420 (modify-phases %standard-phases
421 (add-after 'unpack 'patch
422 (lambda* (#:key inputs #:allow-other-keys)
423 (substitute* "Makefile"
424 (("/bin/pwd") (which "pwd"))
425 (("/bin/false") (which "false")))
426 (substitute* "tools/dtoc/fdt_util.py"
428 (substitute* "tools/patman/test_util.py"
429 ;; python-coverage is simply called coverage in guix.
430 (("python-coverage") "coverage")
431 ;; XXX Allow for only 99% test coverage.
432 ;; TODO: Find out why that is needed.
433 (("if coverage != '100%':") "if not int(coverage.rstrip('%')) >= 99:"))
434 (substitute* "test/run"
435 ;; Make it easier to find test failures.
436 (("#!/bin/bash") "#!/bin/bash -x")
437 ;; pytest doesn't find it otherwise.
438 (("test/py/tests/test_ofplatdata.py")
439 "tests/test_ofplatdata.py")
440 ;; This test would require git.
441 (("\\./tools/patman/patman") (which "true"))
442 ;; This test would require internet access.
443 (("\\./tools/buildman/buildman") (which "true")))
444 (substitute* "test/py/tests/test_sandbox_exit.py"
446 "@pytest.mark.skip(reason='Guix has problems with SIGINT')
448 ;; Test against the tools being installed rather than tools built
449 ;; for "sandbox" target.
450 (substitute* "test/image/test-imagetools.sh"
451 (("BASEDIR=sandbox") "BASEDIR=."))
452 (for-each (lambda (file)
454 ;; Disable signatures, due to GPL/Openssl
455 ;; license incompatibilities. See
456 ;; https://bugs.gnu.org/34717 for details.
457 (("CONFIG_FIT_SIGNATURE=y") "CONFIG_FIT_SIGNATURE=n")
458 ;; This test requires a sound system, which is un-used
460 (("CONFIG_SOUND=y") "CONFIG_SOUND=n")))
461 (find-files "configs" "sandbox_.*defconfig$"))
464 (lambda* (#:key make-flags #:allow-other-keys)
465 (call-with-output-file "configs/tools_defconfig"
467 (display "CONFIG_SYS_TEXT_BASE=0\n" port)))
468 (apply invoke "make" "tools_defconfig" make-flags)))
470 (lambda* (#:key inputs make-flags #:allow-other-keys)
471 (apply invoke "make" "tools-all" make-flags)))
473 (lambda* (#:key outputs #:allow-other-keys)
474 (let* ((out (assoc-ref outputs "out"))
475 (bin (string-append out "/bin")))
476 (for-each (lambda (name)
477 (install-file name bin))
481 "tools/gen_ethaddr_crc"
488 "tools/env/fw_printenv"
489 "tools/sunxi-spl-image-builder"))
492 (add-after 'install 'check
493 (lambda* (#:key make-flags test-target #:allow-other-keys)
494 (invoke "test/image/test-imagetools.sh")))
495 ;; Only run full test suite on x86_64 systems, as many tests
497 ,@(if (string-match "^x86_64-linux"
498 (or (%current-target-system)
500 '((add-after 'check 'check-x86
501 (lambda* (#:key make-flags test-target #:allow-other-keys)
502 (apply invoke "make" "mrproper" make-flags)
503 (setenv "SDL_VIDEODRIVER" "dummy")
504 (setenv "PAGER" "cat")
505 (apply invoke "make" test-target make-flags))))
507 (description "U-Boot is a bootloader used mostly for ARM boards. It
508 also initializes the boards (RAM etc). This package provides its
509 board-independent tools.")))
511 (define-public (make-u-boot-package board triplet)
512 "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
513 (let ((same-arch? (if (string-prefix? (%current-system)
514 (gnu-triplet->nix-system triplet))
519 (name (string-append "u-boot-"
520 (string-replace-substring (string-downcase board)
523 `(,@(if (not same-arch?)
524 `(("cross-gcc" ,(cross-gcc triplet #:xgcc gcc-7))
525 ("cross-binutils" ,(cross-binutils triplet)))
527 ,@(package-native-inputs u-boot)))
529 `(#:modules ((ice-9 ftw)
532 (guix build gnu-build-system))
536 ,@(if (not same-arch?)
537 `((string-append "CROSS_COMPILE=" ,triplet "-"))
540 (modify-phases %standard-phases
542 (lambda* (#:key outputs make-flags #:allow-other-keys)
543 (let ((config-name (string-append ,board "_defconfig")))
544 (if (file-exists? (string-append "configs/" config-name))
545 (apply invoke "make" `(,@make-flags ,config-name))
547 (display "Invalid board name. Valid board names are:"
548 (current-error-port))
549 (let ((suffix-len (string-length "_defconfig"))
550 (entries (scandir "configs")))
551 (for-each (lambda (file-name)
552 (when (string-suffix? "_defconfig" file-name)
553 (format (current-error-port)
555 (string-drop-right file-name
557 (sort entries string-ci<)))
558 (error "Invalid boardname ~s." ,board))))))
560 (lambda* (#:key outputs #:allow-other-keys)
561 (let* ((out (assoc-ref outputs "out"))
562 (libexec (string-append out "/libexec"))
565 ;; Those would not be reproducible
566 ;; because of the randomness used
568 ;; It's expected that the user will
569 ;; use u-boot-tools to generate them
573 "sunxi-spl-with-ecc.bin"
575 (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
576 (find-files "." "^(MLO|SPL)$"))))
578 (install-file ".config" libexec)
579 ;; Useful for "qemu -kernel".
580 (install-file "u-boot" libexec)
583 (let ((target-file (string-append libexec "/" file)))
584 (mkdir-p (dirname target-file))
585 (copy-file file target-file)))
589 (define-public u-boot-vexpress
590 (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
592 (define-public u-boot-malta
593 (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
595 (define-public u-boot-am335x-boneblack
596 (let ((base (make-u-boot-package "am335x_evm" "arm-linux-gnueabihf")))
599 (name "u-boot-am335x-boneblack")
600 (description "U-Boot is a bootloader used mostly for ARM boards. It
601 also initializes the boards (RAM etc).
603 This U-Boot is built for the BeagleBone Black, which was removed upstream,
604 adjusted from the am335x_evm build with several device trees removed so that
605 it fits within common partitioning schemes.")
607 (substitute-keyword-arguments (package-arguments base)
609 `(modify-phases ,phases
610 (add-after 'unpack 'patch-defconfig
611 ;; Patch out other devicetrees to build image small enough to
612 ;; fit within typical partitioning schemes where the first
613 ;; partition begins at sector 2048.
615 (substitute* "configs/am335x_evm_defconfig"
616 (("CONFIG_OF_LIST=.*$") "CONFIG_OF_LIST=\"am335x-evm am335x-boneblack\"\n"))
619 (define-public u-boot-am335x-evm
620 (make-u-boot-package "am335x_evm" "arm-linux-gnueabihf"))
622 (define-public (make-u-boot-sunxi64-package board triplet)
623 (let ((base (make-u-boot-package board triplet)))
627 (substitute-keyword-arguments (package-arguments base)
629 `(modify-phases ,phases
630 (add-after 'unpack 'set-environment
631 (lambda* (#:key inputs #:allow-other-keys)
632 (let ((bl31 (string-append (assoc-ref inputs "firmware")
635 ;; This is necessary when we're using the bundled dtc.
636 ;(setenv "PATH" (string-append (getenv "PATH") ":"
641 `(("firmware" ,arm-trusted-firmware-sun50i-a64)
642 ,@(package-native-inputs base))))))
644 (define-public u-boot-pine64-plus
645 (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu"))
647 (define-public u-boot-pinebook
648 (make-u-boot-sunxi64-package "pinebook" "aarch64-linux-gnu"))
650 (define-public u-boot-bananapi-m2-ultra
651 (make-u-boot-package "Bananapi_M2_Ultra" "arm-linux-gnueabihf"))
653 (define-public u-boot-a20-olinuxino-lime
654 (make-u-boot-package "A20-OLinuXino-Lime" "arm-linux-gnueabihf"))
656 (define-public u-boot-a20-olinuxino-lime2
657 (make-u-boot-package "A20-OLinuXino-Lime2" "arm-linux-gnueabihf"))
659 (define-public u-boot-a20-olinuxino-micro
660 (make-u-boot-package "A20-OLinuXino_MICRO" "arm-linux-gnueabihf"))
662 (define-public u-boot-nintendo-nes-classic-edition
663 (make-u-boot-package "Nintendo_NES_Classic_Edition" "arm-linux-gnueabihf"))
665 (define-public u-boot-wandboard
666 (make-u-boot-package "wandboard" "arm-linux-gnueabihf"))
668 (define-public u-boot-mx6cuboxi
669 (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf"))
671 (define-public u-boot-novena
672 (let ((base (make-u-boot-package "novena" "arm-linux-gnueabihf")))
675 (description "U-Boot is a bootloader used mostly for ARM boards. It
676 also initializes the boards (RAM etc).
678 This U-Boot is built for Novena. Be advised that this version, contrary
679 to Novena upstream, does not load u-boot.img from the first partition.")
681 (substitute-keyword-arguments (package-arguments base)
683 `(modify-phases ,phases
684 (add-after 'unpack 'patch-novena-defconfig
685 ;; Patch configuration to disable loading u-boot.img from FAT partition,
686 ;; allowing it to be installed at a device offset.
688 (substitute* "configs/novena_defconfig"
689 (("CONFIG_SPL_FS_FAT=y") "# CONFIG_SPL_FS_FAT is not set"))
692 (define-public u-boot-cubieboard
693 (make-u-boot-package "Cubieboard" "arm-linux-gnueabihf"))
695 (define-public u-boot-cubietruck
696 (make-u-boot-package "Cubietruck" "arm-linux-gnueabihf"))
698 (define-public u-boot-puma-rk3399
699 (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu")))
703 (substitute-keyword-arguments (package-arguments base)
705 `(modify-phases ,phases
706 (add-after 'unpack 'set-environment
707 (lambda* (#:key inputs #:allow-other-keys)
708 ;; Need to copy the firmware into u-boot build
710 (copy-file (string-append (assoc-ref inputs "firmware")
711 "/bl31.bin") "bl31-rk3399.bin")
712 (copy-file (string-append (assoc-ref inputs "firmware-m0")
713 "/rk3399m0.bin") "rk3399m0.bin")
715 (add-after 'build 'build-itb
716 (lambda* (#:key make-flags #:allow-other-keys)
717 ;; The u-boot.itb is not built by default.
718 (apply invoke "make" `(,@make-flags ,"u-boot.itb"))))
719 (add-after 'build-itb 'build-rksd
720 (lambda* (#:key inputs #:allow-other-keys)
721 ;; Build Rockchip SD card images.
722 (invoke "./tools/mkimage" "-T" "rksd" "-n" "rk3399" "-d"
723 "spl/u-boot-spl.bin" "u-boot-spl.rksd")))))))
725 `(("firmware" ,arm-trusted-firmware-puma-rk3399)
726 ("firmware-m0" ,rk3399-cortex-m0)
727 ,@(package-native-inputs base))))))
729 (define-public vboot-utils
732 (version "R63-10032.B")
734 ;; XXX: Snapshots are available but changes timestamps every download.
737 (url (string-append "https://chromium.googlesource.com"
738 "/chromiumos/platform/vboot_reference"))
739 (commit (string-append "release-" version))))
740 (file-name (string-append name "-" version "-checkout"))
743 "0h0m3l69vp9dr6xrs1p6y7ilkq3jq8jraw2z20kqfv7lvc9l1lxj"))
745 (search-patches "vboot-utils-skip-test-workbuf.patch"
746 "vboot-utils-fix-tests-show-contents.patch"
747 "vboot-utils-fix-format-load-address.patch"))))
748 (build-system gnu-build-system)
750 `(#:make-flags (list "CC=gcc"
751 ;; On ARM, we must pass "HOST_ARCH=arm" so that the
752 ;; ${HOST_ARCH} and ${ARCH} variables in the makefile
753 ;; match. Otherwise, ${HOST_ARCH} will be assigned
754 ;; "armv7l", the value of `uname -m`, and will not
755 ;; match ${ARCH}, which will make the tests require
757 ,@(if (string-prefix? "arm"
758 (or (%current-target-system)
762 (string-append "DESTDIR=" (assoc-ref %outputs "out")))
763 #:phases (modify-phases %standard-phases
764 (add-after 'unpack 'patch-hard-coded-paths
765 (lambda* (#:key inputs outputs #:allow-other-keys)
766 (let ((coreutils (assoc-ref inputs "coreutils"))
767 (diffutils (assoc-ref inputs "diffutils")))
768 (substitute* "futility/misc.c"
769 (("/bin/cp") (string-append coreutils "/bin/cp")))
770 (substitute* "tests/bitmaps/TestBmpBlock.py"
771 (("/usr/bin/cmp") (string-append diffutils "/bin/cmp")))
772 (substitute* "vboot_host.pc.in"
774 (string-append "prefix=" (assoc-ref outputs "out"))))
777 (add-before 'check 'patch-tests
779 ;; These tests compare diffs against known-good values.
780 ;; Patch the paths to match those in the build container.
781 (substitute* (find-files "tests/futility/expect_output")
782 (("/mnt/host/source/src/platform/vboot_reference")
783 (string-append "/tmp/guix-build-" ,name "-" ,version
785 ;; Tests require write permissions to many of these files.
786 (for-each make-file-writable (find-files "tests/futility"))
788 (add-after 'install 'install-devkeys
789 (lambda* (#:key outputs #:allow-other-keys)
790 (let* ((out (assoc-ref outputs "out"))
791 (share (string-append out "/share/vboot-utils")))
792 (copy-recursively "tests/devkeys"
793 (string-append share "/devkeys"))
795 #:test-target "runtests"))
797 `(("pkg-config" ,pkg-config)
800 ("diffutils" ,diffutils)
801 ("python@2" ,python-2)))
803 `(("coreutils" ,coreutils)
806 ("openssl:static" ,openssl "static")
807 ("util-linux" ,util-linux)))
809 "https://dev.chromium.org/chromium-os/chromiumos-design-docs/verified-boot")
810 (synopsis "ChromiumOS verified boot utilities")
812 "vboot-utils is a collection of tools to facilitate booting of
813 Chrome-branded devices. This includes the @command{cgpt} partitioning
814 program, the @command{futility} and @command{crossystem} firmware management
816 (license license:bsd-3)))
818 (define-public os-prober
825 (uri (string-append "mirror://debian/pool/main/o/os-prober/os-prober_"
829 "0pvhrw4h05n21zw7ig3a3bi8aqdh6zxs0x1znz4g7vhspsps93ld"))))
830 (build-system gnu-build-system)
832 `(#:modules ((guix build gnu-build-system)
834 (ice-9 regex) ; for string-match
835 (srfi srfi-26)) ; for cut
836 #:make-flags (list "CC=gcc")
837 #:tests? #f ; no tests
839 (modify-phases %standard-phases
841 (lambda* (#:key outputs #:allow-other-keys)
842 (substitute* (find-files ".")
843 (("/usr") (assoc-ref outputs "out")))
844 (substitute* (find-files "." "50mounted-tests$")
845 (("mkdir") "mkdir -p"))
848 (lambda* (#:key outputs #:allow-other-keys)
849 (define (find-files-non-recursive directory)
850 (find-files directory
852 (string-match (string-append "^" directory "/[^/]*$")
856 (let* ((out (assoc-ref outputs "out"))
857 (bin (string-append out "/bin"))
858 (lib (string-append out "/lib"))
859 (share (string-append out "/share")))
860 (for-each (cut install-file <> bin)
861 (list "linux-boot-prober" "os-prober"))
862 (install-file "newns" (string-append lib "/os-prober"))
863 (install-file "common.sh" (string-append share "/os-prober"))
864 (install-file "os-probes/mounted/powerpc/20macosx"
865 (string-append lib "/os-probes/mounted"))
870 (let ((destination (string-append lib "/" directory
871 "/" (basename file))))
872 (mkdir-p (dirname destination))
873 (copy-recursively file destination)))
874 (append (find-files-non-recursive (string-append directory "/common"))
875 (find-files-non-recursive (string-append directory "/x86")))))
876 (list "os-probes" "os-probes/mounted" "os-probes/init"
877 "linux-boot-probes" "linux-boot-probes/mounted"))
879 (home-page "https://joeyh.name/code/os-prober")
880 (synopsis "Detect other operating systems")
881 (description "os-prober probes disks on the system for other operating
882 systems so that they can be added to the bootloader. It also works out how to
883 boot existing GNU/Linux systems and detects what distribution is installed in
884 order to add a suitable bootloader menu entry.")
885 (license license:gpl2+)))