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