1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Leo Famulari <leo@famulari.name>
5 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;; Copyright © 2016, 2017 Marius Bakke <mbakke@fastmail.com>
7 ;;; Copyright © 2016, 2017 Danny Milosavljevic <dannym@scratchpost.org>
8 ;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
10 ;;; This file is part of GNU Guix.
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.
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.
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/>.
25 (define-module (gnu packages bootloaders)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages admin)
28 #:use-module ((gnu packages algebra) #:select (bc))
29 #:use-module (gnu packages assembly)
30 #:use-module (gnu packages flex)
31 #:use-module (gnu packages disk)
32 #:use-module (gnu packages bison)
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)
37 #:use-module (gnu packages fontutils)
38 #:use-module (gnu packages gettext)
39 #:use-module (gnu packages linux)
40 #:use-module (gnu packages man)
41 #:use-module (gnu packages ncurses)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages qemu)
45 #:use-module (gnu packages texinfo)
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))
54 ;; GNU Unifont, <http://gnu.org/s/unifont>.
55 ;; GRUB needs it for its graphical terminal, gfxterm.
59 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
62 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
71 "ftp://alpha.gnu.org/gnu/grub/grub-"
74 (file-name (string-append name "-" version ".tar.xz"))
77 "0y02v19x9sb5jvj740f604vvi5j1rx8pily1jk0l64bdp7lkjlj4"))))
78 (build-system gnu-build-system)
80 '(#:phases (modify-phases %standard-phases
81 (add-after 'unpack 'patch-stuff
82 (lambda* (#:key inputs #:allow-other-keys)
83 (substitute* "grub-core/Makefile.in"
84 (("/bin/sh") (which "sh")))
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")
96 ;; Make the font visible.
97 (copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz")
98 (system* "gunzip" "unifont.bdf.gz")
101 `(("gettext" ,gettext-minimal)
103 ;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and
104 ;; 'grub-install' to recognize mapped devices (LUKS, etc.)
107 ;; Depend on mdadm, which is invoked by 'grub-probe' and 'grub-install'
108 ;; to determine whether the root file system is RAID.
111 ("freetype" ,freetype)
112 ;; ("libusb" ,libusb)
114 ("ncurses" ,ncurses)))
116 `(("unifont" ,unifont)
120 ("help2man" ,help2man)
122 ;; Dependencies for the test suite. The "real" QEMU is needed here,
123 ;; because several targets are used.
125 ("qemu" ,qemu-minimal)
126 ("xorriso" ,xorriso)))
127 (home-page "https://www.gnu.org/software/grub/")
128 (synopsis "GRand Unified Boot loader")
130 "GRUB is a multiboot bootloader. It is used for initially loading the
131 kernel of an operating system and then transferring control to it. The kernel
132 then goes on to load the rest of the operating system. As a multiboot
133 bootloader, GRUB handles the presence of multiple operating systems installed
134 on the same computer; upon booting the computer, the user is presented with a
135 menu to select one of the installed operating systems.")
136 (license license:gpl3+)
137 (properties '((cpe-name . "grub2")))))
139 (define-public grub-efi
143 (synopsis "GRand Unified Boot loader (UEFI version)")
145 `(("efibootmgr" ,efibootmgr)
146 ,@(package-inputs grub)))
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".
152 ,@(substitute-keyword-arguments (package-arguments grub)
153 ((#:configure-flags flags ''())
154 `(cons "--with-platform=efi" ,flags))
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"
161 (string-append (assoc-ref inputs "efibootmgr")
162 "/sbin/efibootmgr")))
165 (define-public syslinux
166 (let ((commit "bb41e935cc83c6242de24d2271e067d76af3585c"))
169 (version (git-version "6.04-pre" "1" commit))
173 (url "https://github.com/geneC/syslinux")
175 (file-name (git-file-name name version))
178 "0k8dvafd6410kqxf3kyr4y8jzmpmrih6wbjqg6gklak7945yflrc"))))
179 (build-system gnu-build-system)
183 ("python-2" ,python-2)))
185 `(("libuuid" ,util-linux)))
187 `(#:parallel-build? #f
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")
198 (modify-phases %standard-phases
199 (add-after 'unpack 'patch-files
201 (substitute* (find-files "." "Makefile.*|ppmtolss16")
202 (("/bin/pwd") (which "pwd"))
203 (("/bin/echo") (which "echo"))
204 (("/usr/bin/perl") (which "perl")))
207 (add-before 'build 'set-permissions
209 (zero? (system* "chmod" "a+w" "utils/isohybrid.in"))))
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/*
224 license:expat license:isc license:zlib)))))
233 "mirror://kernel.org/software/utils/dtc/"
234 "dtc-" version ".tar.xz"))
237 "1yygyvnnpdh241hl90n9p3kxcdvk3jxmsr4ndb961c8mq3ak21s7"))))
238 (build-system gnu-build-system)
245 (string-append "PREFIX=" (assoc-ref %outputs "out"))
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
254 tree binary files. These are board description files used by Linux and BSD.")
255 (license license:gpl2+)))
264 "ftp://ftp.denx.de/pub/u-boot/"
265 "u-boot-" version ".tar.bz2"))
268 "0gqihplap05dlpwdb971wsqyv01nz2vabwq5g5649gr5jczsyjzm"))))
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
277 also initializes the boards (RAM etc).")
278 (license license:gpl2+)))
280 (define (make-u-boot-package board triplet)
281 "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
284 (name (string-append "u-boot-" (string-downcase board)))
286 `(("cross-gcc" ,(cross-gcc triplet))
287 ("cross-binutils" ,(cross-binutils triplet))
288 ,@(package-native-inputs u-boot)))
290 `(#:modules ((ice-9 ftw) (guix build utils) (guix build gnu-build-system))
293 (list "HOSTCC=gcc" (string-append "CROSS_COMPILE=" ,triplet "-"))
295 (modify-phases %standard-phases
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)))
302 (display "Invalid board name. Valid board names are:")
303 (let ((suffix-len (string-length "_defconfig")))
306 (when (string-suffix? "_defconfig" file-name)
309 (string-drop-right file-name
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)$")))
320 (let ((target-file (string-append libexec "/" file)))
321 (mkdir-p (dirname target-file))
322 (copy-file file target-file)))
325 (define-public u-boot-vexpress
326 (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
328 (define-public u-boot-malta
329 (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
331 (define-public u-boot-beagle-bone-black
332 (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))