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