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