| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 |
|
| 20 | (define-module (gnu bootloader extlinux)
|
| 21 | #:use-module (gnu bootloader)
|
| 22 | #:use-module (gnu packages bootloaders)
|
| 23 | #:use-module (guix gexp)
|
| 24 | #:use-module (guix utils)
|
| 25 | #:export (extlinux-bootloader
|
| 26 | extlinux-bootloader-gpt))
|
| 27 |
|
| 28 | (define* (extlinux-configuration-file config entries
|
| 29 | #:key
|
| 30 | (system (%current-system))
|
| 31 | (old-entries '())
|
| 32 | #:allow-other-keys)
|
| 33 | "Return the U-Boot configuration file corresponding to CONFIG, a
|
| 34 | <u-boot-configuration> object, and where the store is available at STORE-FS, a
|
| 35 | <file-system> object. OLD-ENTRIES is taken to be a list of menu entries
|
| 36 | corresponding to old generations of the system."
|
| 37 |
|
| 38 | (define all-entries
|
| 39 | (append entries (bootloader-configuration-menu-entries config)))
|
| 40 |
|
| 41 | (define (menu-entry->gexp entry)
|
| 42 | (let ((label (menu-entry-label entry))
|
| 43 | (kernel (menu-entry-linux entry))
|
| 44 | (kernel-arguments (menu-entry-linux-arguments entry))
|
| 45 | (initrd (menu-entry-initrd entry)))
|
| 46 | #~(format port "LABEL ~a
|
| 47 | MENU LABEL ~a
|
| 48 | KERNEL ~a
|
| 49 | FDTDIR ~a/lib/dtbs
|
| 50 | INITRD ~a
|
| 51 | APPEND ~a
|
| 52 | ~%"
|
| 53 | #$label #$label
|
| 54 | #$kernel (dirname #$kernel) #$initrd
|
| 55 | (string-join (list #$@kernel-arguments)))))
|
| 56 |
|
| 57 | (define builder
|
| 58 | #~(call-with-output-file #$output
|
| 59 | (lambda (port)
|
| 60 | (let ((timeout #$(bootloader-configuration-timeout config)))
|
| 61 | (format port "# This file was generated from your Guix configuration. Any changes
|
| 62 | # will be lost upon reconfiguration.
|
| 63 | UI menu.c32
|
| 64 | MENU TITLE GNU Guix Boot Options
|
| 65 | PROMPT ~a
|
| 66 | TIMEOUT ~a~%"
|
| 67 | (if (> timeout 0) 1 0)
|
| 68 | |
| 69 | (* 10 timeout))
|
| 70 | #$@(map menu-entry->gexp all-entries)
|
| 71 |
|
| 72 | #$@(if (pair? old-entries)
|
| 73 | #~((format port "~%")
|
| 74 | #$@(map menu-entry->gexp old-entries)
|
| 75 | (format port "~%"))
|
| 76 | #~())))))
|
| 77 |
|
| 78 | (computed-file "extlinux.conf" builder
|
| 79 | #:options '(#:local-build? #t
|
| 80 | #:substitutable? #f)))
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 | |
| 86 | |
| 87 | |
| 88 |
|
| 89 | (define (install-extlinux mbr)
|
| 90 | #~(lambda (bootloader device mount-point)
|
| 91 | (let ((extlinux (string-append bootloader "/sbin/extlinux"))
|
| 92 | (install-dir (string-append mount-point "/boot/extlinux"))
|
| 93 | (syslinux-dir (string-append bootloader "/share/syslinux")))
|
| 94 | (for-each (lambda (file)
|
| 95 | (install-file file install-dir))
|
| 96 | (find-files syslinux-dir "\\.c32$"))
|
| 97 | (invoke/quiet extlinux "--install" install-dir)
|
| 98 | (write-file-on-device (string-append syslinux-dir "/" #$mbr)
|
| 99 | 440 device 0))))
|
| 100 |
|
| 101 | (define install-extlinux-mbr
|
| 102 | (install-extlinux "mbr.bin"))
|
| 103 |
|
| 104 | (define install-extlinux-gpt
|
| 105 | (install-extlinux "gptmbr.bin"))
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 | |
| 110 | |
| 111 | |
| 112 |
|
| 113 | (define extlinux-bootloader
|
| 114 | (bootloader
|
| 115 | (name 'extlinux)
|
| 116 | (package syslinux)
|
| 117 | (installer install-extlinux-mbr)
|
| 118 | (configuration-file "/boot/extlinux/extlinux.conf")
|
| 119 | (configuration-file-generator extlinux-configuration-file)))
|
| 120 |
|
| 121 | (define extlinux-bootloader-gpt
|
| 122 | (bootloader
|
| 123 | (inherit extlinux-bootloader)
|
| 124 | (installer install-extlinux-gpt)))
|