installer: parted: Add debug output.
[jackhill/guix/guix.git] / gnu / packages / bootloaders.scm
CommitLineData
65d8b777 1;;; GNU Guix --- Functional package management for GNU
ab100b90 2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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>
d613991a 5;;; Copyright © 2016, 2020 Jan (janneke) 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>
33430a45 10;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
ab100b90 11;;; Copyright © 2019 nee <nee@cock.li>
af58b275 12;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
5664a471 13;;; Copyright © 2020 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
5327b399 14;;; Copyright © 2018, 2019, 2020 Vagrant Cascadian <vagrant@debian.org>
c10e8cf7 15;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
65d8b777
LC
16;;;
17;;; This file is part of GNU Guix.
18;;;
19;;; GNU Guix is free software; you can redistribute it and/or modify it
20;;; under the terms of the GNU General Public License as published by
21;;; the Free Software Foundation; either version 3 of the License, or (at
22;;; your option) any later version.
23;;;
24;;; GNU Guix is distributed in the hope that it will be useful, but
25;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27;;; GNU General Public License for more details.
28;;;
29;;; You should have received a copy of the GNU General Public License
30;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
31
862e38d5 32(define-module (gnu packages bootloaders)
65d8b777 33 #:use-module (gnu packages)
862e38d5 34 #:use-module (gnu packages admin)
178e5500 35 #:use-module (gnu packages algebra)
862e38d5 36 #:use-module (gnu packages assembly)
a60f1319 37 #:use-module (gnu packages base)
7febe3a2 38 #:use-module (gnu packages disk)
65d8b777 39 #:use-module (gnu packages bison)
862e38d5 40 #:use-module (gnu packages cdrom)
65212c42 41 #:use-module (gnu packages check)
0c7707d5 42 #:use-module (gnu packages compression)
862e38d5
DC
43 #:use-module (gnu packages cross-base)
44 #:use-module (gnu packages disk)
29be6cfb 45 #:use-module (gnu packages firmware)
862e38d5 46 #:use-module (gnu packages flex)
a86177d6 47 #:use-module (gnu packages fontutils)
f074f5e8 48 #:use-module (gnu packages gcc)
862e38d5 49 #:use-module (gnu packages gettext)
65d8b777 50 #:use-module (gnu packages linux)
862e38d5 51 #:use-module (gnu packages man)
444f9dcc 52 #:use-module (gnu packages mtools)
862e38d5 53 #:use-module (gnu packages ncurses)
96b714f5 54 #:use-module (gnu packages perl)
a60f1319 55 #:use-module (gnu packages pkg-config)
96b714f5 56 #:use-module (gnu packages python)
58301666 57 #:use-module (gnu packages texinfo)
a60f1319 58 #:use-module (gnu packages tls)
65212c42 59 #:use-module (gnu packages sdl)
12c613b5 60 #:use-module (gnu packages swig)
5d706f18 61 #:use-module (gnu packages valgrind)
59132b80 62 #:use-module (gnu packages virtualization)
ab100b90 63 #:use-module (gnu packages xorg)
a60f1319 64 #:use-module (gnu packages web)
862e38d5
DC
65 #:use-module (guix build-system gnu)
66 #:use-module (guix download)
67 #:use-module (guix git-download)
68 #:use-module ((guix licenses) #:prefix license:)
69 #:use-module (guix packages)
63087721
EF
70 #:use-module (guix utils)
71 #:use-module (srfi srfi-1)
a7c87169
MW
72 #:use-module (srfi srfi-26)
73 #:use-module (ice-9 regex))
65d8b777 74
9b24c768
LC
75(define unifont
76 ;; GNU Unifont, <http://gnu.org/s/unifont>.
77 ;; GRUB needs it for its graphical terminal, gfxterm.
78 (origin
79 (method url-fetch)
80 (uri
81 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
82 (sha256
83 (base32
84 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
85
65d8b777
LC
86(define-public grub
87 (package
88 (name "grub")
069ab3bb 89 (version "2.04")
65d8b777
LC
90 (source (origin
91 (method url-fetch)
3586a3e9 92 (uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz"))
65d8b777
LC
93 (sha256
94 (base32
069ab3bb 95 "0zgp5m3hmc9jh8wpjx6czzkh5id2y8n1k823x2mjvm2sk6b28ag5"))
654de94e
JN
96 (patches (search-patches
97 "grub-efi-fat-serial-number.patch"
15135a5e 98 "grub-setup-root.patch"
d613991a
JN
99 "grub-verifiers-Blocklist-fallout-cleanup.patch"
100 "grub-cross-system-i686.patch"))))
65d8b777
LC
101 (build-system gnu-build-system)
102 (arguments
069ab3bb
TGR
103 `(#:configure-flags
104 ;; Counterintuitively, this *disables* a spurious Python dependency by
105 ;; calling the ‘true’ binary instead. Python is only needed during
106 ;; bootstrapping (for genptl.py), not when building from a release.
107 (list "PYTHON=true")
108 #:phases (modify-phases %standard-phases
358db004 109 (add-after 'unpack 'patch-stuff
7c353424 110 (lambda* (#:key native-inputs inputs #:allow-other-keys)
04e0eac1
MW
111 (substitute* "grub-core/Makefile.in"
112 (("/bin/sh") (which "sh")))
65d8b777 113
358db004
LC
114 ;; Give the absolute file name of 'mdadm', used to
115 ;; determine the root file system when it's a RAID
116 ;; device. Failing to do that, 'grub-probe' silently
117 ;; fails if 'mdadm' is not in $PATH.
118 (substitute* "grub-core/osdep/linux/getroot.c"
119 (("argv\\[0\\] = \"mdadm\"")
120 (string-append "argv[0] = \""
121 (assoc-ref inputs "mdadm")
122 "/sbin/mdadm\"")))
123
04e0eac1 124 ;; Make the font visible.
7c353424
MO
125 (copy-file (assoc-ref (or native-inputs inputs)
126 "unifont")
127 "unifont.bdf.gz")
04e0eac1 128 (system* "gunzip" "unifont.bdf.gz")
ab100b90 129
130 ;; Give the absolute file name of 'ckbcomp'.
131 (substitute* "util/grub-kbdcomp.in"
132 (("^ckbcomp ")
133 (string-append (assoc-ref inputs "console-setup")
134 "/bin/ckbcomp ")))
23a53a95
LF
135 #t))
136 (add-before 'check 'disable-flaky-test
137 (lambda _
138 ;; This test is unreliable. For more information, see:
139 ;; <https://bugs.gnu.org/26936>.
140 (substitute* "Makefile.in"
141 (("grub_cmd_date grub_cmd_set_date grub_cmd_sleep")
142 "grub_cmd_date grub_cmd_sleep"))
069ab3bb
TGR
143 #t))
144 (add-before 'check 'disable-pixel-perfect-test
145 (lambda _
146 ;; This test compares many screenshots rendered with an
147 ;; older Unifont (9.0.06) than that packaged in Guix.
148 (substitute* "Makefile.in"
149 (("test_unset grub_func_test")
150 "test_unset"))
56f0feb6 151 #t)))
63087721
EF
152 ;; Disable tests on ARM and AARCH64 platforms.
153 #:tests? ,(not (any (cute string-prefix? <> (or (%current-target-system)
154 (%current-system)))
155 '("arm" "aarch64")))))
65d8b777 156 (inputs
10da75df
LC
157 `(("gettext" ,gettext-minimal)
158
159 ;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and
160 ;; 'grub-install' to recognize mapped devices (LUKS, etc.)
654de94e
JN
161 ,@(if (member (or (%current-target-system)
162 (%current-system))
163 (package-supported-systems lvm2))
164 `(("lvm2" ,lvm2))
165 '())
10da75df
LC
166
167 ;; Depend on mdadm, which is invoked by 'grub-probe' and 'grub-install'
168 ;; to determine whether the root file system is RAID.
654de94e
JN
169 ,@(if (member (or (%current-target-system)
170 (%current-system))
171 (package-supported-systems mdadm))
172 `(("mdadm" ,mdadm))
173 '())
10da75df 174
ab100b90 175 ;; Console-setup's ckbcomp is invoked by grub-kbdcomp. It is required
176 ;; for generating alternative keyboard layouts.
177 ("console-setup" ,console-setup)
178
35014c40
TGR
179 ;; Needed for ‘grub-mount’, the only reliable way to tell whether a given
180 ;; file system will be readable by GRUB without rebooting.
654de94e
JN
181 ,@(if (member (or (%current-target-system)
182 (%current-system))
183 (package-supported-systems fuse))
184 `(("fuse" ,fuse))
185 '())
35014c40 186
65d8b777
LC
187 ("freetype" ,freetype)
188 ;; ("libusb" ,libusb)
01eafd38 189 ("ncurses" ,ncurses)))
65d8b777 190 (native-inputs
0a2a7053
MW
191 `(("pkg-config" ,pkg-config)
192 ("unifont" ,unifont)
9b24c768 193 ("bison" ,bison)
f142c077 194 ("flex" ,flex)
58301666
MW
195 ("texinfo" ,texinfo)
196 ("help2man" ,help2man)
65d8b777 197
a7c87169
MW
198 ;; XXX: When building GRUB 2.02 on 32-bit x86, we need a binutils
199 ;; capable of assembling 64-bit instructions. However, our default
200 ;; binutils on 32-bit x86 is not 64-bit capable.
201 ,@(if (string-match "^i[3456]86-" (%current-system))
202 (let ((binutils (package/inherit
203 binutils
204 (name "binutils-i386")
205 (arguments
206 (substitute-keyword-arguments (package-arguments binutils)
207 ((#:configure-flags flags ''())
208 `(cons "--enable-64-bit-bfd" ,flags)))))))
209 `(("ld-wrapper" ,(make-ld-wrapper "ld-wrapper-i386"
210 #:binutils binutils))
211 ("binutils" ,binutils)))
212 '())
213
65d8b777
LC
214 ;; Dependencies for the test suite. The "real" QEMU is needed here,
215 ;; because several targets are used.
7febe3a2 216 ("parted" ,parted)
654de94e
JN
217 ,@(if (member (%current-system) (package-supported-systems qemu-minimal))
218 `(("qemu" ,qemu-minimal))
219 '())
65d8b777 220 ("xorriso" ,xorriso)))
175b259c 221 (home-page "https://www.gnu.org/software/grub/")
79c311b8 222 (synopsis "GRand Unified Boot loader")
65d8b777 223 (description
a22dc0c4 224 "GRUB is a multiboot bootloader. It is used for initially loading the
35b9e423 225kernel of an operating system and then transferring control to it. The kernel
c5779c93 226then goes on to load the rest of the operating system. As a multiboot
574e86f9
LC
227bootloader, GRUB handles the presence of multiple operating systems installed
228on the same computer; upon booting the computer, the user is presented with a
a22dc0c4 229menu to select one of the installed operating systems.")
3f73aa1a 230 (license license:gpl3+)
99effc8f 231 (properties '((cpe-name . "grub2")))))
acb5f7c3 232
0c962369
JN
233(define-public grub-minimal
234 (package
235 (inherit grub)
236 (name "grub-minimal")
237 (inputs
238 (fold alist-delete (package-inputs grub)
239 '("lvm2" "mdadm" "fuse" "console-setup")))
240 (native-inputs
241 (fold alist-delete (package-native-inputs grub)
242 '("help2man" "texinfo" "parted" "qemu" "xorriso")))
243 (arguments
244 `(#:configure-flags (list "PYTHON=true")
245 #:phases (modify-phases %standard-phases
246 (add-after 'unpack 'patch-stuff
247 (lambda* (#:key native-inputs inputs #:allow-other-keys)
248 (substitute* "grub-core/Makefile.in"
249 (("/bin/sh") (which "sh")))
250
251 ;; Make the font visible.
252 (copy-file (assoc-ref (or native-inputs inputs)
253 "unifont")
254 "unifont.bdf.gz")
255 (system* "gunzip" "unifont.bdf.gz")
256
257 #t)))
258 #:tests? #f))))
259
acb5f7c3
MB
260(define-public grub-efi
261 (package
262 (inherit grub)
263 (name "grub-efi")
264 (synopsis "GRand Unified Boot loader (UEFI version)")
265 (inputs
266 `(("efibootmgr" ,efibootmgr)
c695fb76 267 ("mtools" ,mtools)
acb5f7c3
MB
268 ,@(package-inputs grub)))
269 (arguments
270 `(;; TODO: Tests need a UEFI firmware for qemu. There is one at
271 ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
272 ;; Search for 'OVMF' in "tests/util/grub-shell.in".
acb5f7c3 273 ,@(substitute-keyword-arguments (package-arguments grub)
46ff2dbb 274 ((#:tests? _ #f) #f)
ef753a1a
LC
275 ((#:configure-flags flags ''())
276 `(cons "--with-platform=efi" ,flags))
acb5f7c3
MB
277 ((#:phases phases)
278 `(modify-phases ,phases
279 (add-after 'patch-stuff 'use-absolute-efibootmgr-path
280 (lambda* (#:key inputs #:allow-other-keys)
281 (substitute* "grub-core/osdep/unix/platform.c"
282 (("efibootmgr")
283 (string-append (assoc-ref inputs "efibootmgr")
284 "/sbin/efibootmgr")))
444f9dcc
DM
285 #t))
286 (add-after 'patch-stuff 'use-absolute-mtools-path
287 (lambda* (#:key inputs #:allow-other-keys)
288 (let ((mtools (assoc-ref inputs "mtools")))
289 (substitute* "util/grub-mkrescue.c"
290 (("\"mformat\"")
291 (string-append "\"" mtools
292 "/bin/mformat\"")))
293 (substitute* "util/grub-mkrescue.c"
294 (("\"mcopy\"")
295 (string-append "\"" mtools
296 "/bin/mcopy\"")))
297 #t))))))))))
96b714f5 298
dd4b7476
DM
299;; Because grub searches hardcoded paths it's easiest to just build grub
300;; again to make it find both grub-pc and grub-efi. There is a command
301;; line argument which allows you to specify ONE platform - but
302;; grub-mkrescue will use multiple platforms if they are available
303;; in the installation directory (without command line argument).
304(define-public grub-hybrid
305 (package
306 (inherit grub-efi)
307 (name "grub-hybrid")
308 (synopsis "GRand Unified Boot loader (hybrid version)")
309 (inputs
310 `(("grub" ,grub)
311 ,@(package-inputs grub-efi)))
312 (arguments
313 (substitute-keyword-arguments (package-arguments grub-efi)
314 ((#:modules modules `((guix build utils) (guix build gnu-build-system)))
315 `((ice-9 ftw) ,@modules))
316 ((#:phases phases)
317 `(modify-phases ,phases
318 (add-after 'install 'install-non-efi
319 (lambda* (#:key inputs outputs #:allow-other-keys)
320 (let ((input-dir (string-append (assoc-ref inputs "grub")
321 "/lib/grub"))
322 (output-dir (string-append (assoc-ref outputs "out")
323 "/lib/grub")))
324 (for-each
325 (lambda (basename)
db34d4bb
EF
326 (if (not (or (string-prefix? "." basename)
327 (file-exists? (string-append output-dir "/" basename))))
dd4b7476
DM
328 (symlink (string-append input-dir "/" basename)
329 (string-append output-dir "/" basename))))
330 (scandir input-dir))
331 #t)))))))))
332
96b714f5
DC
333(define-public syslinux
334 (let ((commit "bb41e935cc83c6242de24d2271e067d76af3585c"))
335 (package
336 (name "syslinux")
337 (version (git-version "6.04-pre" "1" commit))
338 (source (origin
339 (method git-fetch)
340 (uri (git-reference
341 (url "https://github.com/geneC/syslinux")
342 (commit commit)))
343 (file-name (git-file-name name version))
344 (sha256
345 (base32
346 "0k8dvafd6410kqxf3kyr4y8jzmpmrih6wbjqg6gklak7945yflrc"))))
347 (build-system gnu-build-system)
348 (native-inputs
349 `(("nasm" ,nasm)
350 ("perl" ,perl)
351 ("python-2" ,python-2)))
352 (inputs
bb93042c 353 `(("libuuid" ,util-linux "lib")
0b4dbb40 354 ("mtools" ,mtools)))
96b714f5
DC
355 (arguments
356 `(#:parallel-build? #f
357 #:make-flags
358 (list (string-append "BINDIR=" %output "/bin")
359 (string-append "SBINDIR=" %output "/sbin")
360 (string-append "LIBDIR=" %output "/lib")
361 (string-append "INCDIR=" %output "/include")
362 (string-append "DATADIR=" %output "/share")
363 (string-append "MANDIR=" %output "/share/man")
364 "PERL=perl"
365 "bios")
366 #:phases
367 (modify-phases %standard-phases
368 (add-after 'unpack 'patch-files
0b4dbb40 369 (lambda* (#:key inputs #:allow-other-keys)
96b714f5
DC
370 (substitute* (find-files "." "Makefile.*|ppmtolss16")
371 (("/bin/pwd") (which "pwd"))
372 (("/bin/echo") (which "echo"))
373 (("/usr/bin/perl") (which "perl")))
0b4dbb40
LC
374 (let ((mtools (assoc-ref inputs "mtools")))
375 (substitute* (find-files "." "\\.c$")
376 (("mcopy")
377 (string-append mtools "/bin/mcopy"))
378 (("mattrib")
379 (string-append mtools "/bin/mattrib"))))
96b714f5
DC
380 #t))
381 (delete 'configure)
382 (add-before 'build 'set-permissions
383 (lambda _
60d8db74 384 (invoke "chmod" "a+w" "utils/isohybrid.in")))
96b714f5
DC
385 (replace 'check
386 (lambda _
387 (setenv "CC" "gcc")
388 (substitute* "tests/unittest/include/unittest/unittest.h"
389 ;; Don't look up headers under /usr.
390 (("/usr/include/") ""))
60d8db74 391 (invoke "make" "unittest"))))))
0f304ba7 392 (home-page "https://www.syslinux.org")
96b714f5
DC
393 (synopsis "Lightweight Linux bootloader")
394 (description "Syslinux is a lightweight Linux bootloader.")
8d3f604d
EF
395 ;; The Makefile specifically targets i386 and x86_64 using nasm.
396 (supported-systems '("i686-linux" "x86_64-linux"))
96b714f5
DC
397 (license (list license:gpl2+
398 license:bsd-3 ; gnu-efi/*
399 license:bsd-4 ; gnu-efi/inc/* gnu-efi/lib/*
400 ;; Also contains:
401 license:expat license:isc license:zlib)))))
862e38d5
DC
402
403(define-public dtc
404 (package
405 (name "dtc")
91af1031 406 (version "1.5.1")
862e38d5
DC
407 (source (origin
408 (method url-fetch)
409 (uri (string-append
3b4efb1f 410 "mirror://kernel.org/software/utils/dtc/"
862e38d5
DC
411 "dtc-" version ".tar.xz"))
412 (sha256
413 (base32
91af1031 414 "07q3mdsvl4smbiakriq3hnsyyd0q344lsm306q0kgz4hjq1p82v6"))))
862e38d5
DC
415 (build-system gnu-build-system)
416 (native-inputs
417 `(("bison" ,bison)
12c613b5 418 ("flex" ,flex)
8cd10b22
VC
419 ("libyaml" ,libyaml)
420 ("pkg-config" ,pkg-config)
5d706f18
VC
421 ("swig" ,swig)
422 ("valgrind" ,valgrind)))
12c613b5 423 (inputs
5664a471 424 `(("python" ,python)))
862e38d5
DC
425 (arguments
426 `(#:make-flags
427 (list "CC=gcc"
91af1031
TGR
428
429 ;; /bin/fdt{get,overlay,put} need help finding libfdt.so.1.
430 (string-append "LDFLAGS=-Wl,-rpath="
431 (assoc-ref %outputs "out") "/lib")
432
862e38d5 433 (string-append "PREFIX=" (assoc-ref %outputs "out"))
12c613b5 434 (string-append "SETUP_PREFIX=" (assoc-ref %outputs "out"))
862e38d5
DC
435 "INSTALL=install")
436 #:phases
437 (modify-phases %standard-phases
d95bb295 438 (delete 'configure)))) ; no configure script
862e38d5
DC
439 (home-page "https://www.devicetree.org")
440 (synopsis "Compiles device tree source files")
441 (description "@command{dtc} compiles
442@uref{http://elinux.org/Device_Tree_Usage, device tree source files} to device
443tree binary files. These are board description files used by Linux and BSD.")
444 (license license:gpl2+)))
445
446(define u-boot
447 (package
448 (name "u-boot")
26c5e5af 449 (version "2020.10")
862e38d5
DC
450 (source (origin
451 (method url-fetch)
452 (uri (string-append
453 "ftp://ftp.denx.de/pub/u-boot/"
454 "u-boot-" version ".tar.bz2"))
455 (sha256
456 (base32
26c5e5af 457 "08m6f1bh4pdcqbxf983qdb66ccd5vak5cbzc114yf3jwq2yinj0d"))))
862e38d5
DC
458 (native-inputs
459 `(("bc" ,bc)
336c4a4b 460 ("bison" ,bison)
53e290df 461 ("dtc" ,dtc)
336c4a4b 462 ("flex" ,flex)
0c7707d5 463 ("lz4" ,lz4)
634b0e28
VC
464 ("perl" ,perl)
465 ("python" ,python)
466 ("python-coverage" ,python-coverage)
467 ("python-pytest" ,python-pytest)
f074f5e8 468 ("swig" ,swig)))
862e38d5 469 (build-system gnu-build-system)
3e63a83c 470 (home-page "https://www.denx.de/wiki/U-Boot/")
862e38d5
DC
471 (synopsis "ARM bootloader")
472 (description "U-Boot is a bootloader used mostly for ARM boards. It
473also initializes the boards (RAM etc).")
474 (license license:gpl2+)))
475
2676628f
DM
476(define-public u-boot-tools
477 (package
478 (inherit u-boot)
479 (name "u-boot-tools")
6b125371
DM
480 (native-inputs
481 `(("sdl2" ,sdl2)
482 ,@(package-native-inputs u-boot)))
2676628f 483 (arguments
65212c42 484 `(#:make-flags '("HOSTCC=gcc")
e9545e6d 485 #:test-target "tcheck"
2676628f
DM
486 #:phases
487 (modify-phases %standard-phases
65212c42
DM
488 (add-after 'unpack 'patch
489 (lambda* (#:key inputs #:allow-other-keys)
490 (substitute* "Makefile"
491 (("/bin/pwd") (which "pwd"))
492 (("/bin/false") (which "false")))
493 (substitute* "tools/dtoc/fdt_util.py"
494 (("'cc'") "'gcc'"))
e1d1ec14 495 (substitute* "tools/patman/test_util.py"
e9545e6d
VC
496 ;; python3-coverage is simply called coverage in guix.
497 (("python3-coverage") "coverage"))
65212c42
DM
498 (substitute* "test/run"
499 ;; Make it easier to find test failures.
500 (("#!/bin/bash") "#!/bin/bash -x")
65212c42
DM
501 ;; This test would require git.
502 (("\\./tools/patman/patman") (which "true"))
634b0e28
VC
503 ;; FIXME: test fails, needs further investiation
504 (("run_test \"binman\"") ": run_test \"binman\"")
505 ;; FIXME: code coverage not working
506 (("run_test \"binman code coverage\"") ": run_test \"binman code coverage\"")
65212c42
DM
507 ;; This test would require internet access.
508 (("\\./tools/buildman/buildman") (which "true")))
509 (substitute* "test/py/tests/test_sandbox_exit.py"
510 (("def test_ctrl_c")
511 "@pytest.mark.skip(reason='Guix has problems with SIGINT')
512def test_ctrl_c"))
6f5be83c
VC
513 ;; Test against the tools being installed rather than tools built
514 ;; for "sandbox" target.
515 (substitute* "test/image/test-imagetools.sh"
516 (("BASEDIR=sandbox") "BASEDIR=."))
4da4e952
VC
517 (for-each (lambda (file)
518 (substitute* file
e9545e6d
VC
519 ;; Disable features that require OpenSSL due
520 ;; to GPL/Openssl license incompatibilities.
521 ;; See https://bugs.gnu.org/34717 for
522 ;; details.
523 (("CONFIG_FIT_SIGNATURE=y")
524 "CONFIG_FIT_SIGNATURE=n\nCONFIG_UT_LIB_ASN1=n")
fb0aeaac
VC
525 ;; This test requires a sound system, which is un-used
526 ;; in u-boot-tools.
4da4e952 527 (("CONFIG_SOUND=y") "CONFIG_SOUND=n")))
634b0e28 528 (find-files "configs" "sandbox_.*defconfig$|tools-only_defconfig"))
65212c42 529 #t))
2676628f
DM
530 (replace 'configure
531 (lambda* (#:key make-flags #:allow-other-keys)
634b0e28 532 (apply invoke "make" "tools-only_defconfig" make-flags)))
2676628f
DM
533 (replace 'build
534 (lambda* (#:key inputs make-flags #:allow-other-keys)
9e84a4d6 535 (apply invoke "make" "tools-all" make-flags)))
2676628f
DM
536 (replace 'install
537 (lambda* (#:key outputs #:allow-other-keys)
538 (let* ((out (assoc-ref outputs "out"))
539 (bin (string-append out "/bin")))
540 (for-each (lambda (name)
541 (install-file name bin))
542 '("tools/netconsole"
543 "tools/jtagconsole"
544 "tools/gen_eth_addr"
545 "tools/gen_ethaddr_crc"
546 "tools/img2srec"
547 "tools/mkenvimage"
548 "tools/dumpimage"
549 "tools/mkimage"
550 "tools/proftool"
551 "tools/fdtgrep"
10186ee2
DM
552 "tools/env/fw_printenv"
553 "tools/sunxi-spl-image-builder"))
65212c42
DM
554 #t)))
555 (delete 'check)
556 (add-after 'install 'check
557 (lambda* (#:key make-flags test-target #:allow-other-keys)
6f5be83c
VC
558 (invoke "test/image/test-imagetools.sh")))
559 ;; Only run full test suite on x86_64 systems, as many tests
560 ;; assume x86_64.
561 ,@(if (string-match "^x86_64-linux"
562 (or (%current-target-system)
563 (%current-system)))
564 '((add-after 'check 'check-x86
565 (lambda* (#:key make-flags test-target #:allow-other-keys)
566 (apply invoke "make" "mrproper" make-flags)
567 (setenv "SDL_VIDEODRIVER" "dummy")
568 (setenv "PAGER" "cat")
569 (apply invoke "make" test-target make-flags))))
570 '()))))
2676628f
DM
571 (description "U-Boot is a bootloader used mostly for ARM boards. It
572also initializes the boards (RAM etc). This package provides its
573board-independent tools.")))
574
4ce4fc50 575(define-public (make-u-boot-package board triplet)
862e38d5 576 "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
6bfcb729
LC
577 (let ((same-arch? (lambda ()
578 (string=? (%current-system)
579 (gnu-triplet->nix-system triplet)))))
3bfee8ff
EF
580 (package
581 (inherit u-boot)
df8a9096
DM
582 (name (string-append "u-boot-"
583 (string-replace-substring (string-downcase board)
584 "_" "-")))
3bfee8ff 585 (native-inputs
6bfcb729 586 `(,@(if (not (same-arch?))
b8806e13 587 `(("cross-gcc" ,(cross-gcc triplet))
3bfee8ff 588 ("cross-binutils" ,(cross-binutils triplet)))
b8806e13 589 `())
3bfee8ff
EF
590 ,@(package-native-inputs u-boot)))
591 (arguments
37297674
EF
592 `(#:modules ((ice-9 ftw)
593 (srfi srfi-1)
594 (guix build utils)
595 (guix build gnu-build-system))
3bfee8ff
EF
596 #:test-target "test"
597 #:make-flags
598 (list "HOSTCC=gcc"
6bfcb729 599 ,@(if (not (same-arch?))
3bfee8ff
EF
600 `((string-append "CROSS_COMPILE=" ,triplet "-"))
601 '()))
602 #:phases
603 (modify-phases %standard-phases
604 (replace 'configure
605 (lambda* (#:key outputs make-flags #:allow-other-keys)
606 (let ((config-name (string-append ,board "_defconfig")))
607 (if (file-exists? (string-append "configs/" config-name))
8f43bdd9 608 (apply invoke "make" `(,@make-flags ,config-name))
3bfee8ff 609 (begin
ac30d18c
DM
610 (display "Invalid board name. Valid board names are:"
611 (current-error-port))
30ef146c
DM
612 (let ((suffix-len (string-length "_defconfig"))
613 (entries (scandir "configs")))
614 (for-each (lambda (file-name)
615 (when (string-suffix? "_defconfig" file-name)
ac30d18c 616 (format (current-error-port)
30ef146c
DM
617 "- ~A\n"
618 (string-drop-right file-name
619 suffix-len))))
ee3c8fbe 620 (sort entries string-ci<)))
bdd235b3 621 (error "Invalid boardname ~s." ,board))))))
3bfee8ff 622 (replace 'install
9b94ced4 623 (lambda* (#:key outputs #:allow-other-keys)
3bfee8ff
EF
624 (let* ((out (assoc-ref outputs "out"))
625 (libexec (string-append out "/libexec"))
dd208b93 626 (uboot-files (append
a9446dde
DM
627 (remove
628 ;; Those would not be reproducible
629 ;; because of the randomness used
630 ;; to produce them.
631 ;; It's expected that the user will
632 ;; use u-boot-tools to generate them
633 ;; instead.
634 (lambda (name)
635 (string-suffix?
636 "sunxi-spl-with-ecc.bin"
637 name))
638 (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
fd0b21d5 639 (find-files "." "^(MLO|SPL)$"))))
3bfee8ff 640 (mkdir-p libexec)
a32f9b59 641 (install-file ".config" libexec)
0fcfed39
DM
642 ;; Useful for "qemu -kernel".
643 (install-file "u-boot" libexec)
3bfee8ff
EF
644 (for-each
645 (lambda (file)
646 (let ((target-file (string-append libexec "/" file)))
647 (mkdir-p (dirname target-file))
648 (copy-file file target-file)))
d1af9a8c
DM
649 uboot-files)
650 #t)))))))))
862e38d5
DC
651
652(define-public u-boot-vexpress
653 (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
654
655(define-public u-boot-malta
656 (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
657
6b99afee
VC
658(define-public u-boot-am335x-boneblack
659 (let ((base (make-u-boot-package "am335x_evm" "arm-linux-gnueabihf")))
660 (package
661 (inherit base)
662 (name "u-boot-am335x-boneblack")
663 (description "U-Boot is a bootloader used mostly for ARM boards. It
664also initializes the boards (RAM etc).
665
666This U-Boot is built for the BeagleBone Black, which was removed upstream,
667adjusted from the am335x_evm build with several device trees removed so that
668it fits within common partitioning schemes.")
669 (arguments
670 (substitute-keyword-arguments (package-arguments base)
671 ((#:phases phases)
672 `(modify-phases ,phases
673 (add-after 'unpack 'patch-defconfig
674 ;; Patch out other devicetrees to build image small enough to
675 ;; fit within typical partitioning schemes where the first
676 ;; partition begins at sector 2048.
677 (lambda _
678 (substitute* "configs/am335x_evm_defconfig"
679 (("CONFIG_OF_LIST=.*$") "CONFIG_OF_LIST=\"am335x-evm am335x-boneblack\"\n"))
680 #t)))))))))
681
682(define-public u-boot-am335x-evm
683 (make-u-boot-package "am335x_evm" "arm-linux-gnueabihf"))
4adeb3f6 684
0da3526d
VC
685(define-public (make-u-boot-sunxi64-package board triplet)
686 (let ((base (make-u-boot-package board triplet)))
29be6cfb
EF
687 (package
688 (inherit base)
689 (arguments
690 (substitute-keyword-arguments (package-arguments base)
691 ((#:phases phases)
692 `(modify-phases ,phases
693 (add-after 'unpack 'set-environment
db78fc06
MO
694 (lambda* (#:key native-inputs inputs #:allow-other-keys)
695 (let ((bl31
696 (string-append
697 (assoc-ref (or native-inputs inputs) "firmware")
698 "/bl31.bin")))
29be6cfb 699 (setenv "BL31" bl31)
35e427d1
DM
700 ;; This is necessary when we're using the bundled dtc.
701 ;(setenv "PATH" (string-append (getenv "PATH") ":"
702 ; "scripts/dtc"))
703 )
29be6cfb
EF
704 #t))))))
705 (native-inputs
95d91986 706 `(("firmware" ,arm-trusted-firmware-sun50i-a64)
29be6cfb
EF
707 ,@(package-native-inputs base))))))
708
0da3526d
VC
709(define-public u-boot-pine64-plus
710 (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu"))
711
af58b275
MO
712(define-public u-boot-pine64-lts
713 (make-u-boot-sunxi64-package "pine64-lts" "aarch64-linux-gnu"))
714
74e35e8c 715(define-public u-boot-pinebook
760dfc67
VC
716 (let ((base (make-u-boot-sunxi64-package "pinebook" "aarch64-linux-gnu")))
717 (package
718 (inherit base)
719 (arguments
720 (substitute-keyword-arguments (package-arguments base)
721 ((#:phases phases)
722 `(modify-phases ,phases
723 (add-after 'unpack 'patch-pinebook-config
724 ;; Fix regression with LCD video output introduced in 2020.01
725 ;; https://patchwork.ozlabs.org/patch/1225130/
726 (lambda _
727 (substitute* "configs/pinebook_defconfig"
728 (("CONFIG_VIDEO_BRIDGE_ANALOGIX_ANX6345=y") "CONFIG_VIDEO_BRIDGE_ANALOGIX_ANX6345=y\nCONFIG_VIDEO_BPP32=y"))
729 #t)))))))))
74e35e8c 730
e830c9d0 731(define-public u-boot-bananapi-m2-ultra
30aeb846
DM
732 (make-u-boot-package "Bananapi_M2_Ultra" "arm-linux-gnueabihf"))
733
c55c6985
DM
734(define-public u-boot-a20-olinuxino-lime
735 (make-u-boot-package "A20-OLinuXino-Lime" "arm-linux-gnueabihf"))
736
4b9e9abb
DM
737(define-public u-boot-a20-olinuxino-lime2
738 (make-u-boot-package "A20-OLinuXino-Lime2" "arm-linux-gnueabihf"))
739
a7bb327e
DM
740(define-public u-boot-a20-olinuxino-micro
741 (make-u-boot-package "A20-OLinuXino_MICRO" "arm-linux-gnueabihf"))
742
84ee3378
DM
743(define-public u-boot-nintendo-nes-classic-edition
744 (make-u-boot-package "Nintendo_NES_Classic_Edition" "arm-linux-gnueabihf"))
745
95a3422e
VC
746(define-public u-boot-wandboard
747 (make-u-boot-package "wandboard" "arm-linux-gnueabihf"))
748
adc61d72
VC
749(define-public u-boot-mx6cuboxi
750 (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf"))
751
1b960787 752(define-public u-boot-novena
6e2bad00
VC
753 (let ((base (make-u-boot-package "novena" "arm-linux-gnueabihf")))
754 (package
755 (inherit base)
756 (description "U-Boot is a bootloader used mostly for ARM boards. It
757also initializes the boards (RAM etc).
758
759This U-Boot is built for Novena. Be advised that this version, contrary
6b99afee 760to Novena upstream, does not load u-boot.img from the first partition.")
6e2bad00
VC
761 (arguments
762 (substitute-keyword-arguments (package-arguments base)
763 ((#:phases phases)
764 `(modify-phases ,phases
765 (add-after 'unpack 'patch-novena-defconfig
766 ;; Patch configuration to disable loading u-boot.img from FAT partition,
767 ;; allowing it to be installed at a device offset.
768 (lambda _
769 (substitute* "configs/novena_defconfig"
6b99afee 770 (("CONFIG_SPL_FS_FAT=y") "# CONFIG_SPL_FS_FAT is not set"))
6e2bad00 771 #t)))))))))
1b960787 772
dd4fe0c2
DM
773(define-public u-boot-cubieboard
774 (make-u-boot-package "Cubieboard" "arm-linux-gnueabihf"))
775
a7d5ce94
JL
776(define-public u-boot-cubietruck
777 (make-u-boot-package "Cubietruck" "arm-linux-gnueabihf"))
778
6fe16577
VC
779(define-public u-boot-puma-rk3399
780 (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu")))
781 (package
782 (inherit base)
783 (arguments
784 (substitute-keyword-arguments (package-arguments base)
785 ((#:phases phases)
786 `(modify-phases ,phases
787 (add-after 'unpack 'set-environment
788 (lambda* (#:key inputs #:allow-other-keys)
789 ;; Need to copy the firmware into u-boot build
790 ;; directory.
791 (copy-file (string-append (assoc-ref inputs "firmware")
792 "/bl31.bin") "bl31-rk3399.bin")
793 (copy-file (string-append (assoc-ref inputs "firmware-m0")
794 "/rk3399m0.bin") "rk3399m0.bin")
795 #t))
796 (add-after 'build 'build-itb
797 (lambda* (#:key make-flags #:allow-other-keys)
798 ;; The u-boot.itb is not built by default.
799 (apply invoke "make" `(,@make-flags ,"u-boot.itb"))))
800 (add-after 'build-itb 'build-rksd
801 (lambda* (#:key inputs #:allow-other-keys)
802 ;; Build Rockchip SD card images.
803 (invoke "./tools/mkimage" "-T" "rksd" "-n" "rk3399" "-d"
804 "spl/u-boot-spl.bin" "u-boot-spl.rksd")))))))
805 (native-inputs
806 `(("firmware" ,arm-trusted-firmware-puma-rk3399)
807 ("firmware-m0" ,rk3399-cortex-m0)
808 ,@(package-native-inputs base))))))
809
10f31af9
VC
810(define-public u-boot-qemu-riscv64
811 (make-u-boot-package "qemu-riscv64" "riscv64-linux-gnu"))
812
7e954f67 813(define-public u-boot-qemu-riscv64-smode
1f9fae00
VC
814 (let ((base (make-u-boot-package "qemu-riscv64_smode" "riscv64-linux-gnu")))
815 (package
816 (inherit base)
817 (source (origin
818 (inherit (package-source u-boot))
819 (patches
820 (search-patches "u-boot-riscv64-fix-extlinux.patch")))))))
7e954f67 821
7d063645
VC
822(define-public u-boot-sifive-fu540
823 (make-u-boot-package "sifive_fu540" "riscv64-linux-gnu"))
824
2fce14af
VC
825(define-public u-boot-rock64-rk3328
826 (let ((base (make-u-boot-package "rock64-rk3328" "aarch64-linux-gnu")))
827 (package
828 (inherit base)
2fce14af
VC
829 (arguments
830 (substitute-keyword-arguments (package-arguments base)
831 ((#:phases phases)
832 `(modify-phases ,phases
833 (add-after 'unpack 'set-environment
834 (lambda* (#:key inputs #:allow-other-keys)
835 (let ((bl31 (string-append (assoc-ref inputs "firmware")
836 "/bl31.elf")))
837 (setenv "BL31" bl31))
2fce14af
VC
838 #t))))))
839 (native-inputs
840 `(("firmware" ,arm-trusted-firmware-rk3328)
841 ,@(package-native-inputs base))))))
842
545ff7b7
VC
843(define-public u-boot-firefly-rk3399
844 (let ((base (make-u-boot-package "firefly-rk3399" "aarch64-linux-gnu")))
845 (package
846 (inherit base)
545ff7b7
VC
847 (arguments
848 (substitute-keyword-arguments (package-arguments base)
849 ((#:phases phases)
850 `(modify-phases ,phases
851 (add-after 'unpack 'set-environment
852 (lambda* (#:key inputs #:allow-other-keys)
853 (setenv "BL31" (string-append (assoc-ref inputs "firmware")
854 "/bl31.elf"))
855 #t))
856 ;; Phases do not succeed on the bl31 ELF.
857 (delete 'strip)
858 (delete 'validate-runpath)))))
859 (native-inputs
860 `(("firmware" ,arm-trusted-firmware-rk3399)
861 ,@(package-native-inputs base))))))
862
fa747018
CN
863(define-public u-boot-rockpro64-rk3399
864 (let ((base (make-u-boot-package "rockpro64-rk3399" "aarch64-linux-gnu")))
865 (package
866 (inherit base)
5327b399
VC
867 (arguments
868 (substitute-keyword-arguments (package-arguments base)
869 ((#:phases phases)
870 `(modify-phases ,phases
871 (add-after 'unpack 'set-environment
872 (lambda* (#:key inputs #:allow-other-keys)
873 (setenv "BL31" (string-append (assoc-ref inputs "firmware")
874 "/bl31.elf"))
875 #t))
876 ;; Phases do not succeed on the bl31 ELF.
877 (delete 'strip)
878 (delete 'validate-runpath)))))
879 (native-inputs
880 `(("firmware" ,arm-trusted-firmware-rk3399)
881 ,@(package-native-inputs base))))))
882
883(define-public u-boot-pinebook-pro-rk3399
884 (let ((base (make-u-boot-package "pinebook-pro-rk3399" "aarch64-linux-gnu")))
885 (package
886 (inherit base)
fa747018
CN
887 (arguments
888 (substitute-keyword-arguments (package-arguments base)
889 ((#:phases phases)
890 `(modify-phases ,phases
891 (add-after 'unpack 'set-environment
892 (lambda* (#:key inputs #:allow-other-keys)
893 (setenv "BL31" (string-append (assoc-ref inputs "firmware")
894 "/bl31.elf"))
895 #t))
896 ;; Phases do not succeed on the bl31 ELF.
897 (delete 'strip)
898 (delete 'validate-runpath)))))
899 (native-inputs
900 `(("firmware" ,arm-trusted-firmware-rk3399)
901 ,@(package-native-inputs base))))))
902
a60f1319
MB
903(define-public vboot-utils
904 (package
905 (name "vboot-utils")
906 (version "R63-10032.B")
907 (source (origin
908 ;; XXX: Snapshots are available but changes timestamps every download.
909 (method git-fetch)
910 (uri (git-reference
911 (url (string-append "https://chromium.googlesource.com"
912 "/chromiumos/platform/vboot_reference"))
913 (commit (string-append "release-" version))))
914 (file-name (string-append name "-" version "-checkout"))
915 (sha256
916 (base32
b634b5c2
KK
917 "0h0m3l69vp9dr6xrs1p6y7ilkq3jq8jraw2z20kqfv7lvc9l1lxj"))
918 (patches
919 (search-patches "vboot-utils-skip-test-workbuf.patch"
920 "vboot-utils-fix-tests-show-contents.patch"
921 "vboot-utils-fix-format-load-address.patch"))))
a60f1319
MB
922 (build-system gnu-build-system)
923 (arguments
924 `(#:make-flags (list "CC=gcc"
b634b5c2
KK
925 ;; On ARM, we must pass "HOST_ARCH=arm" so that the
926 ;; ${HOST_ARCH} and ${ARCH} variables in the makefile
927 ;; match. Otherwise, ${HOST_ARCH} will be assigned
928 ;; "armv7l", the value of `uname -m`, and will not
929 ;; match ${ARCH}, which will make the tests require
930 ;; QEMU for testing.
931 ,@(if (string-prefix? "arm"
932 (or (%current-target-system)
933 (%current-system)))
934 '("HOST_ARCH=arm")
935 '())
a60f1319
MB
936 (string-append "DESTDIR=" (assoc-ref %outputs "out")))
937 #:phases (modify-phases %standard-phases
938 (add-after 'unpack 'patch-hard-coded-paths
939 (lambda* (#:key inputs outputs #:allow-other-keys)
940 (let ((coreutils (assoc-ref inputs "coreutils"))
941 (diffutils (assoc-ref inputs "diffutils")))
942 (substitute* "futility/misc.c"
943 (("/bin/cp") (string-append coreutils "/bin/cp")))
944 (substitute* "tests/bitmaps/TestBmpBlock.py"
945 (("/usr/bin/cmp") (string-append diffutils "/bin/cmp")))
946 (substitute* "vboot_host.pc.in"
947 (("prefix=/usr")
948 (string-append "prefix=" (assoc-ref outputs "out"))))
949 #t)))
950 (delete 'configure)
951 (add-before 'check 'patch-tests
952 (lambda _
953 ;; These tests compare diffs against known-good values.
954 ;; Patch the paths to match those in the build container.
955 (substitute* (find-files "tests/futility/expect_output")
956 (("/mnt/host/source/src/platform/vboot_reference")
957 (string-append "/tmp/guix-build-" ,name "-" ,version
958 ".drv-0/source")))
959 ;; Tests require write permissions to many of these files.
960 (for-each make-file-writable (find-files "tests/futility"))
71f2b4b8
KK
961 #t))
962 (add-after 'install 'install-devkeys
963 (lambda* (#:key outputs #:allow-other-keys)
964 (let* ((out (assoc-ref outputs "out"))
965 (share (string-append out "/share/vboot-utils")))
966 (copy-recursively "tests/devkeys"
967 (string-append share "/devkeys"))
968 #t))))
a60f1319
MB
969 #:test-target "runtests"))
970 (native-inputs
971 `(("pkg-config" ,pkg-config)
972
973 ;; For tests.
974 ("diffutils" ,diffutils)
975 ("python@2" ,python-2)))
976 (inputs
977 `(("coreutils" ,coreutils)
978 ("libyaml" ,libyaml)
979 ("openssl" ,openssl)
980 ("openssl:static" ,openssl "static")
bb93042c 981 ("util-linux" ,util-linux "lib")))
a60f1319
MB
982 (home-page
983 "https://dev.chromium.org/chromium-os/chromiumos-design-docs/verified-boot")
984 (synopsis "ChromiumOS verified boot utilities")
985 (description
986 "vboot-utils is a collection of tools to facilitate booting of
987Chrome-branded devices. This includes the @command{cgpt} partitioning
988program, the @command{futility} and @command{crossystem} firmware management
989tools, and more.")
990 (license license:bsd-3)))
991
aa90375a
AI
992(define-public os-prober
993 (package
994 (name "os-prober")
e9bdef5f 995 (version "1.77")
aa90375a
AI
996 (source
997 (origin
998 (method url-fetch)
999 (uri (string-append "mirror://debian/pool/main/o/os-prober/os-prober_"
1000 version ".tar.xz"))
1001 (sha256
1002 (base32
e9bdef5f 1003 "0pvhrw4h05n21zw7ig3a3bi8aqdh6zxs0x1znz4g7vhspsps93ld"))))
aa90375a
AI
1004 (build-system gnu-build-system)
1005 (arguments
1006 `(#:modules ((guix build gnu-build-system)
1007 (guix build utils)
e9bdef5f
TGR
1008 (ice-9 regex) ; for string-match
1009 (srfi srfi-26)) ; for cut
33430a45
TGR
1010 #:make-flags
1011 (list ,(string-append "CC=" (cc-for-target)))
e9bdef5f 1012 #:tests? #f ; no tests
aa90375a
AI
1013 #:phases
1014 (modify-phases %standard-phases
1015 (replace 'configure
1016 (lambda* (#:key outputs #:allow-other-keys)
1017 (substitute* (find-files ".")
1018 (("/usr") (assoc-ref outputs "out")))
1019 (substitute* (find-files "." "50mounted-tests$")
1020 (("mkdir") "mkdir -p"))
1021 #t))
1022 (replace 'install
1023 (lambda* (#:key outputs #:allow-other-keys)
1024 (define (find-files-non-recursive directory)
1025 (find-files directory
1026 (lambda (file stat)
1027 (string-match (string-append "^" directory "/[^/]*$")
1028 file))
1029 #:directories? #t))
1030
1031 (let* ((out (assoc-ref outputs "out"))
1032 (bin (string-append out "/bin"))
1033 (lib (string-append out "/lib"))
1034 (share (string-append out "/share")))
1035 (for-each (cut install-file <> bin)
1036 (list "linux-boot-prober" "os-prober"))
1037 (install-file "newns" (string-append lib "/os-prober"))
1038 (install-file "common.sh" (string-append share "/os-prober"))
1039 (install-file "os-probes/mounted/powerpc/20macosx"
1040 (string-append lib "/os-probes/mounted"))
1041 (for-each
1042 (lambda (directory)
1043 (for-each
1044 (lambda (file)
1045 (let ((destination (string-append lib "/" directory
1046 "/" (basename file))))
1047 (mkdir-p (dirname destination))
1048 (copy-recursively file destination)))
1049 (append (find-files-non-recursive (string-append directory "/common"))
1050 (find-files-non-recursive (string-append directory "/x86")))))
1051 (list "os-probes" "os-probes/mounted" "os-probes/init"
1052 "linux-boot-probes" "linux-boot-probes/mounted"))
1053 #t))))))
1054 (home-page "https://joeyh.name/code/os-prober")
1055 (synopsis "Detect other operating systems")
1056 (description "os-prober probes disks on the system for other operating
1057systems so that they can be added to the bootloader. It also works out how to
1058boot existing GNU/Linux systems and detects what distribution is installed in
1059order to add a suitable bootloader menu entry.")
1060 (license license:gpl2+)))