gnu: mrustc: Update to 0.0.0-2.ee65f12.
[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
ac30d18c
DM
395 (display "Invalid board name. Valid board names are:"
396 (current-error-port))
30ef146c
DM
397 (let ((suffix-len (string-length "_defconfig"))
398 (entries (scandir "configs")))
399 (for-each (lambda (file-name)
400 (when (string-suffix? "_defconfig" file-name)
ac30d18c 401 (format (current-error-port)
30ef146c
DM
402 "- ~A\n"
403 (string-drop-right file-name
404 suffix-len))))
405 (sort entries string<)))
3bfee8ff
EF
406 #f)))))
407 (replace 'install
9b94ced4 408 (lambda* (#:key outputs #:allow-other-keys)
3bfee8ff
EF
409 (let* ((out (assoc-ref outputs "out"))
410 (libexec (string-append out "/libexec"))
dd208b93 411 (uboot-files (append
9a1c4a6c 412 (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb)$")
fd0b21d5 413 (find-files "." "^(MLO|SPL)$"))))
3bfee8ff 414 (mkdir-p libexec)
a32f9b59 415 (install-file ".config" libexec)
0fcfed39
DM
416 ;; Useful for "qemu -kernel".
417 (install-file "u-boot" libexec)
3bfee8ff
EF
418 (for-each
419 (lambda (file)
420 (let ((target-file (string-append libexec "/" file)))
421 (mkdir-p (dirname target-file))
422 (copy-file file target-file)))
423 uboot-files))))))))))
862e38d5
DC
424
425(define-public u-boot-vexpress
426 (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
427
428(define-public u-boot-malta
429 (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
430
431(define-public u-boot-beagle-bone-black
432 (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))
4adeb3f6 433
29be6cfb
EF
434(define-public u-boot-pine64-plus
435 (let ((base (make-u-boot-package "pine64_plus" "aarch64-linux-gnu")))
436 (package
437 (inherit base)
438 (arguments
439 (substitute-keyword-arguments (package-arguments base)
440 ((#:phases phases)
441 `(modify-phases ,phases
442 (add-after 'unpack 'set-environment
443 (lambda* (#:key inputs #:allow-other-keys)
444 (let ((bl31 (string-append (assoc-ref inputs "firmware")
445 "/bl31.bin")))
446 (setenv "BL31" bl31)
35e427d1
DM
447 ;; This is necessary when we're using the bundled dtc.
448 ;(setenv "PATH" (string-append (getenv "PATH") ":"
449 ; "scripts/dtc"))
450 )
29be6cfb
EF
451 #t))))))
452 (native-inputs
453 `(("firmware" ,arm-trusted-firmware-pine64-plus)
454 ,@(package-native-inputs base))))))
455
30aeb846
DM
456(define-public u-boot-banana-pi-m2-ultra
457 (make-u-boot-package "Bananapi_M2_Ultra" "arm-linux-gnueabihf"))
458
c55c6985
DM
459(define-public u-boot-a20-olinuxino-lime
460 (make-u-boot-package "A20-OLinuXino-Lime" "arm-linux-gnueabihf"))
461
4b9e9abb
DM
462(define-public u-boot-a20-olinuxino-lime2
463 (make-u-boot-package "A20-OLinuXino-Lime2" "arm-linux-gnueabihf"))
464
a7bb327e
DM
465(define-public u-boot-a20-olinuxino-micro
466 (make-u-boot-package "A20-OLinuXino_MICRO" "arm-linux-gnueabihf"))
467
84ee3378
DM
468(define-public u-boot-nintendo-nes-classic-edition
469 (make-u-boot-package "Nintendo_NES_Classic_Edition" "arm-linux-gnueabihf"))
470
95a3422e
VC
471(define-public u-boot-wandboard
472 (make-u-boot-package "wandboard" "arm-linux-gnueabihf"))
473
adc61d72
VC
474(define-public u-boot-mx6cuboxi
475 (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf"))
476
1b960787
VC
477(define-public u-boot-novena
478 (make-u-boot-package "novena" "arm-linux-gnueabihf"))
479
dd4fe0c2
DM
480(define-public u-boot-cubieboard
481 (make-u-boot-package "Cubieboard" "arm-linux-gnueabihf"))
482
a60f1319
MB
483(define-public vboot-utils
484 (package
485 (name "vboot-utils")
486 (version "R63-10032.B")
487 (source (origin
488 ;; XXX: Snapshots are available but changes timestamps every download.
489 (method git-fetch)
490 (uri (git-reference
491 (url (string-append "https://chromium.googlesource.com"
492 "/chromiumos/platform/vboot_reference"))
493 (commit (string-append "release-" version))))
494 (file-name (string-append name "-" version "-checkout"))
495 (sha256
496 (base32
497 "0h0m3l69vp9dr6xrs1p6y7ilkq3jq8jraw2z20kqfv7lvc9l1lxj"))))
498 (build-system gnu-build-system)
499 (arguments
500 `(#:make-flags (list "CC=gcc"
501 (string-append "DESTDIR=" (assoc-ref %outputs "out")))
502 #:phases (modify-phases %standard-phases
503 (add-after 'unpack 'patch-hard-coded-paths
504 (lambda* (#:key inputs outputs #:allow-other-keys)
505 (let ((coreutils (assoc-ref inputs "coreutils"))
506 (diffutils (assoc-ref inputs "diffutils")))
507 (substitute* "futility/misc.c"
508 (("/bin/cp") (string-append coreutils "/bin/cp")))
509 (substitute* "tests/bitmaps/TestBmpBlock.py"
510 (("/usr/bin/cmp") (string-append diffutils "/bin/cmp")))
511 (substitute* "vboot_host.pc.in"
512 (("prefix=/usr")
513 (string-append "prefix=" (assoc-ref outputs "out"))))
514 #t)))
515 (delete 'configure)
516 (add-before 'check 'patch-tests
517 (lambda _
518 ;; These tests compare diffs against known-good values.
519 ;; Patch the paths to match those in the build container.
520 (substitute* (find-files "tests/futility/expect_output")
521 (("/mnt/host/source/src/platform/vboot_reference")
522 (string-append "/tmp/guix-build-" ,name "-" ,version
523 ".drv-0/source")))
524 ;; Tests require write permissions to many of these files.
525 (for-each make-file-writable (find-files "tests/futility"))
526 #t)))
527 #:test-target "runtests"))
528 (native-inputs
529 `(("pkg-config" ,pkg-config)
530
531 ;; For tests.
532 ("diffutils" ,diffutils)
533 ("python@2" ,python-2)))
534 (inputs
535 `(("coreutils" ,coreutils)
536 ("libyaml" ,libyaml)
537 ("openssl" ,openssl)
538 ("openssl:static" ,openssl "static")
539 ("util-linux" ,util-linux)))
540 (home-page
541 "https://dev.chromium.org/chromium-os/chromiumos-design-docs/verified-boot")
542 (synopsis "ChromiumOS verified boot utilities")
543 (description
544 "vboot-utils is a collection of tools to facilitate booting of
545Chrome-branded devices. This includes the @command{cgpt} partitioning
546program, the @command{futility} and @command{crossystem} firmware management
547tools, and more.")
548 (license license:bsd-3)))
549
aa90375a
AI
550(define-public os-prober
551 (package
552 (name "os-prober")
553 (version "1.76")
554 (source
555 (origin
556 (method url-fetch)
557 (uri (string-append "mirror://debian/pool/main/o/os-prober/os-prober_"
558 version ".tar.xz"))
559 (sha256
560 (base32
561 "1vb45i76bqivlghrq7m3n07qfmmq4wxrkplqx8gywj011rhq19fk"))))
562 (build-system gnu-build-system)
563 (arguments
564 `(#:modules ((guix build gnu-build-system)
565 (guix build utils)
566 (ice-9 regex) ; for string-match
567 (srfi srfi-26)) ; for cut
568 #:make-flags (list "CC=gcc")
569 #:tests? #f ; no tests
570 #:phases
571 (modify-phases %standard-phases
572 (replace 'configure
573 (lambda* (#:key outputs #:allow-other-keys)
574 (substitute* (find-files ".")
575 (("/usr") (assoc-ref outputs "out")))
576 (substitute* (find-files "." "50mounted-tests$")
577 (("mkdir") "mkdir -p"))
578 #t))
579 (replace 'install
580 (lambda* (#:key outputs #:allow-other-keys)
581 (define (find-files-non-recursive directory)
582 (find-files directory
583 (lambda (file stat)
584 (string-match (string-append "^" directory "/[^/]*$")
585 file))
586 #:directories? #t))
587
588 (let* ((out (assoc-ref outputs "out"))
589 (bin (string-append out "/bin"))
590 (lib (string-append out "/lib"))
591 (share (string-append out "/share")))
592 (for-each (cut install-file <> bin)
593 (list "linux-boot-prober" "os-prober"))
594 (install-file "newns" (string-append lib "/os-prober"))
595 (install-file "common.sh" (string-append share "/os-prober"))
596 (install-file "os-probes/mounted/powerpc/20macosx"
597 (string-append lib "/os-probes/mounted"))
598 (for-each
599 (lambda (directory)
600 (for-each
601 (lambda (file)
602 (let ((destination (string-append lib "/" directory
603 "/" (basename file))))
604 (mkdir-p (dirname destination))
605 (copy-recursively file destination)))
606 (append (find-files-non-recursive (string-append directory "/common"))
607 (find-files-non-recursive (string-append directory "/x86")))))
608 (list "os-probes" "os-probes/mounted" "os-probes/init"
609 "linux-boot-probes" "linux-boot-probes/mounted"))
610 #t))))))
611 (home-page "https://joeyh.name/code/os-prober")
612 (synopsis "Detect other operating systems")
613 (description "os-prober probes disks on the system for other operating
614systems so that they can be added to the bootloader. It also works out how to
615boot existing GNU/Linux systems and detects what distribution is installed in
616order to add a suitable bootloader menu entry.")
617 (license license:gpl2+)))