Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / bootloaders.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 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 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages bootloaders)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages admin)
30 #:use-module ((gnu packages algebra) #:select (bc))
31 #:use-module (gnu packages assembly)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages disk)
34 #:use-module (gnu packages bison)
35 #:use-module (gnu packages cdrom)
36 #:use-module (gnu packages check)
37 #:use-module (gnu packages cross-base)
38 #:use-module (gnu packages disk)
39 #:use-module (gnu packages firmware)
40 #:use-module (gnu packages flex)
41 #:use-module (gnu packages fontutils)
42 #:use-module (gnu packages gcc)
43 #:use-module (gnu packages gettext)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages man)
46 #:use-module (gnu packages mtools)
47 #:use-module (gnu packages ncurses)
48 #:use-module (gnu packages perl)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages python)
51 #:use-module (gnu packages texinfo)
52 #:use-module (gnu packages tls)
53 #:use-module (gnu packages sdl)
54 #:use-module (gnu packages swig)
55 #:use-module (gnu packages valgrind)
56 #:use-module (gnu packages virtualization)
57 #:use-module (gnu packages web)
58 #:use-module (guix build-system gnu)
59 #:use-module (guix download)
60 #:use-module (guix git-download)
61 #:use-module ((guix licenses) #:prefix license:)
62 #:use-module (guix packages)
63 #:use-module (guix utils)
64 #:use-module (srfi srfi-1)
65 #:use-module (srfi srfi-26)
66 #:use-module (ice-9 regex))
67
68 (define unifont
69 ;; GNU Unifont, <http://gnu.org/s/unifont>.
70 ;; GRUB needs it for its graphical terminal, gfxterm.
71 (origin
72 (method url-fetch)
73 (uri
74 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
75 (sha256
76 (base32
77 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
78
79 (define-public grub
80 (package
81 (name "grub")
82 (version "2.02")
83 (source (origin
84 (method url-fetch)
85 (uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz"))
86 (sha256
87 (base32
88 "03vvdfhdmf16121v7xs8is2krwnv15wpkhkf16a4yf8nsfc3f2w1"))
89 (patches (search-patches "grub-check-error-efibootmgr.patch"
90 "grub-binutils-compat.patch"))))
91 (build-system gnu-build-system)
92 (arguments
93 `(#:phases (modify-phases %standard-phases
94 (add-after 'unpack 'patch-stuff
95 (lambda* (#:key inputs #:allow-other-keys)
96 (substitute* "grub-core/Makefile.in"
97 (("/bin/sh") (which "sh")))
98
99 ;; Give the absolute file name of 'mdadm', used to
100 ;; determine the root file system when it's a RAID
101 ;; device. Failing to do that, 'grub-probe' silently
102 ;; fails if 'mdadm' is not in $PATH.
103 (substitute* "grub-core/osdep/linux/getroot.c"
104 (("argv\\[0\\] = \"mdadm\"")
105 (string-append "argv[0] = \""
106 (assoc-ref inputs "mdadm")
107 "/sbin/mdadm\"")))
108
109 ;; Make the font visible.
110 (copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz")
111 (system* "gunzip" "unifont.bdf.gz")
112 #t))
113 (add-before 'check 'disable-flaky-test
114 (lambda _
115 ;; This test is unreliable. For more information, see:
116 ;; <https://bugs.gnu.org/26936>.
117 (substitute* "Makefile.in"
118 (("grub_cmd_date grub_cmd_set_date grub_cmd_sleep")
119 "grub_cmd_date grub_cmd_sleep"))
120 #t)))
121 ;; Disable tests on ARM and AARCH64 platforms.
122 #:tests? ,(not (any (cute string-prefix? <> (or (%current-target-system)
123 (%current-system)))
124 '("arm" "aarch64")))))
125 (inputs
126 `(("gettext" ,gettext-minimal)
127
128 ;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and
129 ;; 'grub-install' to recognize mapped devices (LUKS, etc.)
130 ("lvm2" ,lvm2)
131
132 ;; Depend on mdadm, which is invoked by 'grub-probe' and 'grub-install'
133 ;; to determine whether the root file system is RAID.
134 ("mdadm" ,mdadm)
135
136 ("freetype" ,freetype)
137 ;; ("libusb" ,libusb)
138 ;; ("fuse" ,fuse)
139 ("ncurses" ,ncurses)))
140 (native-inputs
141 `(("pkg-config" ,pkg-config)
142 ("unifont" ,unifont)
143 ("bison" ,bison)
144 ;; Due to a bug in flex >= 2.6.2, GRUB must be built with an older flex:
145 ;; <http://lists.gnu.org/archive/html/grub-devel/2017-02/msg00133.html>
146 ;; TODO Try building with flex > 2.6.4.
147 ("flex" ,flex-2.6.1)
148 ("texinfo" ,texinfo)
149 ("help2man" ,help2man)
150
151 ;; XXX: When building GRUB 2.02 on 32-bit x86, we need a binutils
152 ;; capable of assembling 64-bit instructions. However, our default
153 ;; binutils on 32-bit x86 is not 64-bit capable.
154 ,@(if (string-match "^i[3456]86-" (%current-system))
155 (let ((binutils (package/inherit
156 binutils
157 (name "binutils-i386")
158 (arguments
159 (substitute-keyword-arguments (package-arguments binutils)
160 ((#:configure-flags flags ''())
161 `(cons "--enable-64-bit-bfd" ,flags)))))))
162 `(("ld-wrapper" ,(make-ld-wrapper "ld-wrapper-i386"
163 #:binutils binutils))
164 ("binutils" ,binutils)))
165 '())
166
167 ;; Dependencies for the test suite. The "real" QEMU is needed here,
168 ;; because several targets are used.
169 ("parted" ,parted)
170 ("qemu" ,qemu-minimal-2.10)
171 ("xorriso" ,xorriso)))
172 (home-page "https://www.gnu.org/software/grub/")
173 (synopsis "GRand Unified Boot loader")
174 (description
175 "GRUB is a multiboot bootloader. It is used for initially loading the
176 kernel of an operating system and then transferring control to it. The kernel
177 then goes on to load the rest of the operating system. As a multiboot
178 bootloader, GRUB handles the presence of multiple operating systems installed
179 on the same computer; upon booting the computer, the user is presented with a
180 menu to select one of the installed operating systems.")
181 (license license:gpl3+)
182 (properties '((cpe-name . "grub2")))))
183
184 (define-public grub-efi
185 (package
186 (inherit grub)
187 (name "grub-efi")
188 (synopsis "GRand Unified Boot loader (UEFI version)")
189 (inputs
190 `(("efibootmgr" ,efibootmgr)
191 ("mtools" ,mtools)
192 ,@(package-inputs grub)))
193 (arguments
194 `(;; TODO: Tests need a UEFI firmware for qemu. There is one at
195 ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
196 ;; Search for 'OVMF' in "tests/util/grub-shell.in".
197 ,@(substitute-keyword-arguments (package-arguments grub)
198 ((#:tests? _ #f) #f)
199 ((#:configure-flags flags ''())
200 `(cons "--with-platform=efi" ,flags))
201 ((#:phases phases)
202 `(modify-phases ,phases
203 (add-after 'patch-stuff 'use-absolute-efibootmgr-path
204 (lambda* (#:key inputs #:allow-other-keys)
205 (substitute* "grub-core/osdep/unix/platform.c"
206 (("efibootmgr")
207 (string-append (assoc-ref inputs "efibootmgr")
208 "/sbin/efibootmgr")))
209 #t))
210 (add-after 'patch-stuff 'use-absolute-mtools-path
211 (lambda* (#:key inputs #:allow-other-keys)
212 (let ((mtools (assoc-ref inputs "mtools")))
213 (substitute* "util/grub-mkrescue.c"
214 (("\"mformat\"")
215 (string-append "\"" mtools
216 "/bin/mformat\"")))
217 (substitute* "util/grub-mkrescue.c"
218 (("\"mcopy\"")
219 (string-append "\"" mtools
220 "/bin/mcopy\"")))
221 #t))))))))))
222
223 ;; Because grub searches hardcoded paths it's easiest to just build grub
224 ;; again to make it find both grub-pc and grub-efi. There is a command
225 ;; line argument which allows you to specify ONE platform - but
226 ;; grub-mkrescue will use multiple platforms if they are available
227 ;; in the installation directory (without command line argument).
228 (define-public grub-hybrid
229 (package
230 (inherit grub-efi)
231 (name "grub-hybrid")
232 (synopsis "GRand Unified Boot loader (hybrid version)")
233 (inputs
234 `(("grub" ,grub)
235 ,@(package-inputs grub-efi)))
236 (arguments
237 (substitute-keyword-arguments (package-arguments grub-efi)
238 ((#:modules modules `((guix build utils) (guix build gnu-build-system)))
239 `((ice-9 ftw) ,@modules))
240 ((#:phases phases)
241 `(modify-phases ,phases
242 (add-after 'install 'install-non-efi
243 (lambda* (#:key inputs outputs #:allow-other-keys)
244 (let ((input-dir (string-append (assoc-ref inputs "grub")
245 "/lib/grub"))
246 (output-dir (string-append (assoc-ref outputs "out")
247 "/lib/grub")))
248 (for-each
249 (lambda (basename)
250 (if (not (or (string-prefix? "." basename)
251 (file-exists? (string-append output-dir "/" basename))))
252 (symlink (string-append input-dir "/" basename)
253 (string-append output-dir "/" basename))))
254 (scandir input-dir))
255 #t)))))))))
256
257 (define-public syslinux
258 (let ((commit "bb41e935cc83c6242de24d2271e067d76af3585c"))
259 (package
260 (name "syslinux")
261 (version (git-version "6.04-pre" "1" commit))
262 (source (origin
263 (method git-fetch)
264 (uri (git-reference
265 (url "https://github.com/geneC/syslinux")
266 (commit commit)))
267 (file-name (git-file-name name version))
268 (sha256
269 (base32
270 "0k8dvafd6410kqxf3kyr4y8jzmpmrih6wbjqg6gklak7945yflrc"))))
271 (build-system gnu-build-system)
272 (native-inputs
273 `(("nasm" ,nasm)
274 ("perl" ,perl)
275 ("python-2" ,python-2)))
276 (inputs
277 `(("libuuid" ,util-linux)
278 ("mtools" ,mtools)))
279 (arguments
280 `(#:parallel-build? #f
281 #:make-flags
282 (list (string-append "BINDIR=" %output "/bin")
283 (string-append "SBINDIR=" %output "/sbin")
284 (string-append "LIBDIR=" %output "/lib")
285 (string-append "INCDIR=" %output "/include")
286 (string-append "DATADIR=" %output "/share")
287 (string-append "MANDIR=" %output "/share/man")
288 "PERL=perl"
289 "bios")
290 #:phases
291 (modify-phases %standard-phases
292 (add-after 'unpack 'patch-files
293 (lambda* (#:key inputs #:allow-other-keys)
294 (substitute* (find-files "." "Makefile.*|ppmtolss16")
295 (("/bin/pwd") (which "pwd"))
296 (("/bin/echo") (which "echo"))
297 (("/usr/bin/perl") (which "perl")))
298 (let ((mtools (assoc-ref inputs "mtools")))
299 (substitute* (find-files "." "\\.c$")
300 (("mcopy")
301 (string-append mtools "/bin/mcopy"))
302 (("mattrib")
303 (string-append mtools "/bin/mattrib"))))
304 #t))
305 (delete 'configure)
306 (add-before 'build 'set-permissions
307 (lambda _
308 (invoke "chmod" "a+w" "utils/isohybrid.in")))
309 (replace 'check
310 (lambda _
311 (setenv "CC" "gcc")
312 (substitute* "tests/unittest/include/unittest/unittest.h"
313 ;; Don't look up headers under /usr.
314 (("/usr/include/") ""))
315 (invoke "make" "unittest"))))))
316 (home-page "https://www.syslinux.org")
317 (synopsis "Lightweight Linux bootloader")
318 (description "Syslinux is a lightweight Linux bootloader.")
319 (license (list license:gpl2+
320 license:bsd-3 ; gnu-efi/*
321 license:bsd-4 ; gnu-efi/inc/* gnu-efi/lib/*
322 ;; Also contains:
323 license:expat license:isc license:zlib)))))
324
325 (define-public dtc
326 (package
327 (name "dtc")
328 (version "1.4.7")
329 (source (origin
330 (method url-fetch)
331 (uri (string-append
332 "mirror://kernel.org/software/utils/dtc/"
333 "dtc-" version ".tar.xz"))
334 (sha256
335 (base32
336 "1rydi5jvhlhsr110h6n0pavv3daqa0cb4m5vcps50qzq1zqfhhv6"))))
337 (build-system gnu-build-system)
338 (native-inputs
339 `(("bison" ,bison)
340 ("flex" ,flex)
341 ("swig" ,swig)
342 ("valgrind" ,valgrind)))
343 (inputs
344 `(("python-2" ,python-2)))
345 (arguments
346 `(#:make-flags
347 (list "CC=gcc"
348 (string-append "PREFIX=" (assoc-ref %outputs "out"))
349 (string-append "SETUP_PREFIX=" (assoc-ref %outputs "out"))
350 "INSTALL=install")
351 #:phases
352 (modify-phases %standard-phases
353 (delete 'configure)))) ; no configure script
354 (home-page "https://www.devicetree.org")
355 (synopsis "Compiles device tree source files")
356 (description "@command{dtc} compiles
357 @uref{http://elinux.org/Device_Tree_Usage, device tree source files} to device
358 tree binary files. These are board description files used by Linux and BSD.")
359 (license license:gpl2+)))
360
361 (define u-boot
362 (package
363 (name "u-boot")
364 (version "2018.07")
365 (source (origin
366 (method url-fetch)
367 (uri (string-append
368 "ftp://ftp.denx.de/pub/u-boot/"
369 "u-boot-" version ".tar.bz2"))
370 (sha256
371 (base32
372 "1m7nw64mxflpc6sqvnz2kb5fxfkb4mrpy8b1wi15dcwipj4dy44z"))))
373 (native-inputs
374 `(("bc" ,bc)
375 ("bison" ,bison)
376 ("dtc" ,dtc)
377 ("flex" ,flex)
378 ("openssl" ,openssl)
379 ("python-2" ,python-2)
380 ("python2-coverage" ,python2-coverage)
381 ("python2-pytest" ,python2-pytest)
382 ("sdl" ,sdl)
383 ("swig" ,swig)))
384 (build-system gnu-build-system)
385 (home-page "https://www.denx.de/wiki/U-Boot/")
386 (synopsis "ARM bootloader")
387 (description "U-Boot is a bootloader used mostly for ARM boards. It
388 also initializes the boards (RAM etc).")
389 (license license:gpl2+)))
390
391 (define-public u-boot-tools
392 (package
393 (inherit u-boot)
394 (name "u-boot-tools")
395 (arguments
396 `(#:make-flags '("HOSTCC=gcc")
397 #:test-target "tests"
398 #:phases
399 (modify-phases %standard-phases
400 (add-after 'unpack 'patch
401 (lambda* (#:key inputs #:allow-other-keys)
402 (substitute* "Makefile"
403 (("/bin/pwd") (which "pwd"))
404 (("/bin/false") (which "false")))
405 (substitute* "tools/dtoc/fdt_util.py"
406 (("'cc'") "'gcc'"))
407 (substitute* "test/run"
408 ;; Make it easier to find test failures.
409 (("#!/bin/bash") "#!/bin/bash -x")
410 ;; pytest doesn't find it otherwise.
411 (("test/py/tests/test_ofplatdata.py")
412 "tests/test_ofplatdata.py")
413 ;; This test would require git.
414 (("\\./tools/patman/patman") (which "true"))
415 ;; This test would require internet access.
416 (("\\./tools/buildman/buildman") (which "true")))
417 (substitute* "test/py/tests/test_sandbox_exit.py"
418 (("def test_ctrl_c")
419 "@pytest.mark.skip(reason='Guix has problems with SIGINT')
420 def test_ctrl_c"))
421 (substitute* "tools/binman/binman.py"
422 (("100%") "99%")) ; TODO: Find out why that is needed.
423 #t))
424 (replace 'configure
425 (lambda* (#:key make-flags #:allow-other-keys)
426 (call-with-output-file "configs/tools_defconfig"
427 (lambda (port)
428 (display "CONFIG_SYS_TEXT_BASE=0\n" port)))
429 (apply invoke "make" "tools_defconfig" make-flags)))
430 (replace 'build
431 (lambda* (#:key inputs make-flags #:allow-other-keys)
432 (apply invoke "make" "tools-all" make-flags)))
433 (replace 'install
434 (lambda* (#:key outputs #:allow-other-keys)
435 (let* ((out (assoc-ref outputs "out"))
436 (bin (string-append out "/bin")))
437 (for-each (lambda (name)
438 (install-file name bin))
439 '("tools/netconsole"
440 "tools/jtagconsole"
441 "tools/gen_eth_addr"
442 "tools/gen_ethaddr_crc"
443 "tools/img2srec"
444 "tools/mkenvimage"
445 "tools/dumpimage"
446 "tools/mkimage"
447 "tools/proftool"
448 "tools/fdtgrep"
449 "tools/env/fw_printenv"
450 "tools/sunxi-spl-image-builder"))
451 #t)))
452 (delete 'check)
453 (add-after 'install 'check
454 (lambda* (#:key make-flags test-target #:allow-other-keys)
455 (apply invoke "make" "mrproper" make-flags)
456 (setenv "SDL_VIDEODRIVER" "dummy")
457 (setenv "PAGER" "cat")
458 (apply invoke "make" test-target make-flags)
459 (symlink "build-sandbox_spl" "sandbox")
460 (invoke "test/image/test-imagetools.sh"))))))
461 (description "U-Boot is a bootloader used mostly for ARM boards. It
462 also initializes the boards (RAM etc). This package provides its
463 board-independent tools.")))
464
465 (define-public (make-u-boot-package board triplet)
466 "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
467 (let ((same-arch? (if (string-prefix? (%current-system)
468 (gnu-triplet->nix-system triplet))
469 `#t
470 `#f)))
471 (package
472 (inherit u-boot)
473 (name (string-append "u-boot-"
474 (string-replace-substring (string-downcase board)
475 "_" "-")))
476 (native-inputs
477 `(,@(if (not same-arch?)
478 `(("cross-gcc" ,(cross-gcc triplet #:xgcc gcc-7))
479 ("cross-binutils" ,(cross-binutils triplet)))
480 `(("gcc-7" ,gcc-7)))
481 ,@(package-native-inputs u-boot)))
482 (arguments
483 `(#:modules ((ice-9 ftw)
484 (srfi srfi-1)
485 (guix build utils)
486 (guix build gnu-build-system))
487 #:test-target "test"
488 #:make-flags
489 (list "HOSTCC=gcc"
490 ,@(if (not same-arch?)
491 `((string-append "CROSS_COMPILE=" ,triplet "-"))
492 '()))
493 #:phases
494 (modify-phases %standard-phases
495 (replace 'configure
496 (lambda* (#:key outputs make-flags #:allow-other-keys)
497 (let ((config-name (string-append ,board "_defconfig")))
498 (if (file-exists? (string-append "configs/" config-name))
499 (zero? (apply system* "make" `(,@make-flags ,config-name)))
500 (begin
501 (display "Invalid board name. Valid board names are:"
502 (current-error-port))
503 (let ((suffix-len (string-length "_defconfig"))
504 (entries (scandir "configs")))
505 (for-each (lambda (file-name)
506 (when (string-suffix? "_defconfig" file-name)
507 (format (current-error-port)
508 "- ~A\n"
509 (string-drop-right file-name
510 suffix-len))))
511 (sort entries string-ci<)))
512 (error "Invalid boardname ~s." ,board))))))
513 (replace 'install
514 (lambda* (#:key outputs #:allow-other-keys)
515 (let* ((out (assoc-ref outputs "out"))
516 (libexec (string-append out "/libexec"))
517 (uboot-files (append
518 (remove
519 ;; Those would not be reproducible
520 ;; because of the randomness used
521 ;; to produce them.
522 ;; It's expected that the user will
523 ;; use u-boot-tools to generate them
524 ;; instead.
525 (lambda (name)
526 (string-suffix?
527 "sunxi-spl-with-ecc.bin"
528 name))
529 (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
530 (find-files "." "^(MLO|SPL)$"))))
531 (mkdir-p libexec)
532 (install-file ".config" libexec)
533 ;; Useful for "qemu -kernel".
534 (install-file "u-boot" libexec)
535 (for-each
536 (lambda (file)
537 (let ((target-file (string-append libexec "/" file)))
538 (mkdir-p (dirname target-file))
539 (copy-file file target-file)))
540 uboot-files)
541 #t)))))))))
542
543 (define-public u-boot-vexpress
544 (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
545
546 (define-public u-boot-malta
547 (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
548
549 (define-public u-boot-beagle-bone-black
550 (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))
551
552 (define-public u-boot-pine64-plus
553 (let ((base (make-u-boot-package "pine64_plus" "aarch64-linux-gnu")))
554 (package
555 (inherit base)
556 (arguments
557 (substitute-keyword-arguments (package-arguments base)
558 ((#:phases phases)
559 `(modify-phases ,phases
560 (add-after 'unpack 'set-environment
561 (lambda* (#:key inputs #:allow-other-keys)
562 (let ((bl31 (string-append (assoc-ref inputs "firmware")
563 "/bl31.bin")))
564 (setenv "BL31" bl31)
565 ;; This is necessary when we're using the bundled dtc.
566 ;(setenv "PATH" (string-append (getenv "PATH") ":"
567 ; "scripts/dtc"))
568 )
569 #t))))))
570 (native-inputs
571 `(("firmware" ,arm-trusted-firmware-pine64-plus)
572 ,@(package-native-inputs base))))))
573
574 (define-public u-boot-bananapi-m2-ultra
575 (make-u-boot-package "Bananapi_M2_Ultra" "arm-linux-gnueabihf"))
576
577 (define-public u-boot-a20-olinuxino-lime
578 (make-u-boot-package "A20-OLinuXino-Lime" "arm-linux-gnueabihf"))
579
580 (define-public u-boot-a20-olinuxino-lime2
581 (make-u-boot-package "A20-OLinuXino-Lime2" "arm-linux-gnueabihf"))
582
583 (define-public u-boot-a20-olinuxino-micro
584 (make-u-boot-package "A20-OLinuXino_MICRO" "arm-linux-gnueabihf"))
585
586 (define-public u-boot-nintendo-nes-classic-edition
587 (make-u-boot-package "Nintendo_NES_Classic_Edition" "arm-linux-gnueabihf"))
588
589 (define-public u-boot-wandboard
590 (make-u-boot-package "wandboard" "arm-linux-gnueabihf"))
591
592 (define-public u-boot-mx6cuboxi
593 (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf"))
594
595 (define-public u-boot-novena
596 (make-u-boot-package "novena" "arm-linux-gnueabihf"))
597
598 (define-public u-boot-cubieboard
599 (make-u-boot-package "Cubieboard" "arm-linux-gnueabihf"))
600
601 (define-public u-boot-cubietruck
602 (make-u-boot-package "Cubietruck" "arm-linux-gnueabihf"))
603
604 (define-public u-boot-puma-rk3399
605 (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu")))
606 (package
607 (inherit base)
608 (arguments
609 (substitute-keyword-arguments (package-arguments base)
610 ((#:phases phases)
611 `(modify-phases ,phases
612 (add-after 'unpack 'set-environment
613 (lambda* (#:key inputs #:allow-other-keys)
614 ;; Need to copy the firmware into u-boot build
615 ;; directory.
616 (copy-file (string-append (assoc-ref inputs "firmware")
617 "/bl31.bin") "bl31-rk3399.bin")
618 (copy-file (string-append (assoc-ref inputs "firmware-m0")
619 "/rk3399m0.bin") "rk3399m0.bin")
620 #t))
621 (add-after 'build 'build-itb
622 (lambda* (#:key make-flags #:allow-other-keys)
623 ;; The u-boot.itb is not built by default.
624 (apply invoke "make" `(,@make-flags ,"u-boot.itb"))))
625 (add-after 'build-itb 'build-rksd
626 (lambda* (#:key inputs #:allow-other-keys)
627 ;; Build Rockchip SD card images.
628 (invoke "./tools/mkimage" "-T" "rksd" "-n" "rk3399" "-d"
629 "spl/u-boot-spl.bin" "u-boot-spl.rksd")))))))
630 (native-inputs
631 `(("firmware" ,arm-trusted-firmware-puma-rk3399)
632 ("firmware-m0" ,rk3399-cortex-m0)
633 ,@(package-native-inputs base))))))
634
635 (define-public vboot-utils
636 (package
637 (name "vboot-utils")
638 (version "R63-10032.B")
639 (source (origin
640 ;; XXX: Snapshots are available but changes timestamps every download.
641 (method git-fetch)
642 (uri (git-reference
643 (url (string-append "https://chromium.googlesource.com"
644 "/chromiumos/platform/vboot_reference"))
645 (commit (string-append "release-" version))))
646 (file-name (string-append name "-" version "-checkout"))
647 (sha256
648 (base32
649 "0h0m3l69vp9dr6xrs1p6y7ilkq3jq8jraw2z20kqfv7lvc9l1lxj"))))
650 (build-system gnu-build-system)
651 (arguments
652 `(#:make-flags (list "CC=gcc"
653 (string-append "DESTDIR=" (assoc-ref %outputs "out")))
654 #:phases (modify-phases %standard-phases
655 (add-after 'unpack 'patch-hard-coded-paths
656 (lambda* (#:key inputs outputs #:allow-other-keys)
657 (let ((coreutils (assoc-ref inputs "coreutils"))
658 (diffutils (assoc-ref inputs "diffutils")))
659 (substitute* "futility/misc.c"
660 (("/bin/cp") (string-append coreutils "/bin/cp")))
661 (substitute* "tests/bitmaps/TestBmpBlock.py"
662 (("/usr/bin/cmp") (string-append diffutils "/bin/cmp")))
663 (substitute* "vboot_host.pc.in"
664 (("prefix=/usr")
665 (string-append "prefix=" (assoc-ref outputs "out"))))
666 #t)))
667 (delete 'configure)
668 (add-before 'check 'patch-tests
669 (lambda _
670 ;; These tests compare diffs against known-good values.
671 ;; Patch the paths to match those in the build container.
672 (substitute* (find-files "tests/futility/expect_output")
673 (("/mnt/host/source/src/platform/vboot_reference")
674 (string-append "/tmp/guix-build-" ,name "-" ,version
675 ".drv-0/source")))
676 ;; Tests require write permissions to many of these files.
677 (for-each make-file-writable (find-files "tests/futility"))
678 #t)))
679 #:test-target "runtests"))
680 (native-inputs
681 `(("pkg-config" ,pkg-config)
682
683 ;; For tests.
684 ("diffutils" ,diffutils)
685 ("python@2" ,python-2)))
686 (inputs
687 `(("coreutils" ,coreutils)
688 ("libyaml" ,libyaml)
689 ("openssl" ,openssl)
690 ("openssl:static" ,openssl "static")
691 ("util-linux" ,util-linux)))
692 (home-page
693 "https://dev.chromium.org/chromium-os/chromiumos-design-docs/verified-boot")
694 (synopsis "ChromiumOS verified boot utilities")
695 (description
696 "vboot-utils is a collection of tools to facilitate booting of
697 Chrome-branded devices. This includes the @command{cgpt} partitioning
698 program, the @command{futility} and @command{crossystem} firmware management
699 tools, and more.")
700 (license license:bsd-3)))
701
702 (define-public os-prober
703 (package
704 (name "os-prober")
705 (version "1.76")
706 (source
707 (origin
708 (method url-fetch)
709 (uri (string-append "mirror://debian/pool/main/o/os-prober/os-prober_"
710 version ".tar.xz"))
711 (sha256
712 (base32
713 "1vb45i76bqivlghrq7m3n07qfmmq4wxrkplqx8gywj011rhq19fk"))))
714 (build-system gnu-build-system)
715 (arguments
716 `(#:modules ((guix build gnu-build-system)
717 (guix build utils)
718 (ice-9 regex) ; for string-match
719 (srfi srfi-26)) ; for cut
720 #:make-flags (list "CC=gcc")
721 #:tests? #f ; no tests
722 #:phases
723 (modify-phases %standard-phases
724 (replace 'configure
725 (lambda* (#:key outputs #:allow-other-keys)
726 (substitute* (find-files ".")
727 (("/usr") (assoc-ref outputs "out")))
728 (substitute* (find-files "." "50mounted-tests$")
729 (("mkdir") "mkdir -p"))
730 #t))
731 (replace 'install
732 (lambda* (#:key outputs #:allow-other-keys)
733 (define (find-files-non-recursive directory)
734 (find-files directory
735 (lambda (file stat)
736 (string-match (string-append "^" directory "/[^/]*$")
737 file))
738 #:directories? #t))
739
740 (let* ((out (assoc-ref outputs "out"))
741 (bin (string-append out "/bin"))
742 (lib (string-append out "/lib"))
743 (share (string-append out "/share")))
744 (for-each (cut install-file <> bin)
745 (list "linux-boot-prober" "os-prober"))
746 (install-file "newns" (string-append lib "/os-prober"))
747 (install-file "common.sh" (string-append share "/os-prober"))
748 (install-file "os-probes/mounted/powerpc/20macosx"
749 (string-append lib "/os-probes/mounted"))
750 (for-each
751 (lambda (directory)
752 (for-each
753 (lambda (file)
754 (let ((destination (string-append lib "/" directory
755 "/" (basename file))))
756 (mkdir-p (dirname destination))
757 (copy-recursively file destination)))
758 (append (find-files-non-recursive (string-append directory "/common"))
759 (find-files-non-recursive (string-append directory "/x86")))))
760 (list "os-probes" "os-probes/mounted" "os-probes/init"
761 "linux-boot-probes" "linux-boot-probes/mounted"))
762 #t))))))
763 (home-page "https://joeyh.name/code/os-prober")
764 (synopsis "Detect other operating systems")
765 (description "os-prober probes disks on the system for other operating
766 systems so that they can be added to the bootloader. It also works out how to
767 boot existing GNU/Linux systems and detects what distribution is installed in
768 order to add a suitable bootloader menu entry.")
769 (license license:gpl2+)))