From 44d5f54e31039d78f156bd9562dca293124eaa76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 9 Sep 2016 23:27:00 +0200 Subject: system: grub: Allow arbitrary kernel file names in 'menu-entry'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . Reported by Tomáš Čech . * gnu/system.scm (system-linux-image-file-name) (operating-system-kernel-file): New procedures. (operating-system-grub.cfg): Use 'operating-system-kernel-file' for the 'kernel' field of 'menu-entry'. (operating-system-parameters-file): Likewise for the 'kernel' entry. (read-boot-parameters): Adjust 'kernel' field so that it contains the absolute file name of the image. * gnu/system/grub.scm (grub-configuration-file)[linux-image-name]: Remove. [entry->gexp]: Assume LINUX is the absolute file name of the kernel image. * doc/guix.texi (GRUB Configuration): Add an example, and adjust 'kernel' field documentation accordingly. --- gnu/system.scm | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'gnu/system.scm') diff --git a/gnu/system.scm b/gnu/system.scm index 080201011c..18b2806fe9 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -69,6 +69,7 @@ operating-system-host-name operating-system-hosts-file operating-system-kernel + operating-system-kernel-file operating-system-kernel-arguments operating-system-initrd operating-system-users @@ -246,6 +247,19 @@ from the initrd." "Return the list of swap services for OS." (map swap-service (operating-system-swap-devices os))) +(define* (system-linux-image-file-name #:optional (system (%current-system))) + "Return the basename of the kernel image file for SYSTEM." + ;; FIXME: Evaluate the conditional based on the actual current system. + (if (string-prefix? "mips" (%current-system)) + "vmlinuz" + "bzImage")) + +(define (operating-system-kernel-file os) + "Return an object representing the absolute file name of the kernel image of +OS." + (file-append (operating-system-kernel os) + "/" (system-linux-image-file-name os))) + (define* (operating-system-directory-base-entries os #:key container?) "Return the basic entries of the 'system' directory of OS for use as the value of the SYSTEM-SERVICE-TYPE service." @@ -710,12 +724,13 @@ listed in OS. The C library expects to find it under ((system (operating-system-derivation os)) (root-fs -> (operating-system-root-file-system os)) (store-fs -> (operating-system-store-file-system os)) - (kernel -> (operating-system-kernel os)) + (label -> (kernel->grub-label (operating-system-kernel os))) + (kernel -> (operating-system-kernel-file os)) (root-device -> (if (eq? 'uuid (file-system-title root-fs)) (uuid->string (file-system-device root-fs)) (file-system-device root-fs))) (entries -> (list (menu-entry - (label (kernel->grub-label kernel)) + (label label) (linux kernel) (linux-arguments (cons* (string-append "--root=" root-device) @@ -739,7 +754,7 @@ this file is the reconstruction of GRUB menu entries for old configurations." #~(boot-parameters (version 0) (label #$label) (root-device #$(file-system-device root)) - (kernel #$(operating-system-kernel os)) + (kernel #$(operating-system-kernel-file os)) (kernel-arguments #$(operating-system-kernel-arguments os)) (initrd #$initrd)) @@ -768,7 +783,14 @@ this file is the reconstruction of GRUB menu entries for old configurations." (boot-parameters (label label) (root-device root) - (kernel linux) + + ;; In the past, we would store the directory name of the kernel instead + ;; of the absolute file name of its image. Detect that and correct it. + (kernel (if (string=? linux (direct-store-path linux)) + (string-append linux "/" + (system-linux-image-file-name)) + linux)) + (kernel-arguments (match (assq 'kernel-arguments rest) ((_ args) args) -- cgit v1.2.3 From ab20d74a4638dc6295aa9b9af276d2a98f238f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 9 Sep 2016 23:38:24 +0200 Subject: system: Build the initrd file name with 'file-append'. * gnu/system.scm (operating-system-initrd-file) (operating-system-grub.cfg): Use 'file-append' to construct the initrd file name. --- gnu/system.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu/system.scm') diff --git a/gnu/system.scm b/gnu/system.scm index 18b2806fe9..4c1de384fa 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -660,7 +660,7 @@ hardware-related operations as necessary when booting a Linux container." (mlet %store-monad ((initrd (make-initrd boot-file-systems #:linux (operating-system-kernel os) #:mapped-devices mapped-devices))) - (return #~(string-append #$initrd "/initrd")))) + (return (file-append initrd "/initrd")))) (define (locale-name->definition* name) "Variant of 'locale-name->definition' that raises an error upon failure." @@ -738,7 +738,7 @@ listed in OS. The C library expects to find it under #~(string-append "--load=" #$system "/boot") (operating-system-kernel-arguments os))) - (initrd #~(string-append #$system "/initrd")))))) + (initrd (file-append system "/initrd")))))) (grub-configuration-file (operating-system-bootloader os) store-fs entries #:old-entries old-entries))) -- cgit v1.2.3 From 9e41130b14ad32c4e1fa756f95d806703056cb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 10 Sep 2016 12:03:47 +0200 Subject: system: Use 'file-append' to denote file names. * gnu/services/avahi.scm, gnu/services/base.scm, gnu/services/databases.scm, gnu/services/dbus.scm, gnu/services/desktop.scm, gnu/services/dict.scm, gnu/services/mail.scm, gnu/services/networking.scm, gnu/services/sddm.scm, gnu/services/spice.scm, gnu/services/ssh.scm, gnu/services/web.scm, gnu/services/xorg.scm, gnu/system.scm: Replace the #~(string-append #$pkg "/bin/foo") idiom with (file-append pkg "/bin/foo"). --- gnu/system.scm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'gnu/system.scm') diff --git a/gnu/system.scm b/gnu/system.scm index 4c1de384fa..7edb018f00 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -472,9 +472,9 @@ then source /run/current-system/profile/etc/profile.d/bash_completion.sh fi\n"))) (etc-service - `(("services" ,#~(string-append #$net-base "/etc/services")) - ("protocols" ,#~(string-append #$net-base "/etc/protocols")) - ("rpc" ,#~(string-append #$net-base "/etc/rpc")) + `(("services" ,(file-append net-base "/etc/services")) + ("protocols" ,(file-append net-base "/etc/protocols")) + ("rpc" ,(file-append net-base "/etc/rpc")) ("login.defs" ,#~#$login.defs) ("issue" ,#~#$issue) ("nsswitch.conf" ,#~#$nsswitch) @@ -482,8 +482,8 @@ fi\n"))) ("bashrc" ,#~#$bashrc) ("hosts" ,#~#$(or (operating-system-hosts-file os) (default-/etc/hosts (operating-system-host-name os)))) - ("localtime" ,#~(string-append #$tzdata "/share/zoneinfo/" - #$(operating-system-timezone os))) + ("localtime" ,(file-append tzdata "/share/zoneinfo/" + (operating-system-timezone os))) ("sudoers" ,(operating-system-sudoers-file os)))))) (define %root-account @@ -547,7 +547,7 @@ use 'plain-file' instead~%") @var{session-environment-service-type}, to be used in @file{/etc/environment}." `(("LANG" . ,(operating-system-locale os)) ("TZ" . ,(operating-system-timezone os)) - ("TZDIR" . ,#~(string-append #$tzdata "/share/zoneinfo")) + ("TZDIR" . ,(file-append tzdata "/share/zoneinfo")) ;; Tell 'modprobe' & co. where to look for modules. ("LINUX_MODULE_DIRECTORY" . "/run/booted-system/kernel/lib/modules") ;; These variables are honored by OpenSSL (libssl) and Git. @@ -571,12 +571,12 @@ use 'plain-file' instead~%") (define %setuid-programs ;; Default set of setuid-root programs. (let ((shadow (@ (gnu packages admin) shadow))) - (list #~(string-append #$shadow "/bin/passwd") - #~(string-append #$shadow "/bin/su") - #~(string-append #$inetutils "/bin/ping") - #~(string-append #$inetutils "/bin/ping6") - #~(string-append #$sudo "/bin/sudo") - #~(string-append #$fuse "/bin/fusermount")))) + (list (file-append shadow "/bin/passwd") + (file-append shadow "/bin/su") + (file-append inetutils "/bin/ping") + (file-append inetutils "/bin/ping6") + (file-append sudo "/bin/sudo") + (file-append fuse "/bin/fusermount")))) (define %sudoers-specification ;; Default /etc/sudoers contents: 'root' and all members of the 'wheel' -- cgit v1.2.3 From d7b342d81556ddee9e369f78255bc76367a004ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 24 Sep 2016 17:39:00 +0900 Subject: system: 'read-boot-parameters' reads the 'initrd' parameter. * gnu/system.scm ()[initrd]: New field. (read-boot-parameters): Read the 'initrd' element and fill in the 'initrd' field of the result. --- gnu/system.scm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'gnu/system.scm') diff --git a/gnu/system.scm b/gnu/system.scm index 7edb018f00..bf79bf1c27 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -101,6 +101,7 @@ boot-parameters-root-device boot-parameters-kernel boot-parameters-kernel-arguments + boot-parameters-initrd read-boot-parameters local-host-aliases @@ -770,7 +771,8 @@ this file is the reconstruction of GRUB menu entries for old configurations." (label boot-parameters-label) (root-device boot-parameters-root-device) (kernel boot-parameters-kernel) - (kernel-arguments boot-parameters-kernel-arguments)) + (kernel-arguments boot-parameters-kernel-arguments) + (initrd boot-parameters-initrd)) (define (read-boot-parameters port) "Read boot parameters from PORT and return the corresponding @@ -794,7 +796,14 @@ this file is the reconstruction of GRUB menu entries for old configurations." (kernel-arguments (match (assq 'kernel-arguments rest) ((_ args) args) - (#f '()))))) ;the old format + (#f '()))) ;the old format + + (initrd + (match (assq 'initrd rest) + (('initrd ('string-append directory file)) ;the old format + (string-append directory file)) + (('initrd (? string? file)) + file))))) (x ;unsupported format (warning (_ "unrecognized boot parameters for '~a'~%") system) -- cgit v1.2.3 From 0f65f54ebd76324653fd5506a7dab42ee44d9255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20de=20La=20Lama?= Date: Wed, 14 Sep 2016 16:13:24 +0200 Subject: system: grub.cfg uses correct file names when store is not in root partition. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . Reported by csanchezdll@gmail.com (Carlos Sánchez de La Lama). * guix/scripts/system.scm (previous-grub-entries): Get the initrd file name from PARAMS. * gnu/system.scm (operating-system-grub.cfg): Use 'operating-system-initrd-file' to retrieve the initrd file name. * gnu/system/grub.scm (strip-mount-point): New procedure. (grub-configuration-file)[entry->gexp]: Call 'strip-mount-point' for LINUX and INITRD. Co-authored-by: Ludovic Courtès --- gnu/system.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gnu/system.scm') diff --git a/gnu/system.scm b/gnu/system.scm index bf79bf1c27..38ae8f1771 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -727,6 +727,7 @@ listed in OS. The C library expects to find it under (store-fs -> (operating-system-store-file-system os)) (label -> (kernel->grub-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)) (uuid->string (file-system-device root-fs)) (file-system-device root-fs))) @@ -739,7 +740,7 @@ listed in OS. The C library expects to find it under #~(string-append "--load=" #$system "/boot") (operating-system-kernel-arguments os))) - (initrd (file-append system "/initrd")))))) + (initrd initrd))))) (grub-configuration-file (operating-system-bootloader os) store-fs entries #:old-entries old-entries))) -- cgit v1.2.3