From: David Craven <david@craven.ch>
To: guix-devel@gnu.org
Subject: [PATCH 1/2] system: Rename grub to bootloader.
Date: Tue, 10 Jan 2017 19:42:42 +0100 [thread overview]
Message-ID: <20170110184243.6100-1-david@craven.ch> (raw)
* gnu/system.scm (operating-system-bootloader-configuration-file,
kernel->bootloader-label, bootloader-device): Rename variables.
* guix/scripts/system.scm (install-bootloader*,
profile-bootloader-entries, system->bootloader-entry): Rename
variables.
(install, perform-action, %default-options): Adjust accordingly.
* gnu/system/vm.scm (qemu-image, system-disk-image, system-qemu-image,
system-qemu-image/shared-store): Rename variables and update
docstrings to be bootloader agnostic.
---
gnu/system.scm | 40 ++++++-------
gnu/system/vm.scm | 30 +++++-----
guix/scripts/system.scm | 156 ++++++++++++++++++++++++------------------------
3 files changed, 115 insertions(+), 111 deletions(-)
diff --git a/gnu/system.scm b/gnu/system.scm
index 4e57f975e..9c1239e0b 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -92,7 +92,7 @@
operating-system-derivation
operating-system-profile
- operating-system-grub.cfg
+ operating-system-bootcfg
operating-system-etc-directory
operating-system-locale-directory
operating-system-boot-script
@@ -698,8 +698,8 @@ listed in OS. The C library expects to find it under
(locale-directory definitions
#:libcs (operating-system-locale-libcs os)))
-(define (kernel->grub-label kernel)
- "Return a label for the GRUB menu entry that boots KERNEL."
+(define (kernel->bootloader-label kernel)
+ "Return a label for a bootloader menu entry that boots KERNEL."
(string-append "GNU with "
(string-titlecase (package-name kernel)) " "
(package-version kernel)
@@ -726,14 +726,14 @@ listed in OS. The C library expects to find it under
"Return the file system that contains the store of OS."
(store-file-system (operating-system-file-systems os)))
-(define* (operating-system-grub.cfg os #:optional (old-entries '()))
- "Return the GRUB configuration file for OS. Use OLD-ENTRIES to populate the
-\"old entries\" menu."
+(define* (operating-system-bootcfg os #:optional (old-entries '()))
+ "Return the bootloader configuration file for OS. Use OLD-ENTRIES to populate
+the \"old entries\" menu."
(mlet* %store-monad
((system (operating-system-derivation os))
(root-fs -> (operating-system-root-file-system os))
(store-fs -> (operating-system-store-file-system os))
- (label -> (kernel->grub-label (operating-system-kernel os)))
+ (label -> (kernel->bootloader-label (operating-system-kernel os)))
(kernel -> (operating-system-kernel-file os))
(initrd (operating-system-initrd-file os))
(root-device -> (if (eq? 'uuid (file-system-title root-fs))
@@ -743,7 +743,7 @@ listed in OS. The C library expects to find it under
(label label)
;; The device where the kernel and initrd live.
- (device (grub-device store-fs))
+ (device (bootloader-device store-fs))
(device-mount-point
(file-system-mount-point store-fs))
@@ -758,7 +758,7 @@ listed in OS. The C library expects to find it under
(grub-configuration-file (operating-system-bootloader os) entries
#:old-entries old-entries)))
-(define (grub-device fs)
+(define (bootloader-device fs)
"Given FS, a <file-system> object, return a value suitable for use as the
device in a <menu-entry>."
(case (file-system-title fs)
@@ -768,11 +768,11 @@ device in a <menu-entry>."
(define (operating-system-parameters-file os)
"Return a file that describes the boot parameters of OS. The primary use of
-this file is the reconstruction of GRUB menu entries for old configurations."
+this file is the reconstruction of bootloader menu entries for old configurations."
(mlet %store-monad ((initrd (operating-system-initrd-file os))
(root -> (operating-system-root-file-system os))
(store -> (operating-system-store-file-system os))
- (label -> (kernel->grub-label
+ (label -> (kernel->bootloader-label
(operating-system-kernel os))))
(gexp->file "parameters"
#~(boot-parameters
@@ -784,7 +784,7 @@ this file is the reconstruction of GRUB menu entries for old configurations."
#$(operating-system-kernel-arguments os))
(initrd #$initrd)
(store
- (device #$(grub-device store))
+ (device #$(bootloader-device store))
(mount-point #$(file-system-mount-point store))))
#:set-load-path? #f)))
@@ -796,13 +796,13 @@ this file is the reconstruction of GRUB menu entries for old configurations."
(define-record-type* <boot-parameters>
boot-parameters make-boot-parameters boot-parameters?
(label boot-parameters-label)
- ;; Because we will use the 'store-device' to create the GRUB search command,
- ;; the 'store-device' has slightly different semantics than 'root-device'.
- ;; The 'store-device' can be a file system uuid, a file system label, or #f,
- ;; but it cannot be a device path such as "/dev/sda3", since GRUB would not
- ;; understand that. The 'root-device', on the other hand, corresponds
- ;; exactly to the device field of the <file-system> object representing the
- ;; OS's root file system, so it might be a device path like "/dev/sda3".
+ ;; Because the bootloader needs to use the 'store-device' it has slightly
+ ;; different semantics than 'root-device'. The 'store-device' can be a file
+ ;; system uuid, a file system label, or #f, but it cannot be a device path
+ ;; such as "/dev/sda3", since a bootloader would not understand that. The
+ ;; 'root-device', on the other hand, corresponds exactly to the device field
+ ;; of the <file-system> object representing the OS's root file system, so it
+ ;; might be a device path like "/dev/sda3".
(root-device boot-parameters-root-device)
(store-device boot-parameters-store-device)
(store-mount-point boot-parameters-store-mount-point)
@@ -847,7 +847,7 @@ this file is the reconstruction of GRUB menu entries for old configurations."
device)
(_ ;the old format
;; Root might be a device path like "/dev/sda1", which is not a
- ;; suitable GRUB device identifier.
+ ;; suitable bootloader device identifier.
(if (string-prefix? "/" root)
#f
root))))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 1e680b85a..dbc3a5649 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -175,7 +175,7 @@ made available under the /xchg CIFS share."
(file-system-type "ext4")
file-system-label
os-derivation
- grub-configuration
+ bootloader-configuration
(register-closures? #t)
(inputs '())
copy-inputs?)
@@ -183,8 +183,9 @@ made available under the /xchg CIFS share."
'qcow2' or 'raw'), with a root partition of type FILE-SYSTEM-TYPE.
Optionally, FILE-SYSTEM-LABEL can be specified as the volume name for the root
partition. The returned image is a full disk image that runs OS-DERIVATION,
-with a GRUB installation that uses GRUB-CONFIGURATION as its configuration
-file (GRUB-CONFIGURATION must be the name of a file in the VM.)
+with a bootloader installation that uses BOOTLOADER-CONFIGURATION as its
+configuration file (BOOTLOADER-CONFIGURATION must be the name of a file in the
+VM.)
INPUTS is a list of inputs (as for packages). When COPY-INPUTS? is true, copy
all of INPUTS into the image being built. When REGISTER-CLOSURES? is true,
@@ -231,7 +232,8 @@ the image."
(initializer initialize)))))
(initialize-hard-disk "/dev/vda"
#:partitions partitions
- #:grub.cfg #$grub-configuration)
+ #:bootloader-configuration
+ #$bootloader-configuration)
(reboot)))))
#:system system
#:make-disk-image? #t
@@ -283,10 +285,10 @@ to USB sticks meant to be read-only."
file-systems-to-keep)))))
(mlet* %store-monad ((os-drv (operating-system-derivation os))
- (grub.cfg (operating-system-grub.cfg os)))
+ (bootcfg (operating-system-bootcfg os)))
(qemu-image #:name name
#:os-derivation os-drv
- #:grub-configuration grub.cfg
+ #:bootloader-configuration bootcfg
#:disk-image-size disk-image-size
#:disk-image-format "raw"
#:file-system-type file-system-type
@@ -294,7 +296,7 @@ to USB sticks meant to be read-only."
#:copy-inputs? #t
#:register-closures? #t
#:inputs `(("system" ,os-drv)
- ("grub.cfg" ,grub.cfg))))))
+ ("bootcfg" ,bootcfg))))))
(define* (system-qemu-image os
#:key
@@ -327,13 +329,13 @@ of the GNU system as described by OS."
file-systems-to-keep)))))
(mlet* %store-monad
((os-drv (operating-system-derivation os))
- (grub.cfg (operating-system-grub.cfg os)))
+ (bootcfg (operating-system-bootcfg os)))
(qemu-image #:os-derivation os-drv
- #:grub-configuration grub.cfg
+ #:bootloader-configuration bootcfg
#:disk-image-size disk-image-size
#:file-system-type file-system-type
#:inputs `(("system" ,os-drv)
- ("grub.cfg" ,grub.cfg))
+ ("bootcfg" ,bootcfg))
#:copy-inputs? #t))))
\f
@@ -414,16 +416,16 @@ When FULL-BOOT? is true, return an image that does a complete boot sequence,
bootloaded included; thus, make a disk image that contains everything the
bootloader refers to: OS kernel, initrd, bootloader data, etc."
(mlet* %store-monad ((os-drv (operating-system-derivation os))
- (grub.cfg (operating-system-grub.cfg os)))
+ (bootcfg (operating-system-bootcfg os)))
;; XXX: When FULL-BOOT? is true, we end up creating an image that contains
- ;; GRUB.CFG and all its dependencies, including the output of OS-DRV.
+ ;; BOOTCFG and all its dependencies, including the output of OS-DRV.
;; This is more than needed (we only need the kernel, initrd, GRUB for its
;; font, and the background image), but it's hard to filter that.
(qemu-image #:os-derivation os-drv
- #:grub-configuration grub.cfg
+ #:bootloader-configuration bootcfg
#:disk-image-size disk-image-size
#:inputs (if full-boot?
- `(("grub.cfg" ,grub.cfg))
+ `(("bootcfg" ,bootcfg))
'())
;; XXX: Passing #t here is too slow, so let it off by default.
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 144a7fd37..274325ab3 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -123,7 +123,7 @@ TARGET, and register them."
(map (cut copy-item <> target #:log-port log-port)
to-copy))))
-(define (install-grub* grub.cfg device target)
+(define (install-bootloader* bootcfg device target)
"This is a variant of 'install-grub' with error handling, lifted in
%STORE-MONAD"
(let* ((gc-root (string-append target %gc-roots-directory
@@ -133,26 +133,27 @@ TARGET, and register them."
(make-symlink (lift2 switch-symlinks %store-monad))
(rename (lift2 rename-file %store-monad)))
(mbegin %store-monad
- ;; Prepare the symlink to GRUB.CFG to make sure that it's a GC root when
- ;; 'install-grub' completes (being a bit paranoid.)
- (make-symlink temp-gc-root grub.cfg)
+ ;; Prepare the symlink to BOOTCFG to make sure that
+ ;; it's a GC root when 'install-grub' completes (being a bit paranoid.)
+ (make-symlink temp-gc-root bootcfg)
- (munless (false-if-exception (install-grub grub.cfg device target))
+ (munless (false-if-exception (install-grub bootcfg
+ device target))
(delete-file temp-gc-root)
- (leave (_ "failed to install GRUB on device '~a'~%") device))
+ (leave (_ "failed to install bootloader on device '~a'~%") device))
- ;; Register GRUB.CFG as a GC root so that its dependencies (background
+ ;; Register BOOTCFG as a GC root so that its dependencies (background
;; image, font, etc.) are not reclaimed.
(rename temp-gc-root gc-root))))
(define* (install os-drv target
#:key (log-port (current-output-port))
- grub? grub.cfg device)
- "Copy the closure of GRUB.CFG, which includes the output of OS-DRV, to
-directory TARGET. TARGET must be an absolute directory name since that's what
-'guix-register' expects.
+ bootloader? bootcfg device)
+ "Copy the closure of BOOTCFG, which includes the output
+of OS-DRV, to directory TARGET. TARGET must be an absolute directory name since
+that's what 'guix-register' expects.
-When GRUB? is true, install GRUB on DEVICE, using GRUB.CFG."
+When BOOTLOADER? is true, install bootloader on DEVICE, using BOOTCFG."
(define (maybe-copy to-copy)
(with-monad %store-monad
(if (string=? target "/")
@@ -181,16 +182,16 @@ the ownership of '~a' may be incorrect!~%")
(populate (lift2 populate-root-file-system %store-monad)))
(mbegin %store-monad
- ;; Copy the closure of GRUB.CFG, which includes OS-DIR, GRUB's
- ;; background image and so on.
- (maybe-copy grub.cfg)
+ ;; Copy the closure of BOOTCFG, which includes OS-DIR, and the
+ ;; bootloader's background image and so on.
+ (maybe-copy bootcfg)
;; Create a bunch of additional files.
(format log-port "populating '~a'...~%" target)
(populate os-dir target)
- (mwhen grub?
- (install-grub* grub.cfg device target)))))
+ (mwhen bootloader?
+ (install-bootloader* bootcfg device target)))))
\f
;;;
@@ -362,11 +363,11 @@ it atomically, and then run OS's activation script."
(date->string (time-utc->date time)
"~Y-~m-~d ~H:~M")))
-(define* (profile-grub-entries #:optional (profile %system-profile)
+(define* (profile-bootloader-entries #:optional (profile %system-profile)
(numbers (generation-numbers profile)))
"Return a list of 'menu-entry' for the generations of PROFILE specified by
NUMBERS, which is a list of generation numbers."
- (define (system->grub-entry system number time)
+ (define (system->bootloader-entry system number time)
(unless-file-not-found
(let* ((file (string-append system "/parameters"))
(params (call-with-input-file file
@@ -399,7 +400,7 @@ NUMBERS, which is a list of generation numbers."
(unless-file-not-found
(stat:mtime (lstat system))))
systems)))
- (filter-map system->grub-entry systems numbers times)))
+ (filter-map system->bootloader-entry systems numbers times)))
\f
;;;
@@ -415,18 +416,19 @@ connection to the store."
;;;
(define (switch-to-system-generation store spec)
"Switch the system profile to the generation specified by SPEC, and
-re-install grub with a grub configuration file that uses the specified system
-generation as its default entry. STORE is an open connection to the store."
+re-install bootloader with a bootloader configuration file that uses the
+specified system generation as its default entry. STORE is an open connection
+to the store."
(let ((number (relative-generation-spec->number %system-profile spec)))
(if number
(begin
- (reinstall-grub store number)
+ (reinstall-bootloader store number)
(switch-to-generation* %system-profile number))
(leave (_ "cannot switch to system generation '~a'~%") spec))))
-(define (reinstall-grub store number)
- "Re-install grub for existing system profile generation NUMBER. STORE is an
-open connection to the store."
+(define (reinstall-bootloader store number)
+ "Re-install bootloader for existing system profile generation NUMBER. STORE
+is an open connection to the store."
(let* ((generation (generation-file-name %system-profile number))
(file (string-append generation "/parameters"))
(params (unless-file-not-found
@@ -435,29 +437,29 @@ open connection to the store."
;; We don't currently keep track of past menu entries' details. The
;; default values will allow the system to boot, even if they differ
;; from the actual past values for this generation's entry.
- (grub-config (grub-configuration (device root-device)))
+ (bootloader-config (grub-configuration (device root-device)))
;; Make the specified system generation the default entry.
- (entries (profile-grub-entries %system-profile (list number)))
+ (entries (profile-bootloader-entries %system-profile (list number)))
(old-generations (delv number (generation-numbers %system-profile)))
- (old-entries (profile-grub-entries %system-profile old-generations))
- (grub.cfg (run-with-store store
- (grub-configuration-file grub-config
- entries
- #:old-entries old-entries))))
- (show-what-to-build store (list grub.cfg))
- (build-derivations store (list grub.cfg))
+ (old-entries (profile-bootloader-entries %system-profile old-generations))
+ (bootcfg (run-with-store store
+ (grub-configuration-file bootloader-config
+ entries
+ #:old-entries old-entries))))
+ (show-what-to-build store (list bootcfg))
+ (build-derivations store (list bootcfg))
;; This is basically the same as install-grub*, but for now we avoid
- ;; re-installing the GRUB boot loader itself onto a device, mainly because
- ;; we don't in general have access to the same version of the GRUB package
- ;; which was used when installing this other system generation.
- (let* ((grub.cfg-path (derivation->output-path grub.cfg))
+ ;; re-installing the boot loader itself onto a device, mainly because we
+ ;; don't in general have access to the same version of the bootloader
+ ;; package which was used when installing this other system generation.
+ (let* ((bootcfg-path (derivation->output-path bootcfg))
(gc-root (string-append %gc-roots-directory "/grub.cfg"))
(temp-gc-root (string-append gc-root ".new")))
- (switch-symlinks temp-gc-root grub.cfg-path)
- (unless (false-if-exception (install-grub-config grub.cfg-path "/"))
+ (switch-symlinks temp-gc-root bootcfg-path)
+ (unless (false-if-exception (install-grub-config bootcfg-path "/"))
(delete-file temp-gc-root)
- (leave (_ "failed to re-install GRUB configuration file: '~a'~%")
- grub.cfg-path))
+ (leave (_ "failed to re-install bootloader configuration file: '~a'~%")
+ bootcfg-path))
(rename-file temp-gc-root gc-root))))
\f
@@ -590,15 +592,15 @@ PATTERN, a string. When PATTERN is #f, display all the system generations."
(warning (_ "Failing to do that may downgrade your system!~%"))))
(define* (perform-action action os
- #:key grub? dry-run? derivations-only?
+ #:key bootloader? dry-run? derivations-only?
use-substitutes? device target
image-size full-boot?
(mappings '()))
- "Perform ACTION for OS. GRUB? specifies whether to install GRUB; DEVICE is
-the target devices for GRUB; TARGET is the target root directory; IMAGE-SIZE
-is the size of the image to be built, for the 'vm-image' and 'disk-image'
-actions. FULL-BOOT? is used for the 'vm' action; it determines whether to
-boot directly to the kernel or to the bootloader.
+ "Perform ACTION for OS. BOOTLOADER? specifies whether to install a
+bootloader; DEVICE is the target device the bootloader is installed on; TARGET
+is the target root directory; IMAGE-SIZE is the size of the image to be built,
+for the 'vm-image' and 'disk-image' actions. FULL-BOOT? is used for the 'vm'
+action; it determines whether to boot directly to the kernel or to the bootloader.
When DERIVATIONS-ONLY? is true, print the derivation file name(s) without
building anything."
@@ -613,22 +615,22 @@ building anything."
#:image-size image-size
#:full-boot? full-boot?
#:mappings mappings))
- (grub (package->derivation (grub-configuration-grub
- (operating-system-bootloader os))))
- (grub.cfg (if (eq? 'container action)
- (return #f)
- (operating-system-grub.cfg os
- (if (eq? 'init action)
- '()
- (profile-grub-entries)))))
-
- ;; For 'init' and 'reconfigure', always build GRUB.CFG, even if
- ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
- ;; root. See <http://bugs.gnu.org/21068>.
+ (bootloader (package->derivation (grub-configuration-grub
+ (operating-system-bootloader os))))
+ (bootcfg (if (eq? 'container action)
+ (return #f)
+ (operating-system-bootcfg os
+ (if (eq? 'init action)
+ '()
+ (profile-bootloader-entries)))))
+
+ ;; For 'init' and 'reconfigure', always build BOOTCFG,
+ ;; even if --no-bootloader is passed, because we use it as a GC root.
+ ;; See <http://bugs.gnu.org/21068>.
(drvs -> (if (memq action '(init reconfigure))
- (if grub?
- (list sys grub.cfg grub)
- (list sys grub.cfg))
+ (if bootloader?
+ (list sys bootcfg bootloader)
+ (list sys bootcfg))
(list sys)))
(% (if derivations-only?
(return (for-each (compose println derivation-file-name)
@@ -642,9 +644,9 @@ building anything."
(for-each (compose println derivation->output-path)
drvs)
- ;; Make sure GRUB is accessible.
- (when grub?
- (let ((prefix (derivation->output-path grub)))
+ ;; Make sure BOOTLOADER is accessible.
+ (when bootloader?
+ (let ((prefix (derivation->output-path bootloader)))
(setenv "PATH"
(string-append prefix "/bin:" prefix "/sbin:"
(getenv "PATH")))))
@@ -653,16 +655,16 @@ building anything."
((reconfigure)
(mbegin %store-monad
(switch-to-system os)
- (mwhen grub?
- (install-grub* (derivation->output-path grub.cfg)
- device "/"))))
+ (mwhen bootloader?
+ (install-bootloader* (derivation->output-path bootcfg)
+ device "/"))))
((init)
(newline)
(format #t (_ "initializing operating system under '~a'...~%")
target)
(install sys (canonicalize-path target)
- #:grub? grub?
- #:grub.cfg (derivation->output-path grub.cfg)
+ #:bootloader? bootloader?
+ #:bootcfg (derivation->output-path bootcfg)
#:device device))
(else
;; All we had to do was to build SYS.
@@ -774,7 +776,7 @@ Some ACTIONS support additional ARGS.\n"))
result)))
(option '("no-grub") #f #f
(lambda (opt name arg result)
- (alist-cons 'install-grub? #f result)))
+ (alist-cons 'install-bootloader? #f result)))
(option '("full-boot") #f #f
(lambda (opt name arg result)
(alist-cons 'full-boot? #t result)))
@@ -808,7 +810,7 @@ Some ACTIONS support additional ARGS.\n"))
(max-silent-time . 3600)
(verbosity . 0)
(image-size . ,(* 900 (expt 2 20)))
- (install-grub? . #t)))
+ (install-bootloader? . #t)))
\f
;;;
@@ -830,11 +832,11 @@ resulting from command-line parsing."
(leave (_ "no configuration file specified~%"))))
(dry? (assoc-ref opts 'dry-run?))
- (grub? (assoc-ref opts 'install-grub?))
+ (bootloader? (assoc-ref opts 'install-bootloader?))
(target (match args
((first second) second)
(_ #f)))
- (device (and grub?
+ (device (and bootloader?
(grub-configuration-device
(operating-system-bootloader os)))))
@@ -862,7 +864,7 @@ resulting from command-line parsing."
m)
(_ #f))
opts)
- #:grub? grub?
+ #:bootloader? bootloader?
#:target target #:device device))))
#:system system))))
--
2.11.0
next reply other threads:[~2017-01-10 18:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 18:42 David Craven [this message]
2017-01-10 18:42 ` [PATCH 2/2] scripts: system: Rename --no-grub option to --no-bootloader David Craven
2017-01-10 23:10 ` Danny Milosavljevic
2017-01-11 8:23 ` David Craven
2017-01-10 18:51 ` [PATCH 1/2] system: Rename grub to bootloader David Craven
2017-01-12 14:14 ` Ludovic Courtès
2017-01-12 14:45 ` David Craven
2017-01-14 17:40 ` Ludovic Courtès
2017-01-13 6:06 ` Chris Marusich
2017-01-10 23:01 ` Danny Milosavljevic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170110184243.6100-1-david@craven.ch \
--to=david@craven.ch \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).