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