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