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