From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id aN82BK9slF8lQgAA0tVLHw (envelope-from ) for ; Sat, 24 Oct 2020 18:04:31 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id sHAgAK9slF8XSQAA1q6Kng (envelope-from ) for ; Sat, 24 Oct 2020 18:04:31 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9D95B9402A2 for ; Sat, 24 Oct 2020 18:04:30 +0000 (UTC) Received: from localhost ([::1]:49524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWNu1-0000m0-Jn for larch@yhetil.org; Sat, 24 Oct 2020 14:04:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kWNta-0000lc-11 for bug-guix@gnu.org; Sat, 24 Oct 2020 14:04:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kWNtZ-00042H-N9 for bug-guix@gnu.org; Sat, 24 Oct 2020 14:04:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kWNtZ-0006Eo-Ic for bug-guix@gnu.org; Sat, 24 Oct 2020 14:04:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#44196: [PATCH 2/3] system: Add store-directory-prefix to boot-parameters. Resent-From: Miguel =?UTF-8?Q?=C3=81ngel?= Arruga Vivas Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 24 Oct 2020 18:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44196 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 44196@debbugs.gnu.org Received: via spool by 44196-submit@debbugs.gnu.org id=B44196.160356260623930 (code B ref 44196); Sat, 24 Oct 2020 18:04:01 +0000 Received: (at 44196) by debbugs.gnu.org; 24 Oct 2020 18:03:26 +0000 Received: from localhost ([127.0.0.1]:35094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWNt0-0006Ds-5Q for submit@debbugs.gnu.org; Sat, 24 Oct 2020 14:03:26 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]:51316) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWNsy-0006Db-4E for 44196@debbugs.gnu.org; Sat, 24 Oct 2020 14:03:25 -0400 Received: by mail-wm1-f46.google.com with SMTP id v5so5829269wmh.1 for <44196@debbugs.gnu.org>; Sat, 24 Oct 2020 11:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-disposition:content-description; bh=vNFSfIxU9CcJnLHascNORhFg76sSyl3atmXDEfM5XG0=; b=GN/PWd82mYaegXXjvcPa3fiWiQ3gYWIsOe/j9lavooY2twRy1vw8diWxsp4RcNKtyZ ujC1RC+ALgcHeKLBLogXcoJLkMqH2nkP1zg3oZLRnlvfGHquezeOEZ7e29ccESpHVii/ UptJ6vTrfGaWhZKy+b9wgWrUV7IQXPp5fDpGdsmkjebPnY8NX4WirbuVwfSO+aUs2W/Q efjlSdzyUdfBkMtuFv6ZPDUeue202Gs08TaxyGN561b+KpPKxXGtRaTNBf23a7upuhHF iA1mY9R9uaN1TOIiu4f8INieIsWA2t1W26V6zh4NQ2hN7EYlPLEXvsVXKh2tsx+Y3X9q IhPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-disposition :content-description; bh=vNFSfIxU9CcJnLHascNORhFg76sSyl3atmXDEfM5XG0=; b=k+ZVIx0GSFdWpFvjitzY9aoy42/llAVg71ih4nQFbp6aLBofIRRPr1HEp6V1KeqfnK orYPHcov/Nx3GxVX9v6kDhgv+PlDQ/c+m//slFuZPTm1BxihHvONdXV/RCdTt0UrpwWn i1ElFtVDFIp7lCW0t/FFwtzYz21CYnMLLS1z/oUNOipMetTrml/prCDgLolpyp7c3V1R yfyY9VcOYLFWlTx2AffI46a+zPuTe6AvWqPHkHDrGJ/PmWPN9kaXFRrHP9troLb5XWnW AskPwTwQrTUnWFgCHUX5WTwl8AemKLctDgjXKqfYOweRUtdJSGmxBTJlLrQ2eEuKJtXq 0/ug== X-Gm-Message-State: AOAM53121HXCbQaEPvMaLDWiZ01sbJ8CQ8/UtBdnU+RA1R1n9Gwx0Z4+ res5qkkJUZhqB6DkhRdM2J3E3n41BbRv3g== X-Google-Smtp-Source: ABdhPJw2GP/c5d2rwrqtUfKUzquVvm3owdl5/LwH/Gn5U58hem509VeMdTsgpEEghjWPGAmEhF12mg== X-Received: by 2002:a1c:6788:: with SMTP id b130mr8574413wmc.91.1603562598221; Sat, 24 Oct 2020 11:03:18 -0700 (PDT) Received: from unfall (218.139.134.37.dynamic.jazztel.es. [37.134.139.218]) by smtp.gmail.com with ESMTPSA id u15sm12412096wrm.77.2020.10.24.11.03.17 for <44196@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Oct 2020 11:03:17 -0700 (PDT) From: Miguel =?UTF-8?Q?=C3=81ngel?= Arruga Vivas References: <878sbvh5j4.fsf@gmail.com> Date: Sat, 24 Oct 2020 20:02:16 +0200 In-Reply-To: <878sbvh5j4.fsf@gmail.com> ("Miguel =?UTF-8?Q?=C3=81ngel?= Arruga Vivas"'s message of "Sat, 24 Oct 2020 19:56:15 +0200") Message-ID: <87y2jvfqon.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-system-Add-store-directory-prefix-to-boot-parameters.patch Content-Description: 0002-system-add-store-directory-prefix.patch X-Spam-Score: 0.2 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -0.8 (/) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=GN/PWd82; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: OaqI3vv8JjJr >From 527a9271122f7b83f31dc0b910c6704af81bde66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?= Date: Sat, 24 Oct 2020 18:15:53 +0200 Subject: [PATCH 2/2] system: Add store-directory-prefix to boot-parameters. * gnu/machine/ssh.scm (roll-back-managed-host): Use boot-parameters-store-directory-prefix. * gnu/system.scm (define-module): Export boot-parameters-store-directory-prefix. ()[store-directory-prefix]: New field. [boot-parameters-store-directory-prefix]: New accessor. (read-boot-parameters): Read directory-prefix from store field. (operating-system-boot-parameters-file): Add directory-prefix to store field. * guix/scripts/system.scm (reinstall-bootloader): Use boot-parameters-store-directory-prefix. * test/boot-parameters.scm (%default-btrfs-subvolume, %default-store-directory-prefix): New variables. (%grub-boot-parameters): Use %default-store-directory-prefix. (%default-operating-system): Use %default-btrfs-subvolume. (test-boot-parameters): Add directory-prefix. (test optional fields): Add test for directory-prefix. (test os store-directory-prefix): New test. --- gnu/machine/ssh.scm | 3 +++ gnu/system.scm | 19 ++++++++++++++++++- guix/scripts/system.scm | 3 +++ tests/boot-parameters.scm | 23 ++++++++++++++++++++--- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 5020bd362f..a3a12fb54b 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -482,6 +482,8 @@ an environment type of 'managed-host." (list (second boot-parameters)))) (locale -> (boot-parameters-locale (second boot-parameters))) + (store-dir -> (boot-parameters-store-directory-prefix + (second boot-parameters))) (old-entries -> (map boot-parameters->menu-entry (drop boot-parameters 2))) (bootloader -> (operating-system-bootloader @@ -492,6 +494,7 @@ an environment type of 'managed-host." bootloader)) bootloader entries #:locale locale + #:store-directory-prefix store-dir #:old-entries old-entries))) (remote-result (machine-remote-eval machine remote-exp))) (when (eqv? 'error remote-result) diff --git a/gnu/system.scm b/gnu/system.scm index a3122eaa65..30a5c418d0 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -148,6 +148,7 @@ boot-parameters-bootloader-name boot-parameters-bootloader-menu-entries boot-parameters-store-device + boot-parameters-store-directory-prefix boot-parameters-store-mount-point boot-parameters-locale boot-parameters-kernel @@ -299,6 +300,7 @@ directly by the user." boot-parameters-bootloader-menu-entries) (store-device boot-parameters-store-device) (store-mount-point boot-parameters-store-mount-point) + (store-directory-prefix boot-parameters-store-directory-prefix) (locale boot-parameters-locale) (kernel boot-parameters-kernel) (kernel-arguments boot-parameters-kernel-arguments) @@ -394,6 +396,17 @@ file system labels." (_ ;the old format root-device)))) + (store-directory-prefix + (match (assq 'store rest) + (('store . store-data) + (match (assq 'directory-prefix store-data) + (('directory-prefix prefix) prefix) + ;; No directory-prefix found. + (_ #f))) + (_ + ;; No store found, old format. + #f))) + (store-mount-point (match (assq 'store rest) (('store ('device _) ('mount-point mount-point) _ ...) @@ -1294,6 +1307,7 @@ such as '--root' and '--load' to ." (let* ((initrd (and (not (operating-system-hurd os)) (operating-system-initrd-file os))) (store (operating-system-store-file-system os)) + (file-systems (operating-system-file-systems os)) (locale (operating-system-locale os)) (bootloader (bootloader-configuration-bootloader (operating-system-bootloader os))) @@ -1315,6 +1329,7 @@ such as '--root' and '--load' to ." (bootloader-configuration-menu-entries (operating-system-bootloader os))) (locale locale) (store-device (ensure-not-/dev (file-system-device store))) + (store-directory-prefix (btrfs-store-subvolume-file-name file-systems)) (store-mount-point (file-system-mount-point store))))) (define (device->sexp device) @@ -1371,7 +1386,9 @@ being stored into the \"parameters\" file)." (device #$(device->sexp (boot-parameters-store-device params))) (mount-point #$(boot-parameters-store-mount-point - params)))) + params)) + (directory-prefix + #$(boot-parameters-store-directory-prefix params)))) #:set-load-path? #f))) (define-gexp-compiler (operating-system-compiler (os ) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 9ed5c26483..ad998156c2 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -385,6 +385,8 @@ STORE is an open connection to the store." (params (first (profile-boot-parameters %system-profile (list number)))) (locale (boot-parameters-locale params)) + (store-directory-prefix + (boot-parameters-store-directory-prefix params)) (old-generations (delv number (reverse (generation-numbers %system-profile)))) (old-params (profile-boot-parameters @@ -398,6 +400,7 @@ STORE is an open connection to the store." ((bootloader-configuration-file-generator bootloader) bootloader-config entries #:locale locale + #:store-directory-prefix store-directory-prefix #:old-entries old-entries))) (drvs -> (list bootcfg))) (mbegin %store-monad diff --git a/tests/boot-parameters.scm b/tests/boot-parameters.scm index d7e579bc89..a00b227551 100644 --- a/tests/boot-parameters.scm +++ b/tests/boot-parameters.scm @@ -46,6 +46,9 @@ (define %default-initrd (string-append %default-initrd-path "/initrd.cpio.gz")) (define %default-root-device (uuid "abcdef12-3456-7890-abcd-ef1234567890")) (define %default-store-device (uuid "01234567-89ab-cdef-0123-456789abcdef")) +(define %default-btrfs-subvolume "testfs") +(define %default-store-directory-prefix + (string-append "/" %default-btrfs-subvolume)) (define %default-store-mount-point (%store-prefix)) (define %default-multiboot-modules '()) (define %default-locale "es_ES.utf8") @@ -63,6 +66,7 @@ (multiboot-modules %default-multiboot-modules) (locale %default-locale) (store-device %default-store-device) + (store-directory-prefix %default-store-directory-prefix) (store-mount-point %default-store-mount-point))) (define %default-operating-system @@ -81,7 +85,10 @@ (file-system (device %default-store-device) (mount-point %default-store-mount-point) - (type "btrfs")) + (type "btrfs") + (options + (string-append "subvol=" + %default-btrfs-subvolume))) %base-file-systems)))) (define (quote-uuid uuid) @@ -103,6 +110,7 @@ (with-store #t) (store-device (quote-uuid %default-store-device)) + (store-directory-prefix %default-store-directory-prefix) (store-mount-point %default-store-mount-point)) (define (generate-boot-parameters) (define (sexp-or-nothing fmt val) @@ -117,10 +125,12 @@ (sexp-or-nothing " (kernel-arguments ~S)" kernel-arguments) (sexp-or-nothing " (initrd ~S)" initrd) (if with-store - (format #false " (store~a~a)" + (format #false " (store~a~a~a)" (sexp-or-nothing " (device ~S)" store-device) (sexp-or-nothing " (mount-point ~S)" - store-mount-point)) + store-mount-point) + (sexp-or-nothing " (directory-prefix ~S)" + store-directory-prefix)) "") (sexp-or-nothing " (locale ~S)" locale) (sexp-or-nothing " (bootloader-name ~a)" bootloader-name) @@ -149,6 +159,7 @@ (test-read-boot-parameters #:store-device #false) (test-read-boot-parameters #:store-device 'false) (test-read-boot-parameters #:store-mount-point #false) + (test-read-boot-parameters #:store-directory-prefix #false) (test-read-boot-parameters #:multiboot-modules #false) (test-read-boot-parameters #:locale #false) (test-read-boot-parameters #:bootloader-name #false @@ -253,4 +264,10 @@ (operating-system-boot-parameters %default-operating-system %default-root-device))) +(test-equal "from os, store-directory-prefix" + %default-store-directory-prefix + (boot-parameters-store-directory-prefix + (operating-system-boot-parameters %default-operating-system + %default-root-device))) + (test-end "boot-parameters") -- 2.28.0