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