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