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