Commit | Line | Data |
---|---|---|
65d8b777 | 1 | ;;; GNU Guix --- Functional package management for GNU |
a7c87169 | 2 | ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> |
0a2a7053 | 3 | ;;; Copyright © 2015, 2018 Mark H Weaver <mhw@netris.org> |
f0150f87 | 4 | ;;; Copyright © 2015 Leo Famulari <leo@famulari.name> |
4c726001 | 5 | ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org> |
a60f1319 | 6 | ;;; Copyright © 2016, 2017, 2018 Marius Bakke <mbakke@fastmail.com> |
862e38d5 DC |
7 | ;;; Copyright © 2016, 2017 Danny Milosavljevic <dannym@scratchpost.org> |
8 | ;;; Copyright © 2016, 2017 David Craven <david@craven.ch> | |
db34d4bb | 9 | ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il> |
d95bb295 | 10 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
65d8b777 LC |
11 | ;;; |
12 | ;;; This file is part of GNU Guix. | |
13 | ;;; | |
14 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
15 | ;;; under the terms of the GNU General Public License as published by | |
16 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
17 | ;;; your option) any later version. | |
18 | ;;; | |
19 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
20 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | ;;; GNU General Public License for more details. | |
23 | ;;; | |
24 | ;;; You should have received a copy of the GNU General Public License | |
25 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
26 | ||
862e38d5 | 27 | (define-module (gnu packages bootloaders) |
65d8b777 | 28 | #:use-module (gnu packages) |
862e38d5 DC |
29 | #:use-module (gnu packages admin) |
30 | #:use-module ((gnu packages algebra) #:select (bc)) | |
31 | #:use-module (gnu packages assembly) | |
a60f1319 | 32 | #:use-module (gnu packages base) |
7febe3a2 | 33 | #:use-module (gnu packages disk) |
65d8b777 | 34 | #:use-module (gnu packages bison) |
862e38d5 | 35 | #:use-module (gnu packages cdrom) |
65212c42 | 36 | #:use-module (gnu packages check) |
862e38d5 DC |
37 | #:use-module (gnu packages cross-base) |
38 | #:use-module (gnu packages disk) | |
29be6cfb | 39 | #:use-module (gnu packages firmware) |
862e38d5 | 40 | #:use-module (gnu packages flex) |
a86177d6 | 41 | #:use-module (gnu packages fontutils) |
f074f5e8 | 42 | #:use-module (gnu packages gcc) |
862e38d5 | 43 | #:use-module (gnu packages gettext) |
65d8b777 | 44 | #:use-module (gnu packages linux) |
862e38d5 | 45 | #:use-module (gnu packages man) |
444f9dcc | 46 | #:use-module (gnu packages mtools) |
862e38d5 | 47 | #:use-module (gnu packages ncurses) |
96b714f5 | 48 | #:use-module (gnu packages perl) |
a60f1319 | 49 | #:use-module (gnu packages pkg-config) |
96b714f5 | 50 | #:use-module (gnu packages python) |
58301666 | 51 | #:use-module (gnu packages texinfo) |
a60f1319 | 52 | #:use-module (gnu packages tls) |
65212c42 | 53 | #:use-module (gnu packages sdl) |
12c613b5 | 54 | #:use-module (gnu packages swig) |
59132b80 | 55 | #:use-module (gnu packages virtualization) |
a60f1319 | 56 | #:use-module (gnu packages web) |
862e38d5 DC |
57 | #:use-module (guix build-system gnu) |
58 | #:use-module (guix download) | |
59 | #:use-module (guix git-download) | |
60 | #:use-module ((guix licenses) #:prefix license:) | |
61 | #:use-module (guix packages) | |
63087721 EF |
62 | #:use-module (guix utils) |
63 | #:use-module (srfi srfi-1) | |
a7c87169 MW |
64 | #:use-module (srfi srfi-26) |
65 | #:use-module (ice-9 regex)) | |
65d8b777 | 66 | |
9b24c768 LC |
67 | (define unifont |
68 | ;; GNU Unifont, <http://gnu.org/s/unifont>. | |
69 | ;; GRUB needs it for its graphical terminal, gfxterm. | |
70 | (origin | |
71 | (method url-fetch) | |
72 | (uri | |
73 | "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz") | |
74 | (sha256 | |
75 | (base32 | |
76 | "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys")))) | |
77 | ||
65d8b777 LC |
78 | (define-public grub |
79 | (package | |
80 | (name "grub") | |
3586a3e9 | 81 | (version "2.02") |
65d8b777 LC |
82 | (source (origin |
83 | (method url-fetch) | |
3586a3e9 | 84 | (uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz")) |
65d8b777 LC |
85 | (sha256 |
86 | (base32 | |
3586a3e9 | 87 | "03vvdfhdmf16121v7xs8is2krwnv15wpkhkf16a4yf8nsfc3f2w1")))) |
65d8b777 LC |
88 | (build-system gnu-build-system) |
89 | (arguments | |
56f0feb6 | 90 | `(#:phases (modify-phases %standard-phases |
358db004 | 91 | (add-after 'unpack 'patch-stuff |
04e0eac1 MW |
92 | (lambda* (#:key inputs #:allow-other-keys) |
93 | (substitute* "grub-core/Makefile.in" | |
94 | (("/bin/sh") (which "sh"))) | |
65d8b777 | 95 | |
358db004 LC |
96 | ;; Give the absolute file name of 'mdadm', used to |
97 | ;; determine the root file system when it's a RAID | |
98 | ;; device. Failing to do that, 'grub-probe' silently | |
99 | ;; fails if 'mdadm' is not in $PATH. | |
100 | (substitute* "grub-core/osdep/linux/getroot.c" | |
101 | (("argv\\[0\\] = \"mdadm\"") | |
102 | (string-append "argv[0] = \"" | |
103 | (assoc-ref inputs "mdadm") | |
104 | "/sbin/mdadm\""))) | |
105 | ||
04e0eac1 MW |
106 | ;; Make the font visible. |
107 | (copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz") | |
108 | (system* "gunzip" "unifont.bdf.gz") | |
23a53a95 LF |
109 | #t)) |
110 | (add-before 'check 'disable-flaky-test | |
111 | (lambda _ | |
112 | ;; This test is unreliable. For more information, see: | |
113 | ;; <https://bugs.gnu.org/26936>. | |
114 | (substitute* "Makefile.in" | |
115 | (("grub_cmd_date grub_cmd_set_date grub_cmd_sleep") | |
116 | "grub_cmd_date grub_cmd_sleep")) | |
56f0feb6 | 117 | #t))) |
63087721 EF |
118 | ;; Disable tests on ARM and AARCH64 platforms. |
119 | #:tests? ,(not (any (cute string-prefix? <> (or (%current-target-system) | |
120 | (%current-system))) | |
121 | '("arm" "aarch64"))))) | |
65d8b777 | 122 | (inputs |
10da75df LC |
123 | `(("gettext" ,gettext-minimal) |
124 | ||
125 | ;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and | |
126 | ;; 'grub-install' to recognize mapped devices (LUKS, etc.) | |
127 | ("lvm2" ,lvm2) | |
128 | ||
129 | ;; Depend on mdadm, which is invoked by 'grub-probe' and 'grub-install' | |
130 | ;; to determine whether the root file system is RAID. | |
358db004 | 131 | ("mdadm" ,mdadm) |
10da75df | 132 | |
65d8b777 LC |
133 | ("freetype" ,freetype) |
134 | ;; ("libusb" ,libusb) | |
04e0eac1 | 135 | ;; ("fuse" ,fuse) |
01eafd38 | 136 | ("ncurses" ,ncurses))) |
65d8b777 | 137 | (native-inputs |
0a2a7053 MW |
138 | `(("pkg-config" ,pkg-config) |
139 | ("unifont" ,unifont) | |
9b24c768 | 140 | ("bison" ,bison) |
0a3aca47 LF |
141 | ;; Due to a bug in flex >= 2.6.2, GRUB must be built with an older flex: |
142 | ;; <http://lists.gnu.org/archive/html/grub-devel/2017-02/msg00133.html> | |
143 | ;; TODO Try building with flex > 2.6.4. | |
144 | ("flex" ,flex-2.6.1) | |
58301666 MW |
145 | ("texinfo" ,texinfo) |
146 | ("help2man" ,help2man) | |
65d8b777 | 147 | |
a7c87169 MW |
148 | ;; XXX: When building GRUB 2.02 on 32-bit x86, we need a binutils |
149 | ;; capable of assembling 64-bit instructions. However, our default | |
150 | ;; binutils on 32-bit x86 is not 64-bit capable. | |
151 | ,@(if (string-match "^i[3456]86-" (%current-system)) | |
152 | (let ((binutils (package/inherit | |
153 | binutils | |
154 | (name "binutils-i386") | |
155 | (arguments | |
156 | (substitute-keyword-arguments (package-arguments binutils) | |
157 | ((#:configure-flags flags ''()) | |
158 | `(cons "--enable-64-bit-bfd" ,flags))))))) | |
159 | `(("ld-wrapper" ,(make-ld-wrapper "ld-wrapper-i386" | |
160 | #:binutils binutils)) | |
161 | ("binutils" ,binutils))) | |
162 | '()) | |
163 | ||
65d8b777 LC |
164 | ;; Dependencies for the test suite. The "real" QEMU is needed here, |
165 | ;; because several targets are used. | |
7febe3a2 | 166 | ("parted" ,parted) |
d64bcccf | 167 | ("qemu" ,qemu-minimal-2.10) |
65d8b777 | 168 | ("xorriso" ,xorriso))) |
175b259c | 169 | (home-page "https://www.gnu.org/software/grub/") |
79c311b8 | 170 | (synopsis "GRand Unified Boot loader") |
65d8b777 | 171 | (description |
a22dc0c4 | 172 | "GRUB is a multiboot bootloader. It is used for initially loading the |
35b9e423 | 173 | kernel of an operating system and then transferring control to it. The kernel |
c5779c93 | 174 | then goes on to load the rest of the operating system. As a multiboot |
574e86f9 LC |
175 | bootloader, GRUB handles the presence of multiple operating systems installed |
176 | on the same computer; upon booting the computer, the user is presented with a | |
a22dc0c4 | 177 | menu to select one of the installed operating systems.") |
3f73aa1a | 178 | (license license:gpl3+) |
99effc8f | 179 | (properties '((cpe-name . "grub2"))))) |
acb5f7c3 MB |
180 | |
181 | (define-public grub-efi | |
182 | (package | |
183 | (inherit grub) | |
184 | (name "grub-efi") | |
185 | (synopsis "GRand Unified Boot loader (UEFI version)") | |
186 | (inputs | |
187 | `(("efibootmgr" ,efibootmgr) | |
c695fb76 | 188 | ("mtools" ,mtools) |
acb5f7c3 MB |
189 | ,@(package-inputs grub))) |
190 | (arguments | |
191 | `(;; TODO: Tests need a UEFI firmware for qemu. There is one at | |
192 | ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg . | |
193 | ;; Search for 'OVMF' in "tests/util/grub-shell.in". | |
acb5f7c3 | 194 | ,@(substitute-keyword-arguments (package-arguments grub) |
46ff2dbb | 195 | ((#:tests? _ #f) #f) |
ef753a1a LC |
196 | ((#:configure-flags flags ''()) |
197 | `(cons "--with-platform=efi" ,flags)) | |
acb5f7c3 MB |
198 | ((#:phases phases) |
199 | `(modify-phases ,phases | |
200 | (add-after 'patch-stuff 'use-absolute-efibootmgr-path | |
201 | (lambda* (#:key inputs #:allow-other-keys) | |
202 | (substitute* "grub-core/osdep/unix/platform.c" | |
203 | (("efibootmgr") | |
204 | (string-append (assoc-ref inputs "efibootmgr") | |
205 | "/sbin/efibootmgr"))) | |
444f9dcc DM |
206 | #t)) |
207 | (add-after 'patch-stuff 'use-absolute-mtools-path | |
208 | (lambda* (#:key inputs #:allow-other-keys) | |
209 | (let ((mtools (assoc-ref inputs "mtools"))) | |
210 | (substitute* "util/grub-mkrescue.c" | |
211 | (("\"mformat\"") | |
212 | (string-append "\"" mtools | |
213 | "/bin/mformat\""))) | |
214 | (substitute* "util/grub-mkrescue.c" | |
215 | (("\"mcopy\"") | |
216 | (string-append "\"" mtools | |
217 | "/bin/mcopy\""))) | |
218 | #t)))))))))) | |
96b714f5 | 219 | |
dd4b7476 DM |
220 | ;; Because grub searches hardcoded paths it's easiest to just build grub |
221 | ;; again to make it find both grub-pc and grub-efi. There is a command | |
222 | ;; line argument which allows you to specify ONE platform - but | |
223 | ;; grub-mkrescue will use multiple platforms if they are available | |
224 | ;; in the installation directory (without command line argument). | |
225 | (define-public grub-hybrid | |
226 | (package | |
227 | (inherit grub-efi) | |
228 | (name "grub-hybrid") | |
229 | (synopsis "GRand Unified Boot loader (hybrid version)") | |
230 | (inputs | |
231 | `(("grub" ,grub) | |
232 | ,@(package-inputs grub-efi))) | |
233 | (arguments | |
234 | (substitute-keyword-arguments (package-arguments grub-efi) | |
235 | ((#:modules modules `((guix build utils) (guix build gnu-build-system))) | |
236 | `((ice-9 ftw) ,@modules)) | |
237 | ((#:phases phases) | |
238 | `(modify-phases ,phases | |
239 | (add-after 'install 'install-non-efi | |
240 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
241 | (let ((input-dir (string-append (assoc-ref inputs "grub") | |
242 | "/lib/grub")) | |
243 | (output-dir (string-append (assoc-ref outputs "out") | |
244 | "/lib/grub"))) | |
245 | (for-each | |
246 | (lambda (basename) | |
db34d4bb EF |
247 | (if (not (or (string-prefix? "." basename) |
248 | (file-exists? (string-append output-dir "/" basename)))) | |
dd4b7476 DM |
249 | (symlink (string-append input-dir "/" basename) |
250 | (string-append output-dir "/" basename)))) | |
251 | (scandir input-dir)) | |
252 | #t))))))))) | |
253 | ||
96b714f5 DC |
254 | (define-public syslinux |
255 | (let ((commit "bb41e935cc83c6242de24d2271e067d76af3585c")) | |
256 | (package | |
257 | (name "syslinux") | |
258 | (version (git-version "6.04-pre" "1" commit)) | |
259 | (source (origin | |
260 | (method git-fetch) | |
261 | (uri (git-reference | |
262 | (url "https://github.com/geneC/syslinux") | |
263 | (commit commit))) | |
264 | (file-name (git-file-name name version)) | |
265 | (sha256 | |
266 | (base32 | |
267 | "0k8dvafd6410kqxf3kyr4y8jzmpmrih6wbjqg6gklak7945yflrc")))) | |
268 | (build-system gnu-build-system) | |
269 | (native-inputs | |
270 | `(("nasm" ,nasm) | |
271 | ("perl" ,perl) | |
272 | ("python-2" ,python-2))) | |
273 | (inputs | |
0b4dbb40 LC |
274 | `(("libuuid" ,util-linux) |
275 | ("mtools" ,mtools))) | |
96b714f5 DC |
276 | (arguments |
277 | `(#:parallel-build? #f | |
278 | #:make-flags | |
279 | (list (string-append "BINDIR=" %output "/bin") | |
280 | (string-append "SBINDIR=" %output "/sbin") | |
281 | (string-append "LIBDIR=" %output "/lib") | |
282 | (string-append "INCDIR=" %output "/include") | |
283 | (string-append "DATADIR=" %output "/share") | |
284 | (string-append "MANDIR=" %output "/share/man") | |
285 | "PERL=perl" | |
286 | "bios") | |
287 | #:phases | |
288 | (modify-phases %standard-phases | |
289 | (add-after 'unpack 'patch-files | |
0b4dbb40 | 290 | (lambda* (#:key inputs #:allow-other-keys) |
96b714f5 DC |
291 | (substitute* (find-files "." "Makefile.*|ppmtolss16") |
292 | (("/bin/pwd") (which "pwd")) | |
293 | (("/bin/echo") (which "echo")) | |
294 | (("/usr/bin/perl") (which "perl"))) | |
0b4dbb40 LC |
295 | (let ((mtools (assoc-ref inputs "mtools"))) |
296 | (substitute* (find-files "." "\\.c$") | |
297 | (("mcopy") | |
298 | (string-append mtools "/bin/mcopy")) | |
299 | (("mattrib") | |
300 | (string-append mtools "/bin/mattrib")))) | |
96b714f5 DC |
301 | #t)) |
302 | (delete 'configure) | |
303 | (add-before 'build 'set-permissions | |
304 | (lambda _ | |
305 | (zero? (system* "chmod" "a+w" "utils/isohybrid.in")))) | |
306 | (replace 'check | |
307 | (lambda _ | |
308 | (setenv "CC" "gcc") | |
309 | (substitute* "tests/unittest/include/unittest/unittest.h" | |
310 | ;; Don't look up headers under /usr. | |
311 | (("/usr/include/") "")) | |
312 | (zero? (system* "make" "unittest"))))))) | |
313 | (home-page "http://www.syslinux.org") | |
314 | (synopsis "Lightweight Linux bootloader") | |
315 | (description "Syslinux is a lightweight Linux bootloader.") | |
316 | (license (list license:gpl2+ | |
317 | license:bsd-3 ; gnu-efi/* | |
318 | license:bsd-4 ; gnu-efi/inc/* gnu-efi/lib/* | |
319 | ;; Also contains: | |
320 | license:expat license:isc license:zlib))))) | |
862e38d5 DC |
321 | |
322 | (define-public dtc | |
323 | (package | |
324 | (name "dtc") | |
d95bb295 | 325 | (version "1.4.6") |
862e38d5 DC |
326 | (source (origin |
327 | (method url-fetch) | |
328 | (uri (string-append | |
3b4efb1f | 329 | "mirror://kernel.org/software/utils/dtc/" |
862e38d5 DC |
330 | "dtc-" version ".tar.xz")) |
331 | (sha256 | |
332 | (base32 | |
d95bb295 | 333 | "0zkvih0fpwvk31aqyyfy9kn13nbi76c21ihax15p6h1wrjzh48rq")))) |
862e38d5 DC |
334 | (build-system gnu-build-system) |
335 | (native-inputs | |
336 | `(("bison" ,bison) | |
12c613b5 EF |
337 | ("flex" ,flex) |
338 | ("swig" ,swig))) | |
339 | (inputs | |
340 | `(("python-2" ,python-2))) | |
862e38d5 DC |
341 | (arguments |
342 | `(#:make-flags | |
343 | (list "CC=gcc" | |
344 | (string-append "PREFIX=" (assoc-ref %outputs "out")) | |
12c613b5 | 345 | (string-append "SETUP_PREFIX=" (assoc-ref %outputs "out")) |
862e38d5 DC |
346 | "INSTALL=install") |
347 | #:phases | |
348 | (modify-phases %standard-phases | |
d95bb295 | 349 | (delete 'configure)))) ; no configure script |
862e38d5 DC |
350 | (home-page "https://www.devicetree.org") |
351 | (synopsis "Compiles device tree source files") | |
352 | (description "@command{dtc} compiles | |
353 | @uref{http://elinux.org/Device_Tree_Usage, device tree source files} to device | |
354 | tree binary files. These are board description files used by Linux and BSD.") | |
355 | (license license:gpl2+))) | |
356 | ||
357 | (define u-boot | |
358 | (package | |
359 | (name "u-boot") | |
336c4a4b | 360 | (version "2018.07") |
862e38d5 DC |
361 | (source (origin |
362 | (method url-fetch) | |
363 | (uri (string-append | |
364 | "ftp://ftp.denx.de/pub/u-boot/" | |
365 | "u-boot-" version ".tar.bz2")) | |
366 | (sha256 | |
367 | (base32 | |
336c4a4b | 368 | "1m7nw64mxflpc6sqvnz2kb5fxfkb4mrpy8b1wi15dcwipj4dy44z")))) |
862e38d5 DC |
369 | (native-inputs |
370 | `(("bc" ,bc) | |
336c4a4b | 371 | ("bison" ,bison) |
53e290df | 372 | ("dtc" ,dtc) |
336c4a4b | 373 | ("flex" ,flex) |
65212c42 | 374 | ("openssl" ,openssl) |
f074f5e8 | 375 | ("python-2" ,python-2) |
65212c42 DM |
376 | ("python2-coverage" ,python2-coverage) |
377 | ("python2-pytest" ,python2-pytest) | |
378 | ("sdl" ,sdl) | |
f074f5e8 | 379 | ("swig" ,swig))) |
862e38d5 DC |
380 | (build-system gnu-build-system) |
381 | (home-page "http://www.denx.de/wiki/U-Boot/") | |
382 | (synopsis "ARM bootloader") | |
383 | (description "U-Boot is a bootloader used mostly for ARM boards. It | |
384 | also initializes the boards (RAM etc).") | |
385 | (license license:gpl2+))) | |
386 | ||
2676628f DM |
387 | (define-public u-boot-tools |
388 | (package | |
389 | (inherit u-boot) | |
390 | (name "u-boot-tools") | |
391 | (arguments | |
65212c42 DM |
392 | `(#:make-flags '("HOSTCC=gcc") |
393 | #:test-target "tests" | |
2676628f DM |
394 | #:phases |
395 | (modify-phases %standard-phases | |
65212c42 DM |
396 | (add-after 'unpack 'patch |
397 | (lambda* (#:key inputs #:allow-other-keys) | |
398 | (substitute* "Makefile" | |
399 | (("/bin/pwd") (which "pwd")) | |
400 | (("/bin/false") (which "false"))) | |
401 | (substitute* "tools/dtoc/fdt_util.py" | |
402 | (("'cc'") "'gcc'")) | |
403 | (substitute* "test/run" | |
404 | ;; Make it easier to find test failures. | |
405 | (("#!/bin/bash") "#!/bin/bash -x") | |
406 | ;; pytest doesn't find it otherwise. | |
407 | (("test/py/tests/test_ofplatdata.py") | |
408 | "tests/test_ofplatdata.py") | |
409 | ;; This test would require git. | |
410 | (("\\./tools/patman/patman") (which "true")) | |
411 | ;; This test would require internet access. | |
412 | (("\\./tools/buildman/buildman") (which "true"))) | |
413 | (substitute* "test/py/tests/test_sandbox_exit.py" | |
414 | (("def test_ctrl_c") | |
415 | "@pytest.mark.skip(reason='Guix has problems with SIGINT') | |
416 | def test_ctrl_c")) | |
417 | (substitute* "tools/binman/binman.py" | |
418 | (("100%") "99%")) ; TODO: Find out why that is needed. | |
419 | #t)) | |
2676628f DM |
420 | (replace 'configure |
421 | (lambda* (#:key make-flags #:allow-other-keys) | |
422 | (call-with-output-file "configs/tools_defconfig" | |
423 | (lambda (port) | |
424 | (display "CONFIG_SYS_TEXT_BASE=0\n" port))) | |
425 | (apply invoke "make" "tools_defconfig" make-flags))) | |
426 | (replace 'build | |
427 | (lambda* (#:key inputs make-flags #:allow-other-keys) | |
9e84a4d6 | 428 | (apply invoke "make" "tools-all" make-flags))) |
2676628f DM |
429 | (replace 'install |
430 | (lambda* (#:key outputs #:allow-other-keys) | |
431 | (let* ((out (assoc-ref outputs "out")) | |
432 | (bin (string-append out "/bin"))) | |
433 | (for-each (lambda (name) | |
434 | (install-file name bin)) | |
435 | '("tools/netconsole" | |
436 | "tools/jtagconsole" | |
437 | "tools/gen_eth_addr" | |
438 | "tools/gen_ethaddr_crc" | |
439 | "tools/img2srec" | |
440 | "tools/mkenvimage" | |
441 | "tools/dumpimage" | |
442 | "tools/mkimage" | |
443 | "tools/proftool" | |
444 | "tools/fdtgrep" | |
10186ee2 DM |
445 | "tools/env/fw_printenv" |
446 | "tools/sunxi-spl-image-builder")) | |
65212c42 DM |
447 | #t))) |
448 | (delete 'check) | |
449 | (add-after 'install 'check | |
450 | (lambda* (#:key make-flags test-target #:allow-other-keys) | |
451 | (apply invoke "make" "mrproper" make-flags) | |
452 | (setenv "SDL_VIDEODRIVER" "dummy") | |
453 | (setenv "PAGER" "cat") | |
454 | (apply invoke "make" test-target make-flags) | |
455 | (symlink "build-sandbox_spl" "sandbox") | |
456 | (invoke "test/image/test-imagetools.sh")))))) | |
2676628f DM |
457 | (description "U-Boot is a bootloader used mostly for ARM boards. It |
458 | also initializes the boards (RAM etc). This package provides its | |
459 | board-independent tools."))) | |
460 | ||
4ce4fc50 | 461 | (define-public (make-u-boot-package board triplet) |
862e38d5 | 462 | "Returns a u-boot package for BOARD cross-compiled for TRIPLET." |
2ac42fe5 MO |
463 | (let ((same-arch? (if (string-prefix? (%current-system) |
464 | (gnu-triplet->nix-system triplet)) | |
3bfee8ff EF |
465 | `#t |
466 | `#f))) | |
467 | (package | |
468 | (inherit u-boot) | |
df8a9096 DM |
469 | (name (string-append "u-boot-" |
470 | (string-replace-substring (string-downcase board) | |
471 | "_" "-"))) | |
3bfee8ff EF |
472 | (native-inputs |
473 | `(,@(if (not same-arch?) | |
f074f5e8 | 474 | `(("cross-gcc" ,(cross-gcc triplet #:xgcc gcc-7)) |
3bfee8ff | 475 | ("cross-binutils" ,(cross-binutils triplet))) |
a1f53127 | 476 | `(("gcc-7" ,gcc-7))) |
3bfee8ff EF |
477 | ,@(package-native-inputs u-boot))) |
478 | (arguments | |
37297674 EF |
479 | `(#:modules ((ice-9 ftw) |
480 | (srfi srfi-1) | |
481 | (guix build utils) | |
482 | (guix build gnu-build-system)) | |
3bfee8ff EF |
483 | #:test-target "test" |
484 | #:make-flags | |
485 | (list "HOSTCC=gcc" | |
486 | ,@(if (not same-arch?) | |
487 | `((string-append "CROSS_COMPILE=" ,triplet "-")) | |
488 | '())) | |
489 | #:phases | |
490 | (modify-phases %standard-phases | |
491 | (replace 'configure | |
492 | (lambda* (#:key outputs make-flags #:allow-other-keys) | |
493 | (let ((config-name (string-append ,board "_defconfig"))) | |
494 | (if (file-exists? (string-append "configs/" config-name)) | |
495 | (zero? (apply system* "make" `(,@make-flags ,config-name))) | |
496 | (begin | |
ac30d18c DM |
497 | (display "Invalid board name. Valid board names are:" |
498 | (current-error-port)) | |
30ef146c DM |
499 | (let ((suffix-len (string-length "_defconfig")) |
500 | (entries (scandir "configs"))) | |
501 | (for-each (lambda (file-name) | |
502 | (when (string-suffix? "_defconfig" file-name) | |
ac30d18c | 503 | (format (current-error-port) |
30ef146c DM |
504 | "- ~A\n" |
505 | (string-drop-right file-name | |
506 | suffix-len)))) | |
ee3c8fbe | 507 | (sort entries string-ci<))) |
bdd235b3 | 508 | (error "Invalid boardname ~s." ,board)))))) |
3bfee8ff | 509 | (replace 'install |
9b94ced4 | 510 | (lambda* (#:key outputs #:allow-other-keys) |
3bfee8ff EF |
511 | (let* ((out (assoc-ref outputs "out")) |
512 | (libexec (string-append out "/libexec")) | |
dd208b93 | 513 | (uboot-files (append |
a9446dde DM |
514 | (remove |
515 | ;; Those would not be reproducible | |
516 | ;; because of the randomness used | |
517 | ;; to produce them. | |
518 | ;; It's expected that the user will | |
519 | ;; use u-boot-tools to generate them | |
520 | ;; instead. | |
521 | (lambda (name) | |
522 | (string-suffix? | |
523 | "sunxi-spl-with-ecc.bin" | |
524 | name)) | |
525 | (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$")) | |
fd0b21d5 | 526 | (find-files "." "^(MLO|SPL)$")))) |
3bfee8ff | 527 | (mkdir-p libexec) |
a32f9b59 | 528 | (install-file ".config" libexec) |
0fcfed39 DM |
529 | ;; Useful for "qemu -kernel". |
530 | (install-file "u-boot" libexec) | |
3bfee8ff EF |
531 | (for-each |
532 | (lambda (file) | |
533 | (let ((target-file (string-append libexec "/" file))) | |
534 | (mkdir-p (dirname target-file)) | |
535 | (copy-file file target-file))) | |
d1af9a8c DM |
536 | uboot-files) |
537 | #t))))))))) | |
862e38d5 DC |
538 | |
539 | (define-public u-boot-vexpress | |
540 | (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf")) | |
541 | ||
542 | (define-public u-boot-malta | |
543 | (make-u-boot-package "malta" "mips64el-linux-gnuabi64")) | |
544 | ||
545 | (define-public u-boot-beagle-bone-black | |
546 | (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf")) | |
4adeb3f6 | 547 | |
29be6cfb EF |
548 | (define-public u-boot-pine64-plus |
549 | (let ((base (make-u-boot-package "pine64_plus" "aarch64-linux-gnu"))) | |
550 | (package | |
551 | (inherit base) | |
552 | (arguments | |
553 | (substitute-keyword-arguments (package-arguments base) | |
554 | ((#:phases phases) | |
555 | `(modify-phases ,phases | |
556 | (add-after 'unpack 'set-environment | |
557 | (lambda* (#:key inputs #:allow-other-keys) | |
558 | (let ((bl31 (string-append (assoc-ref inputs "firmware") | |
559 | "/bl31.bin"))) | |
560 | (setenv "BL31" bl31) | |
35e427d1 DM |
561 | ;; This is necessary when we're using the bundled dtc. |
562 | ;(setenv "PATH" (string-append (getenv "PATH") ":" | |
563 | ; "scripts/dtc")) | |
564 | ) | |
29be6cfb EF |
565 | #t)))))) |
566 | (native-inputs | |
567 | `(("firmware" ,arm-trusted-firmware-pine64-plus) | |
568 | ,@(package-native-inputs base)))))) | |
569 | ||
30aeb846 DM |
570 | (define-public u-boot-banana-pi-m2-ultra |
571 | (make-u-boot-package "Bananapi_M2_Ultra" "arm-linux-gnueabihf")) | |
572 | ||
c55c6985 DM |
573 | (define-public u-boot-a20-olinuxino-lime |
574 | (make-u-boot-package "A20-OLinuXino-Lime" "arm-linux-gnueabihf")) | |
575 | ||
4b9e9abb DM |
576 | (define-public u-boot-a20-olinuxino-lime2 |
577 | (make-u-boot-package "A20-OLinuXino-Lime2" "arm-linux-gnueabihf")) | |
578 | ||
a7bb327e DM |
579 | (define-public u-boot-a20-olinuxino-micro |
580 | (make-u-boot-package "A20-OLinuXino_MICRO" "arm-linux-gnueabihf")) | |
581 | ||
84ee3378 DM |
582 | (define-public u-boot-nintendo-nes-classic-edition |
583 | (make-u-boot-package "Nintendo_NES_Classic_Edition" "arm-linux-gnueabihf")) | |
584 | ||
95a3422e VC |
585 | (define-public u-boot-wandboard |
586 | (make-u-boot-package "wandboard" "arm-linux-gnueabihf")) | |
587 | ||
adc61d72 VC |
588 | (define-public u-boot-mx6cuboxi |
589 | (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf")) | |
590 | ||
1b960787 VC |
591 | (define-public u-boot-novena |
592 | (make-u-boot-package "novena" "arm-linux-gnueabihf")) | |
593 | ||
dd4fe0c2 DM |
594 | (define-public u-boot-cubieboard |
595 | (make-u-boot-package "Cubieboard" "arm-linux-gnueabihf")) | |
596 | ||
a7d5ce94 JL |
597 | (define-public u-boot-cubietruck |
598 | (make-u-boot-package "Cubietruck" "arm-linux-gnueabihf")) | |
599 | ||
6fe16577 VC |
600 | (define-public u-boot-puma-rk3399 |
601 | (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu"))) | |
602 | (package | |
603 | (inherit base) | |
604 | (arguments | |
605 | (substitute-keyword-arguments (package-arguments base) | |
606 | ((#:phases phases) | |
607 | `(modify-phases ,phases | |
608 | (add-after 'unpack 'set-environment | |
609 | (lambda* (#:key inputs #:allow-other-keys) | |
610 | ;; Need to copy the firmware into u-boot build | |
611 | ;; directory. | |
612 | (copy-file (string-append (assoc-ref inputs "firmware") | |
613 | "/bl31.bin") "bl31-rk3399.bin") | |
614 | (copy-file (string-append (assoc-ref inputs "firmware-m0") | |
615 | "/rk3399m0.bin") "rk3399m0.bin") | |
616 | #t)) | |
617 | (add-after 'build 'build-itb | |
618 | (lambda* (#:key make-flags #:allow-other-keys) | |
619 | ;; The u-boot.itb is not built by default. | |
620 | (apply invoke "make" `(,@make-flags ,"u-boot.itb")))) | |
621 | (add-after 'build-itb 'build-rksd | |
622 | (lambda* (#:key inputs #:allow-other-keys) | |
623 | ;; Build Rockchip SD card images. | |
624 | (invoke "./tools/mkimage" "-T" "rksd" "-n" "rk3399" "-d" | |
625 | "spl/u-boot-spl.bin" "u-boot-spl.rksd"))))))) | |
626 | (native-inputs | |
627 | `(("firmware" ,arm-trusted-firmware-puma-rk3399) | |
628 | ("firmware-m0" ,rk3399-cortex-m0) | |
629 | ,@(package-native-inputs base)))))) | |
630 | ||
a60f1319 MB |
631 | (define-public vboot-utils |
632 | (package | |
633 | (name "vboot-utils") | |
634 | (version "R63-10032.B") | |
635 | (source (origin | |
636 | ;; XXX: Snapshots are available but changes timestamps every download. | |
637 | (method git-fetch) | |
638 | (uri (git-reference | |
639 | (url (string-append "https://chromium.googlesource.com" | |
640 | "/chromiumos/platform/vboot_reference")) | |
641 | (commit (string-append "release-" version)))) | |
642 | (file-name (string-append name "-" version "-checkout")) | |
643 | (sha256 | |
644 | (base32 | |
645 | "0h0m3l69vp9dr6xrs1p6y7ilkq3jq8jraw2z20kqfv7lvc9l1lxj")))) | |
646 | (build-system gnu-build-system) | |
647 | (arguments | |
648 | `(#:make-flags (list "CC=gcc" | |
649 | (string-append "DESTDIR=" (assoc-ref %outputs "out"))) | |
650 | #:phases (modify-phases %standard-phases | |
651 | (add-after 'unpack 'patch-hard-coded-paths | |
652 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
653 | (let ((coreutils (assoc-ref inputs "coreutils")) | |
654 | (diffutils (assoc-ref inputs "diffutils"))) | |
655 | (substitute* "futility/misc.c" | |
656 | (("/bin/cp") (string-append coreutils "/bin/cp"))) | |
657 | (substitute* "tests/bitmaps/TestBmpBlock.py" | |
658 | (("/usr/bin/cmp") (string-append diffutils "/bin/cmp"))) | |
659 | (substitute* "vboot_host.pc.in" | |
660 | (("prefix=/usr") | |
661 | (string-append "prefix=" (assoc-ref outputs "out")))) | |
662 | #t))) | |
663 | (delete 'configure) | |
664 | (add-before 'check 'patch-tests | |
665 | (lambda _ | |
666 | ;; These tests compare diffs against known-good values. | |
667 | ;; Patch the paths to match those in the build container. | |
668 | (substitute* (find-files "tests/futility/expect_output") | |
669 | (("/mnt/host/source/src/platform/vboot_reference") | |
670 | (string-append "/tmp/guix-build-" ,name "-" ,version | |
671 | ".drv-0/source"))) | |
672 | ;; Tests require write permissions to many of these files. | |
673 | (for-each make-file-writable (find-files "tests/futility")) | |
674 | #t))) | |
675 | #:test-target "runtests")) | |
676 | (native-inputs | |
677 | `(("pkg-config" ,pkg-config) | |
678 | ||
679 | ;; For tests. | |
680 | ("diffutils" ,diffutils) | |
681 | ("python@2" ,python-2))) | |
682 | (inputs | |
683 | `(("coreutils" ,coreutils) | |
684 | ("libyaml" ,libyaml) | |
685 | ("openssl" ,openssl) | |
686 | ("openssl:static" ,openssl "static") | |
687 | ("util-linux" ,util-linux))) | |
688 | (home-page | |
689 | "https://dev.chromium.org/chromium-os/chromiumos-design-docs/verified-boot") | |
690 | (synopsis "ChromiumOS verified boot utilities") | |
691 | (description | |
692 | "vboot-utils is a collection of tools to facilitate booting of | |
693 | Chrome-branded devices. This includes the @command{cgpt} partitioning | |
694 | program, the @command{futility} and @command{crossystem} firmware management | |
695 | tools, and more.") | |
696 | (license license:bsd-3))) | |
697 | ||
aa90375a AI |
698 | (define-public os-prober |
699 | (package | |
700 | (name "os-prober") | |
701 | (version "1.76") | |
702 | (source | |
703 | (origin | |
704 | (method url-fetch) | |
705 | (uri (string-append "mirror://debian/pool/main/o/os-prober/os-prober_" | |
706 | version ".tar.xz")) | |
707 | (sha256 | |
708 | (base32 | |
709 | "1vb45i76bqivlghrq7m3n07qfmmq4wxrkplqx8gywj011rhq19fk")))) | |
710 | (build-system gnu-build-system) | |
711 | (arguments | |
712 | `(#:modules ((guix build gnu-build-system) | |
713 | (guix build utils) | |
714 | (ice-9 regex) ; for string-match | |
715 | (srfi srfi-26)) ; for cut | |
716 | #:make-flags (list "CC=gcc") | |
717 | #:tests? #f ; no tests | |
718 | #:phases | |
719 | (modify-phases %standard-phases | |
720 | (replace 'configure | |
721 | (lambda* (#:key outputs #:allow-other-keys) | |
722 | (substitute* (find-files ".") | |
723 | (("/usr") (assoc-ref outputs "out"))) | |
724 | (substitute* (find-files "." "50mounted-tests$") | |
725 | (("mkdir") "mkdir -p")) | |
726 | #t)) | |
727 | (replace 'install | |
728 | (lambda* (#:key outputs #:allow-other-keys) | |
729 | (define (find-files-non-recursive directory) | |
730 | (find-files directory | |
731 | (lambda (file stat) | |
732 | (string-match (string-append "^" directory "/[^/]*$") | |
733 | file)) | |
734 | #:directories? #t)) | |
735 | ||
736 | (let* ((out (assoc-ref outputs "out")) | |
737 | (bin (string-append out "/bin")) | |
738 | (lib (string-append out "/lib")) | |
739 | (share (string-append out "/share"))) | |
740 | (for-each (cut install-file <> bin) | |
741 | (list "linux-boot-prober" "os-prober")) | |
742 | (install-file "newns" (string-append lib "/os-prober")) | |
743 | (install-file "common.sh" (string-append share "/os-prober")) | |
744 | (install-file "os-probes/mounted/powerpc/20macosx" | |
745 | (string-append lib "/os-probes/mounted")) | |
746 | (for-each | |
747 | (lambda (directory) | |
748 | (for-each | |
749 | (lambda (file) | |
750 | (let ((destination (string-append lib "/" directory | |
751 | "/" (basename file)))) | |
752 | (mkdir-p (dirname destination)) | |
753 | (copy-recursively file destination))) | |
754 | (append (find-files-non-recursive (string-append directory "/common")) | |
755 | (find-files-non-recursive (string-append directory "/x86"))))) | |
756 | (list "os-probes" "os-probes/mounted" "os-probes/init" | |
757 | "linux-boot-probes" "linux-boot-probes/mounted")) | |
758 | #t)))))) | |
759 | (home-page "https://joeyh.name/code/os-prober") | |
760 | (synopsis "Detect other operating systems") | |
761 | (description "os-prober probes disks on the system for other operating | |
762 | systems so that they can be added to the bootloader. It also works out how to | |
763 | boot existing GNU/Linux systems and detects what distribution is installed in | |
764 | order to add a suitable bootloader menu entry.") | |
765 | (license license:gpl2+))) |