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