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