gnu: htseq: Use PyPI URI.
[jackhill/guix/guix.git] / gnu / packages / bootloaders.scm
CommitLineData
65d8b777 1;;; GNU Guix --- Functional package management for GNU
ef753a1a 2;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
04e0eac1 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
f0150f87 4;;; Copyright © 2015 Leo Famulari <leo@famulari.name>
4c726001 5;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
d846834f 6;;; Copyright © 2016, 2017 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>
4adeb3f6 9;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
65d8b777
LC
10;;;
11;;; This file is part of GNU Guix.
12;;;
13;;; GNU Guix is free software; you can redistribute it and/or modify it
14;;; under the terms of the GNU General Public License as published by
15;;; the Free Software Foundation; either version 3 of the License, or (at
16;;; your option) any later version.
17;;;
18;;; GNU Guix is distributed in the hope that it will be useful, but
19;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;;; GNU General Public License for more details.
22;;;
23;;; You should have received a copy of the GNU General Public License
24;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
862e38d5 26(define-module (gnu packages bootloaders)
65d8b777 27 #:use-module (gnu packages)
862e38d5
DC
28 #:use-module (gnu packages admin)
29 #:use-module ((gnu packages algebra) #:select (bc))
30 #:use-module (gnu packages assembly)
7febe3a2 31 #:use-module (gnu packages disk)
65d8b777 32 #:use-module (gnu packages bison)
862e38d5
DC
33 #:use-module (gnu packages cdrom)
34 #:use-module (gnu packages cross-base)
35 #:use-module (gnu packages disk)
36 #:use-module (gnu packages flex)
a86177d6 37 #:use-module (gnu packages fontutils)
862e38d5 38 #:use-module (gnu packages gettext)
65d8b777 39 #:use-module (gnu packages linux)
862e38d5 40 #:use-module (gnu packages man)
444f9dcc 41 #:use-module (gnu packages mtools)
862e38d5 42 #:use-module (gnu packages ncurses)
96b714f5
DC
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages python)
58301666 45 #:use-module (gnu packages texinfo)
59132b80 46 #:use-module (gnu packages virtualization)
862e38d5
DC
47 #:use-module (guix build-system gnu)
48 #:use-module (guix download)
49 #:use-module (guix git-download)
50 #:use-module ((guix licenses) #:prefix license:)
51 #:use-module (guix packages)
52 #:use-module (guix utils))
65d8b777 53
9b24c768
LC
54(define unifont
55 ;; GNU Unifont, <http://gnu.org/s/unifont>.
56 ;; GRUB needs it for its graphical terminal, gfxterm.
57 (origin
58 (method url-fetch)
59 (uri
60 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
61 (sha256
62 (base32
63 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
64
65d8b777
LC
65(define-public grub
66 (package
67 (name "grub")
3586a3e9 68 (version "2.02")
65d8b777
LC
69 (source (origin
70 (method url-fetch)
3586a3e9 71 (uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz"))
65d8b777
LC
72 (sha256
73 (base32
3586a3e9 74 "03vvdfhdmf16121v7xs8is2krwnv15wpkhkf16a4yf8nsfc3f2w1"))))
65d8b777
LC
75 (build-system gnu-build-system)
76 (arguments
d846834f 77 '(#:phases (modify-phases %standard-phases
358db004 78 (add-after 'unpack 'patch-stuff
04e0eac1
MW
79 (lambda* (#:key inputs #:allow-other-keys)
80 (substitute* "grub-core/Makefile.in"
81 (("/bin/sh") (which "sh")))
65d8b777 82
358db004
LC
83 ;; Give the absolute file name of 'mdadm', used to
84 ;; determine the root file system when it's a RAID
85 ;; device. Failing to do that, 'grub-probe' silently
86 ;; fails if 'mdadm' is not in $PATH.
87 (substitute* "grub-core/osdep/linux/getroot.c"
88 (("argv\\[0\\] = \"mdadm\"")
89 (string-append "argv[0] = \""
90 (assoc-ref inputs "mdadm")
91 "/sbin/mdadm\"")))
92
04e0eac1
MW
93 ;; Make the font visible.
94 (copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz")
95 (system* "gunzip" "unifont.bdf.gz")
23a53a95
LF
96 #t))
97 (add-before 'check 'disable-flaky-test
98 (lambda _
99 ;; This test is unreliable. For more information, see:
100 ;; <https://bugs.gnu.org/26936>.
101 (substitute* "Makefile.in"
102 (("grub_cmd_date grub_cmd_set_date grub_cmd_sleep")
103 "grub_cmd_date grub_cmd_sleep"))
104 #t)))))
65d8b777 105 (inputs
10da75df
LC
106 `(("gettext" ,gettext-minimal)
107
108 ;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and
109 ;; 'grub-install' to recognize mapped devices (LUKS, etc.)
110 ("lvm2" ,lvm2)
111
112 ;; Depend on mdadm, which is invoked by 'grub-probe' and 'grub-install'
113 ;; to determine whether the root file system is RAID.
358db004 114 ("mdadm" ,mdadm)
10da75df 115
65d8b777
LC
116 ("freetype" ,freetype)
117 ;; ("libusb" ,libusb)
04e0eac1 118 ;; ("fuse" ,fuse)
01eafd38 119 ("ncurses" ,ncurses)))
65d8b777 120 (native-inputs
9b24c768
LC
121 `(("unifont" ,unifont)
122 ("bison" ,bison)
af50d389
LF
123 ;; Due to a bug in flex >= 2.6.2, GRUB must be built with an older flex:
124 ;; <http://lists.gnu.org/archive/html/grub-devel/2017-02/msg00133.html>
125 ;; TODO Try building with flex > 2.6.3.
126 ("flex" ,flex-2.6.1)
58301666
MW
127 ("texinfo" ,texinfo)
128 ("help2man" ,help2man)
65d8b777
LC
129
130 ;; Dependencies for the test suite. The "real" QEMU is needed here,
131 ;; because several targets are used.
7febe3a2 132 ("parted" ,parted)
7d8f7ab9 133 ("qemu" ,qemu-minimal)
65d8b777 134 ("xorriso" ,xorriso)))
175b259c 135 (home-page "https://www.gnu.org/software/grub/")
79c311b8 136 (synopsis "GRand Unified Boot loader")
65d8b777 137 (description
a22dc0c4 138 "GRUB is a multiboot bootloader. It is used for initially loading the
35b9e423 139kernel of an operating system and then transferring control to it. The kernel
c5779c93 140then goes on to load the rest of the operating system. As a multiboot
574e86f9
LC
141bootloader, GRUB handles the presence of multiple operating systems installed
142on the same computer; upon booting the computer, the user is presented with a
a22dc0c4 143menu to select one of the installed operating systems.")
3f73aa1a 144 (license license:gpl3+)
99effc8f 145 (properties '((cpe-name . "grub2")))))
acb5f7c3
MB
146
147(define-public grub-efi
148 (package
149 (inherit grub)
150 (name "grub-efi")
151 (synopsis "GRand Unified Boot loader (UEFI version)")
152 (inputs
153 `(("efibootmgr" ,efibootmgr)
444f9dcc 154 ("mtools", mtools)
acb5f7c3
MB
155 ,@(package-inputs grub)))
156 (arguments
157 `(;; TODO: Tests need a UEFI firmware for qemu. There is one at
158 ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
159 ;; Search for 'OVMF' in "tests/util/grub-shell.in".
160 #:tests? #f
161 ,@(substitute-keyword-arguments (package-arguments grub)
ef753a1a
LC
162 ((#:configure-flags flags ''())
163 `(cons "--with-platform=efi" ,flags))
acb5f7c3
MB
164 ((#:phases phases)
165 `(modify-phases ,phases
166 (add-after 'patch-stuff 'use-absolute-efibootmgr-path
167 (lambda* (#:key inputs #:allow-other-keys)
168 (substitute* "grub-core/osdep/unix/platform.c"
169 (("efibootmgr")
170 (string-append (assoc-ref inputs "efibootmgr")
171 "/sbin/efibootmgr")))
444f9dcc
DM
172 #t))
173 (add-after 'patch-stuff 'use-absolute-mtools-path
174 (lambda* (#:key inputs #:allow-other-keys)
175 (let ((mtools (assoc-ref inputs "mtools")))
176 (substitute* "util/grub-mkrescue.c"
177 (("\"mformat\"")
178 (string-append "\"" mtools
179 "/bin/mformat\"")))
180 (substitute* "util/grub-mkrescue.c"
181 (("\"mcopy\"")
182 (string-append "\"" mtools
183 "/bin/mcopy\"")))
184 #t))))))))))
96b714f5
DC
185
186(define-public syslinux
187 (let ((commit "bb41e935cc83c6242de24d2271e067d76af3585c"))
188 (package
189 (name "syslinux")
190 (version (git-version "6.04-pre" "1" commit))
191 (source (origin
192 (method git-fetch)
193 (uri (git-reference
194 (url "https://github.com/geneC/syslinux")
195 (commit commit)))
196 (file-name (git-file-name name version))
197 (sha256
198 (base32
199 "0k8dvafd6410kqxf3kyr4y8jzmpmrih6wbjqg6gklak7945yflrc"))))
200 (build-system gnu-build-system)
201 (native-inputs
202 `(("nasm" ,nasm)
203 ("perl" ,perl)
204 ("python-2" ,python-2)))
205 (inputs
206 `(("libuuid" ,util-linux)))
207 (arguments
208 `(#:parallel-build? #f
209 #:make-flags
210 (list (string-append "BINDIR=" %output "/bin")
211 (string-append "SBINDIR=" %output "/sbin")
212 (string-append "LIBDIR=" %output "/lib")
213 (string-append "INCDIR=" %output "/include")
214 (string-append "DATADIR=" %output "/share")
215 (string-append "MANDIR=" %output "/share/man")
216 "PERL=perl"
217 "bios")
218 #:phases
219 (modify-phases %standard-phases
220 (add-after 'unpack 'patch-files
221 (lambda _
222 (substitute* (find-files "." "Makefile.*|ppmtolss16")
223 (("/bin/pwd") (which "pwd"))
224 (("/bin/echo") (which "echo"))
225 (("/usr/bin/perl") (which "perl")))
226 #t))
227 (delete 'configure)
228 (add-before 'build 'set-permissions
229 (lambda _
230 (zero? (system* "chmod" "a+w" "utils/isohybrid.in"))))
231 (replace 'check
232 (lambda _
233 (setenv "CC" "gcc")
234 (substitute* "tests/unittest/include/unittest/unittest.h"
235 ;; Don't look up headers under /usr.
236 (("/usr/include/") ""))
237 (zero? (system* "make" "unittest")))))))
238 (home-page "http://www.syslinux.org")
239 (synopsis "Lightweight Linux bootloader")
240 (description "Syslinux is a lightweight Linux bootloader.")
241 (license (list license:gpl2+
242 license:bsd-3 ; gnu-efi/*
243 license:bsd-4 ; gnu-efi/inc/* gnu-efi/lib/*
244 ;; Also contains:
245 license:expat license:isc license:zlib)))))
862e38d5
DC
246
247(define-public dtc
248 (package
249 (name "dtc")
3b4efb1f 250 (version "1.4.4")
862e38d5
DC
251 (source (origin
252 (method url-fetch)
253 (uri (string-append
3b4efb1f 254 "mirror://kernel.org/software/utils/dtc/"
862e38d5
DC
255 "dtc-" version ".tar.xz"))
256 (sha256
257 (base32
3b4efb1f 258 "1yygyvnnpdh241hl90n9p3kxcdvk3jxmsr4ndb961c8mq3ak21s7"))))
862e38d5
DC
259 (build-system gnu-build-system)
260 (native-inputs
261 `(("bison" ,bison)
8be563a5 262 ("flex" ,flex-2.6.1))) ; A bug in flex prevents building with flex-2.6.3.
862e38d5
DC
263 (arguments
264 `(#:make-flags
265 (list "CC=gcc"
266 (string-append "PREFIX=" (assoc-ref %outputs "out"))
267 "INSTALL=install")
268 #:phases
269 (modify-phases %standard-phases
270 (delete 'configure))))
271 (home-page "https://www.devicetree.org")
272 (synopsis "Compiles device tree source files")
273 (description "@command{dtc} compiles
274@uref{http://elinux.org/Device_Tree_Usage, device tree source files} to device
275tree binary files. These are board description files used by Linux and BSD.")
276 (license license:gpl2+)))
277
278(define u-boot
279 (package
280 (name "u-boot")
13136283 281 (version "2017.07")
862e38d5
DC
282 (source (origin
283 (method url-fetch)
284 (uri (string-append
285 "ftp://ftp.denx.de/pub/u-boot/"
286 "u-boot-" version ".tar.bz2"))
287 (sha256
288 (base32
13136283 289 "1zzywk0fgngm1mfnhkp8d0v57rs51zr1y6rp4p03i6nbibfbyx2k"))))
862e38d5
DC
290 (native-inputs
291 `(("bc" ,bc)
292 ("dtc" ,dtc)
293 ("python-2" ,python-2)))
294 (build-system gnu-build-system)
295 (home-page "http://www.denx.de/wiki/U-Boot/")
296 (synopsis "ARM bootloader")
297 (description "U-Boot is a bootloader used mostly for ARM boards. It
298also initializes the boards (RAM etc).")
299 (license license:gpl2+)))
300
301(define (make-u-boot-package board triplet)
302 "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
303 (package
304 (inherit u-boot)
305 (name (string-append "u-boot-" (string-downcase board)))
306 (native-inputs
307 `(("cross-gcc" ,(cross-gcc triplet))
308 ("cross-binutils" ,(cross-binutils triplet))
309 ,@(package-native-inputs u-boot)))
310 (arguments
311 `(#:modules ((ice-9 ftw) (guix build utils) (guix build gnu-build-system))
312 #:test-target "test"
313 #:make-flags
314 (list "HOSTCC=gcc" (string-append "CROSS_COMPILE=" ,triplet "-"))
315 #:phases
316 (modify-phases %standard-phases
317 (replace 'configure
318 (lambda* (#:key outputs make-flags #:allow-other-keys)
319 (let ((config-name (string-append ,board "_defconfig")))
320 (if (file-exists? (string-append "configs/" config-name))
321 (zero? (apply system* "make" `(,@make-flags ,config-name)))
322 (begin
323 (display "Invalid board name. Valid board names are:")
324 (let ((suffix-len (string-length "_defconfig")))
325 (scandir "configs"
326 (lambda (file-name)
327 (when (string-suffix? "_defconfig" file-name)
328 (format #t
329 "- ~A\n"
330 (string-drop-right file-name
331 suffix-len))))))
332 #f)))))
333 (replace 'install
334 (lambda* (#:key outputs make-flags #:allow-other-keys)
335 (let* ((out (assoc-ref outputs "out"))
336 (libexec (string-append out "/libexec"))
337 (uboot-files (find-files "." ".*\\.(bin|efi|spl)$")))
338 (mkdir-p libexec)
339 (for-each
340 (lambda (file)
341 (let ((target-file (string-append libexec "/" file)))
342 (mkdir-p (dirname target-file))
343 (copy-file file target-file)))
344 uboot-files)))))))))
345
346(define-public u-boot-vexpress
347 (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
348
349(define-public u-boot-malta
350 (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
351
352(define-public u-boot-beagle-bone-black
353 (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))
4adeb3f6
EF
354
355(define-public u-boot-odroid-c2
356 (make-u-boot-package "odroid-c2" "aarch64-linux-gnu"))