unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 40e02319f0c532e07cf9b9d541b500c24c9134a5 5971 bytes (raw)
name: gnu/bootloader/extlinux.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 David Craven <david@craven.ch>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu bootloader extlinux)
  #:use-module (gnu bootloader)
  #:use-module (gnu packages bootloaders)
  #:use-module (guix gexp)
  #:use-module (guix utils)
  #:export (extlinux-bootloader
            extlinux-bootloader-gpt))

(define* (extlinux-configuration-file config entries
                                      #:key
                                      (locale #f)
                                      (system (%current-system))
                                      (old-entries '())
                                      #:allow-other-keys)
  "Return the U-Boot configuration file corresponding to CONFIG, a
<u-boot-configuration> object, and where the store is available at STORE-FS, a
<file-system> object.  OLD-ENTRIES is taken to be a list of menu entries
corresponding to old generations of the system."

  (define all-entries
    (append entries (bootloader-configuration-menu-entries config)))

  (define (translate-label label)
    (match label
      (('hurd name version)
       ;; TRANSLATORS: The first parameter is the capitalized package name
       ;; for the Hurd kernel, which uses the definite article in English.
       ;; The second parameter contains the version string.
       #~(format #f (G_ "GNU with the ~a ~a") package version))
      (('linux name version)
       ;; TRANSLATORS: The first parameter is the capitalized package name
       ;; for Linux kernel, which doesn't use the definite article in
       ;; English.  The second parameter contains the version string.
       #~(format #f (G_ "GNU with ~a ~a") package version))
      (('unknown)
       ;; TRANSLATORS: This is the label for an unknown system to be booted.
       #~(G_ "GNU"))
      ((? string? old-format)
       ;; We cannot translate properly the old format.
       #~old-format)))

  (define init-gettext
    #~(let ((locale #$(and locale
                           (locale-definition-name
                            (locale-name->definition locale)))))
        (when locale
          (setenv "GUIX_LOCPATH" (string-append #$glibc-locales
                                                "/lib/locale/"))
          (bindtextdomain "guix" (string-append #$guix "/share/locale"))
          (textdomain "guix")
          (setlocale LC_ALL locale))))

  (define (menu-entry->gexp entry)
    (let ((label (translate-label (menu-entry-label entry)))
          (kernel (menu-entry-linux entry))
          (kernel-arguments (menu-entry-linux-arguments entry))
          (initrd (menu-entry-initrd entry)))
      #~(format port "LABEL ~a
  MENU LABEL ~a
  KERNEL ~a
  FDTDIR ~a/lib/dtbs
  INITRD ~a
  APPEND ~a
~%"
                #$label #$label
                #$kernel (dirname #$kernel) #$initrd
                (string-join (list #$@kernel-arguments)))))

  (define builder
    #~(call-with-output-file #$output
        (lambda (port)
          #$init-gettext
          ;; Ensure xgettext extracts translatable messages
          ;; with our current keywords.
          (define G_ gettext)
          (let ((timeout #$(bootloader-configuration-timeout config)))
            (format port "~aUI menu.c32
MENU TITLE ~a
PROMPT ~a
TIMEOUT ~a~%"
                    (G_ "\
# This file was generated from your Guix configuration.  Any changes
# will be lost upon reconfiguration.
") ;; Keep line break to not duplicate grub.scm message.
                    (G_ "GNU Guix Boot Options")
                    (if (> timeout 0) 1 0)
                    ;; timeout is expressed in 1/10s of seconds.
                    (* 10 timeout))
            #$@(map menu-entry->gexp all-entries)

            #$@(if (pair? old-entries)
                   #~((format port "~%")
                      #$@(map menu-entry->gexp old-entries)
                      (format port "~%"))
                   #~())))))

  (computed-file "extlinux.conf" builder
                 #:options '(#:local-build? #t
                             #:substitutable? #f)))


\f

;;;
;;; Install procedures.
;;;

(define (install-extlinux mbr)
  #~(lambda (bootloader device mount-point)
      (let ((extlinux (string-append bootloader "/sbin/extlinux"))
            (install-dir (string-append mount-point "/boot/extlinux"))
            (syslinux-dir (string-append bootloader "/share/syslinux")))
        (for-each (lambda (file)
                    (install-file file install-dir))
                  (find-files syslinux-dir "\\.c32$"))
        (invoke/quiet extlinux "--install" install-dir)
        (write-file-on-device (string-append syslinux-dir "/" #$mbr)
                              440 device 0))))

(define install-extlinux-mbr
  (install-extlinux "mbr.bin"))

(define install-extlinux-gpt
  (install-extlinux "gptmbr.bin"))

\f

;;;
;;; Bootloader definitions.
;;;

(define extlinux-bootloader
  (bootloader
   (name 'extlinux)
   (package syslinux)
   (installer install-extlinux-mbr)
   (configuration-file "/boot/extlinux/extlinux.conf")
   (configuration-file-generator extlinux-configuration-file)))

(define extlinux-bootloader-gpt
  (bootloader
   (inherit extlinux-bootloader)
   (installer install-extlinux-gpt)))

debug log:

solving 40e02319f0 ...
found 40e02319f0 in https://yhetil.org/guix-patches/87v9f7po4x.fsf_-_@gmail.com/
found 6b5ff298e7 in https://git.savannah.gnu.org/cgit/guix.git
preparing index
index prepared:
100644 6b5ff298e747d51fce9c10f9a65ecba317c0429f	gnu/bootloader/extlinux.scm

applying [1/1] https://yhetil.org/guix-patches/87v9f7po4x.fsf_-_@gmail.com/
diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm
index 6b5ff298e7..40e02319f0 100644

Checking patch gnu/bootloader/extlinux.scm...
Applied patch gnu/bootloader/extlinux.scm cleanly.

index at:
100644 40e02319f0c532e07cf9b9d541b500c24c9134a5	gnu/bootloader/extlinux.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).