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