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 disk)
31 #:use-module (gnu packages bison)
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)
36 #:use-module (gnu packages fontutils)
37 #:use-module (gnu packages gettext)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages man)
40 #:use-module (gnu packages ncurses)
41 #:use-module (gnu packages perl)
42 #:use-module (gnu packages python)
43 #:use-module (gnu packages qemu)
44 #:use-module (gnu packages texinfo)
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))
53 ;; GNU Unifont, <http://gnu.org/s/unifont>.
54 ;; GRUB needs it for its graphical terminal, gfxterm.
58 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
61 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
69 (uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz"))
72 "03vvdfhdmf16121v7xs8is2krwnv15wpkhkf16a4yf8nsfc3f2w1"))))
73 (build-system gnu-build-system)
75 '(#:phases (modify-phases %standard-phases
76 (add-after 'unpack 'patch-stuff
77 (lambda* (#:key inputs #:allow-other-keys)
78 (substitute* "grub-core/Makefile.in"
79 (("/bin/sh") (which "sh")))
81 ;; Give the absolute file name of 'mdadm', used to
82 ;; determine the root file system when it's a RAID
83 ;; device. Failing to do that, 'grub-probe' silently
84 ;; fails if 'mdadm' is not in $PATH.
85 (substitute* "grub-core/osdep/linux/getroot.c"
86 (("argv\\[0\\] = \"mdadm\"")
87 (string-append "argv[0] = \""
88 (assoc-ref inputs "mdadm")
91 ;; Make the font visible.
92 (copy-file (assoc-ref inputs "unifont") "unifont.bdf.gz")
93 (system* "gunzip" "unifont.bdf.gz")
96 `(("gettext" ,gettext-minimal)
98 ;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and
99 ;; 'grub-install' to recognize mapped devices (LUKS, etc.)
102 ;; Depend on mdadm, which is invoked by 'grub-probe' and 'grub-install'
103 ;; to determine whether the root file system is RAID.
106 ("freetype" ,freetype)
107 ;; ("libusb" ,libusb)
109 ("ncurses" ,ncurses)))
111 `(("unifont" ,unifont)
115 ("help2man" ,help2man)
117 ;; Dependencies for the test suite. The "real" QEMU is needed here,
118 ;; because several targets are used.
120 ("qemu" ,qemu-minimal)
121 ("xorriso" ,xorriso)))
122 (home-page "https://www.gnu.org/software/grub/")
123 (synopsis "GRand Unified Boot loader")
125 "GRUB is a multiboot bootloader. It is used for initially loading the
126 kernel of an operating system and then transferring control to it. The kernel
127 then goes on to load the rest of the operating system. As a multiboot
128 bootloader, GRUB handles the presence of multiple operating systems installed
129 on the same computer; upon booting the computer, the user is presented with a
130 menu to select one of the installed operating systems.")
131 (license license:gpl3+)
132 (properties '((cpe-name . "grub2")))))
134 (define-public grub-efi
138 (synopsis "GRand Unified Boot loader (UEFI version)")
140 `(("efibootmgr" ,efibootmgr)
141 ,@(package-inputs grub)))
143 `(;; TODO: Tests need a UEFI firmware for qemu. There is one at
144 ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
145 ;; Search for 'OVMF' in "tests/util/grub-shell.in".
147 ,@(substitute-keyword-arguments (package-arguments grub)
148 ((#:configure-flags flags ''())
149 `(cons "--with-platform=efi" ,flags))
151 `(modify-phases ,phases
152 (add-after 'patch-stuff 'use-absolute-efibootmgr-path
153 (lambda* (#:key inputs #:allow-other-keys)
154 (substitute* "grub-core/osdep/unix/platform.c"
156 (string-append (assoc-ref inputs "efibootmgr")
157 "/sbin/efibootmgr")))
160 (define-public syslinux
161 (let ((commit "bb41e935cc83c6242de24d2271e067d76af3585c"))
164 (version (git-version "6.04-pre" "1" commit))
168 (url "https://github.com/geneC/syslinux")
170 (file-name (git-file-name name version))
173 "0k8dvafd6410kqxf3kyr4y8jzmpmrih6wbjqg6gklak7945yflrc"))))
174 (build-system gnu-build-system)
178 ("python-2" ,python-2)))
180 `(("libuuid" ,util-linux)))
182 `(#:parallel-build? #f
184 (list (string-append "BINDIR=" %output "/bin")
185 (string-append "SBINDIR=" %output "/sbin")
186 (string-append "LIBDIR=" %output "/lib")
187 (string-append "INCDIR=" %output "/include")
188 (string-append "DATADIR=" %output "/share")
189 (string-append "MANDIR=" %output "/share/man")
193 (modify-phases %standard-phases
194 (add-after 'unpack 'patch-files
196 (substitute* (find-files "." "Makefile.*|ppmtolss16")
197 (("/bin/pwd") (which "pwd"))
198 (("/bin/echo") (which "echo"))
199 (("/usr/bin/perl") (which "perl")))
202 (add-before 'build 'set-permissions
204 (zero? (system* "chmod" "a+w" "utils/isohybrid.in"))))
208 (substitute* "tests/unittest/include/unittest/unittest.h"
209 ;; Don't look up headers under /usr.
210 (("/usr/include/") ""))
211 (zero? (system* "make" "unittest")))))))
212 (home-page "http://www.syslinux.org")
213 (synopsis "Lightweight Linux bootloader")
214 (description "Syslinux is a lightweight Linux bootloader.")
215 (license (list license:gpl2+
216 license:bsd-3 ; gnu-efi/*
217 license:bsd-4 ; gnu-efi/inc/* gnu-efi/lib/*
219 license:expat license:isc license:zlib)))))
228 "mirror://kernel.org/software/utils/dtc/"
229 "dtc-" version ".tar.xz"))
232 "1yygyvnnpdh241hl90n9p3kxcdvk3jxmsr4ndb961c8mq3ak21s7"))))
233 (build-system gnu-build-system)
240 (string-append "PREFIX=" (assoc-ref %outputs "out"))
243 (modify-phases %standard-phases
244 (delete 'configure))))
245 (home-page "https://www.devicetree.org")
246 (synopsis "Compiles device tree source files")
247 (description "@command{dtc} compiles
248 @uref{http://elinux.org/Device_Tree_Usage, device tree source files} to device
249 tree binary files. These are board description files used by Linux and BSD.")
250 (license license:gpl2+)))
259 "ftp://ftp.denx.de/pub/u-boot/"
260 "u-boot-" version ".tar.bz2"))
263 "0gqihplap05dlpwdb971wsqyv01nz2vabwq5g5649gr5jczsyjzm"))))
267 ("python-2" ,python-2)))
268 (build-system gnu-build-system)
269 (home-page "http://www.denx.de/wiki/U-Boot/")
270 (synopsis "ARM bootloader")
271 (description "U-Boot is a bootloader used mostly for ARM boards. It
272 also initializes the boards (RAM etc).")
273 (license license:gpl2+)))
275 (define (make-u-boot-package board triplet)
276 "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
279 (name (string-append "u-boot-" (string-downcase board)))
281 `(("cross-gcc" ,(cross-gcc triplet))
282 ("cross-binutils" ,(cross-binutils triplet))
283 ,@(package-native-inputs u-boot)))
285 `(#:modules ((ice-9 ftw) (guix build utils) (guix build gnu-build-system))
288 (list "HOSTCC=gcc" (string-append "CROSS_COMPILE=" ,triplet "-"))
290 (modify-phases %standard-phases
292 (lambda* (#:key outputs make-flags #:allow-other-keys)
293 (let ((config-name (string-append ,board "_defconfig")))
294 (if (file-exists? (string-append "configs/" config-name))
295 (zero? (apply system* "make" `(,@make-flags ,config-name)))
297 (display "Invalid board name. Valid board names are:")
298 (let ((suffix-len (string-length "_defconfig")))
301 (when (string-suffix? "_defconfig" file-name)
304 (string-drop-right file-name
308 (lambda* (#:key outputs make-flags #:allow-other-keys)
309 (let* ((out (assoc-ref outputs "out"))
310 (libexec (string-append out "/libexec"))
311 (uboot-files (find-files "." ".*\\.(bin|efi|spl)$")))
315 (let ((target-file (string-append libexec "/" file)))
316 (mkdir-p (dirname target-file))
317 (copy-file file target-file)))
320 (define-public u-boot-vexpress
321 (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
323 (define-public u-boot-malta
324 (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
326 (define-public u-boot-beagle-bone-black
327 (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))