From patchwork Fri Oct 28 10:07:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Marusich X-Patchwork-Id: 16889 Received: (qmail 123465 invoked by uid 89); 28 Oct 2016 10:08:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=reconstruction X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: lists.gnu.org Received: from lists.gnu.org (HELO lists.gnu.org) (208.118.235.17) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Oct 2016 10:08:39 +0000 Received: from localhost ([::1]:47947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c045V-0004uw-Qj for patchwork@sourceware.org; Fri, 28 Oct 2016 06:08:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c044m-0004Rr-2K for guix-devel@gnu.org; Fri, 28 Oct 2016 06:07:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c044h-0003y2-Ny for guix-devel@gnu.org; Fri, 28 Oct 2016 06:07:52 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35263) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c044h-0003xl-B8 for guix-devel@gnu.org; Fri, 28 Oct 2016 06:07:47 -0400 Received: by mail-pf0-x244.google.com with SMTP id s8so876524pfj.2 for ; Fri, 28 Oct 2016 03:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tRX3zwOv5tE1UDryETXT8niM8RKsWW5ybvf5gUAStnk=; b=rOtY9JK2vPPqr6QQo5tH33VBVyy2emiRC287O18dosD/L48A/9WT/r5MmgtBj7H3GS pC9xQCWpkhzg+hHgl6fx1LHT229+K8NTdbixehj+9gXUICJ+rlcnDSVo/p6j+h48zmEf gQFOauIuQ96/GNEGxQa+sOlnofuYlCCGZKtQWSrTZJ+ZaOnt9R+kUtybbvb9uSIjTC1W R1oo1rNqiUlQ0Qw9G1nwb3tWhYhrWZzoZgxDPYaGpkgJfBEg/TH55dGU4S2kMyHMFzJk qEnxdcDy2Vvi45IbSfOYSPWbcb0HgXCWT3fZCAwRsEqy8T8TgJt4XAnXQShGg5E+e/DT cA9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tRX3zwOv5tE1UDryETXT8niM8RKsWW5ybvf5gUAStnk=; b=ki3HqUpJzsU5O4ME51K1Jkz8ix+VS3dEmvjdUlP+WcIAdaNY5TgDIvF5hjQC//FAoJ m1pBQw/gQ0baqSp4Usrn2SYqEIRkJyZDae36WIwVW3ij3fDfRC/YX8m/EXv3S12k23bP MLkmJLrRUY/9+QqjhlhjRgIZeXj5PK4vVQ5fJVYV4M+69aDNoGTo22QmM7koG8O+BbT2 uoe8s1CKwRKtrvIGhUuPimFuxRQPaNjkAvD2OYRZu8+4aL8bXZakA31u5icuBXKT2t05 BvGcasdEF7rtCNpAASJZDNa56UvC4sl++s+Oxel+p/TL+uN5e8GVmhGLeb7T1+zXx845 XFKg== X-Gm-Message-State: ABUngvcS0271+Ug11pDthI0wHM7/fKNPVdDK3C4YJZun5AwcClVHyKmzXjeeUuVZ2dAjpg== X-Received: by 10.98.64.195 with SMTP id f64mr1174450pfd.16.1477649265947; Fri, 28 Oct 2016 03:07:45 -0700 (PDT) Received: from garuda.hsd1.wa.comcast.net. ([2601:602:9d80:188d:4e0f:6eff:fef6:70b9]) by smtp.gmail.com with ESMTPSA id t7sm17798508pfa.22.2016.10.28.03.07.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Oct 2016 03:07:45 -0700 (PDT) From: cmmarusich@gmail.com To: guix-devel@gnu.org Subject: [PATCH 01/10] * gnu/system.scm (): Add 'store-device' and 'store-fs-mount-point'. Date: Fri, 28 Oct 2016 03:07:18 -0700 Message-Id: <20161028100727.1182-2-cmmarusich@gmail.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161028100727.1182-1-cmmarusich@gmail.com> References: <20161028100727.1182-1-cmmarusich@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::244 X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+patchwork=sourceware.org@gnu.org Sender: "Guix-devel" From: Chris Marusich In a future commit, we will restructure the grub.cfg generation logic to use this information, to enable the implementation of 'guix system switch-generation' and 'guix system roll-back'. --- gnu/system.scm | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 38ae8f1..ff84b63 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès ;;; Copyright © 2015 Mark H Weaver ;;; Copyright © 2015, 2016 Alex Kost +;;; Copyright © 2016 Chris Marusich ;;; ;;; This file is part of GNU Guix. ;;; @@ -99,6 +100,8 @@ boot-parameters? boot-parameters-label boot-parameters-root-device + boot-parameters-store-device + boot-parameters-store-fs-mount-point boot-parameters-kernel boot-parameters-kernel-arguments boot-parameters-initrd @@ -750,17 +753,25 @@ listed in OS. The C library expects to find it under 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->grub-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-kernel-arguments os)) - (initrd #$initrd)) - #:set-load-path? #f))) + (gexp->file + "parameters" + #~(boot-parameters (version 1) + (label #$label) + (root-device #$(file-system-device root)) + (store-device + #$(case (file-system-title store) + ((uuid) (file-system-device store)) + ((label) (file-system-device store)) + (else #f))) + (store-fs-mount-point #$(file-system-mount-point store)) + (kernel #$(operating-system-kernel-file os)) + (kernel-arguments + #$(operating-system-kernel-arguments os)) + (initrd #$initrd)) + #:set-load-path? #f))) ;;; @@ -770,7 +781,16 @@ this file is the reconstruction of GRUB menu entries for old configurations." (define-record-type* 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 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-fs-mount-point boot-parameters-store-fs-mount-point) (kernel boot-parameters-kernel) (kernel-arguments boot-parameters-kernel-arguments) (initrd boot-parameters-initrd)) @@ -786,6 +806,10 @@ this file is the reconstruction of GRUB menu entries for old configurations." (boot-parameters (label label) (root-device root) + ;; For backwards compatibility, we assume the store device and the + ;; root device are the same. + (store-device root) + (store-fs-mount-point "/") ;; 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. @@ -805,6 +829,22 @@ this file is the reconstruction of GRUB menu entries for old configurations." (string-append directory file)) (('initrd (? string? file)) file))))) + (('boot-parameters ('version 1) + ('label label) + ('root-device root) + ('store-device store) + ('store-fs-mount-point store-fs-mount-point) + ('kernel linux) + ('kernel-arguments arguments) + ('initrd initrd)) + (boot-parameters + (label label) + (root-device root) + (store-device store) + (store-fs-mount-point store-fs-mount-point) + (kernel linux) + (kernel-arguments arguments) + (initrd initrd))) (x ;unsupported format (warning (_ "unrecognized boot parameters for '~a'~%") system)