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