From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xp8-00034N-2E for guix-patches@gnu.org; Fri, 21 Apr 2017 08:38:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1Xp5-0004Kp-Ru for guix-patches@gnu.org; Fri, 21 Apr 2017 08:38:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:33612) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d1Xp5-0004Kg-P3 for guix-patches@gnu.org; Fri, 21 Apr 2017 08:38:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d1Xp5-0003hn-Ix for guix-patches@gnu.org; Fri, 21 Apr 2017 08:38:03 -0400 Subject: bug#26544: [PATCH v4 03/10] system: Factorize operating-system-boot-parameters-file. Resent-Message-ID: From: Danny Milosavljevic Date: Fri, 21 Apr 2017 14:37:07 +0200 Message-Id: <20170421123714.2395-4-dannym@scratchpost.org> In-Reply-To: <20170421123714.2395-1-dannym@scratchpost.org> References: <86h91ikw4m.fsf@gmail.com> <20170421123714.2395-1-dannym@scratchpost.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 26544@debbugs.gnu.org * gnu/system.scm (operating-system-boot-parameters): New variable. (operating-system-boot-parameters-file): Modify. --- gnu/system.scm | 64 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 44190bdfc..6601147e9 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -769,27 +769,49 @@ device in a ." ((label) (file-system-device fs)) (else #f))) -(define (operating-system-boot-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." - (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->boot-label - (operating-system-kernel os)))) - (gexp->file "parameters" - #~(boot-parameters - (version 0) - (label #$label) - (root-device #$(file-system-device root)) - (kernel #$(operating-system-kernel-file os)) - (kernel-arguments - #$(operating-system-user-kernel-arguments os)) - (initrd #$initrd) - (store - (device #$(fs->boot-device store)) - (mount-point #$(file-system-mount-point store)))) - #:set-load-path? #f))) +(define (operating-system-boot-parameters os system root-device) + "Return a monadic record that describes the boot parameters of OS. +SYSTEM is optional. If given, adds kernel arguments for that system to ." + (mlet* %store-monad + ((initrd (operating-system-initrd-file os)) + (store -> (operating-system-store-file-system os)) + (label -> (kernel->boot-label (operating-system-kernel os)))) + (return (boot-parameters + (label label) + (root-device root-device) + (kernel (operating-system-kernel-file os)) + (kernel-arguments + (operating-system-user-kernel-arguments os)) + (initrd initrd) + (store-device (fs->boot-device store)) + (store-mount-point (file-system-mount-point store)))))) + +(define* (operating-system-boot-parameters-file os #:optional (system.drv #f)) + "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. +SYSTEM.DRV is optional. If given, adds kernel arguments for that system to the +returned file (since the returned file is then usually stored into the +content-addressed \"system\" directory, it's usually not a good idea +to give it because the content hash would change by the content hash +being stored into the \"parameters\" file)." + (mlet* %store-monad ((root -> (operating-system-root-file-system os)) + (device -> (file-system-device root)) + (params (operating-system-boot-parameters os + system.drv + device))) + (gexp->file "parameters" + #~(boot-parameters + (version 0) + (label #$(boot-parameters-label params)) + (root-device #$(boot-parameters-root-device params)) + (kernel #$(boot-parameters-kernel params)) + (kernel-arguments + #$(boot-parameters-kernel-arguments params)) + (initrd #$(boot-parameters-initrd params)) + (store + (device #$(boot-parameters-store-device params)) + (mount-point #$(boot-parameters-store-mount-point params)))) + #:set-load-path? #f))) ;;;