From patchwork Thu Sep 26 10:09:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herman Rimm X-Patchwork-Id: 31499 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B400F27BBEA; Thu, 26 Sep 2024 11:12:48 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1094F27BBE2 for ; Thu, 26 Sep 2024 11:12:48 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stlTK-0002zc-WC; Thu, 26 Sep 2024 06:11:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1stlTI-0002xh-96 for guix-patches@gnu.org; Thu, 26 Sep 2024 06:11:40 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1stlTH-0007Px-Th for guix-patches@gnu.org; Thu, 26 Sep 2024 06:11:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=QJoHxVO8C/6UH6ICoo6AdFAwpNBVhW1OBOxGDYtZPB8=; b=qxxHmfhdMOGNJDpEJurBpuUA2v+9/iiP2T2N7Al535yzmh0JqmKNppDgaAOZj2nDvxt0gItty0TXBOihumnyr38XeLuDsLi5gUszagWlYI39mDE8wvKRDvQ/2kF+7GSAVr+tR+++12NrBZOBRid/4XwK8J+fy+UUnNROa3+cR5P9GVXe5kaSHlwDf6Tlw7DGAx5/DeYyZhGUY/lgLfohaHTAGeIki9L898ZlyliXlobkGetqZI2y2H97tZl5/dtXly0WOuRZ1ZeWkcWppK86PwGZhIvJnGTdkfnxzvy2BnAKEt56UdTs2Yp08XjLP2lUA1ERngFcczywKEb3/JFduQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1stlTi-0003VD-QA; Thu, 26 Sep 2024 06:12:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73202] [PATCH v3 10/14] gnu: bootloader: Add device-subvol field to menu-entry record. Resent-From: Herman Rimm Original-Sender: "Debbugs-submit" Resent-CC: lilah@lunabee.space, guix-patches@gnu.org Resent-Date: Thu, 26 Sep 2024 10:12:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73202 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73202@debbugs.gnu.org Cc: Lilah Tascheter , Lilah Tascheter X-Debbugs-Original-Xcc: Lilah Tascheter Received: via spool by 73202-submit@debbugs.gnu.org id=B73202.172734550613318 (code B ref 73202); Thu, 26 Sep 2024 10:12:06 +0000 Received: (at 73202) by debbugs.gnu.org; 26 Sep 2024 10:11:46 +0000 Received: from localhost ([127.0.0.1]:55502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stlTN-0003Sd-W5 for submit@debbugs.gnu.org; Thu, 26 Sep 2024 06:11:46 -0400 Received: from 81-205-150-117.fixed.kpn.net ([81.205.150.117]:53171 helo=email.rimm.ee) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stlT0-0003PN-N9 for 73202@debbugs.gnu.org; Thu, 26 Sep 2024 06:11:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rimm.ee; s=herman; t=1727345441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0CaZ9OnPl3/7G2AVIzFTBFAwD5Y8HdNbaKxoXkEs1cA=; b=oHsBDNbo9zsYzY5wl6UGUWFYBDWzaMVU78yNAvX7nrvXzPzjTUPztp1HTlGaIgycYZkeC6 f/YEjFKUb9AWndNu8QnjSx2zwoNsOiX5XA0dz0sQI4+zHtYkRUhyONNNW4aqQ6rvts80iq +MNBkaPMVvQNGxPJH00ATf7rE4EB02XHOZzqbtIqOtpjzDYxZeWhHQQeO5sXkQDd0E2wLf 8FF14MHqLRl7xLcHzDd0CVW9Y4LbsBXxidGKq+phc/YmnVrKBc4P2kJguZCbdfBCIKDtv+ rUtxYdxMyGULTZNxHU0ZE+kR07qjTuKs3sYIrxNl67VUbEEDfdGL2natief0Mw== Received: by 81-205-150-117.fixed.kpn.net (OpenSMTPD) with ESMTPSA id 8c230017 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Thu, 26 Sep 2024 10:10:41 +0000 (UTC) Date: Thu, 26 Sep 2024 12:09:07 +0200 Message-ID: <33b51456dc709d17c8be3776471e0599f83eaec1.1727345067.git.herman@rimm.ee> X-Mailer: git-send-email 2.45.2 In-Reply-To: <74c789e74594d538308d33633ed8540283dcde49.1727345067.git.herman@rimm.ee> References: <74c789e74594d538308d33633ed8540283dcde49.1727345067.git.herman@rimm.ee> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Herman Rimm X-ACL-Warn: , Herman Rimm via Guix-patches X-Patchwork-Original-From: Herman Rimm via Guix-patches via From: Herman Rimm Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: Lilah Tascheter * gnu/bootloader.scm (menu-entry-device-subvol): Add and export field. (normalize-file): Add procedure. (device->sexp): Match device-subvol and include in S-expression. (sexp->menu-entry): Try match device-subvol and include in menu-entry. * gnu/system/boot.scm (boot-parameters->menu-entry): Add device-subvol value to menu-entry. Change-Id: I3654d160f7306bb45a78b82ea6b249ff4281f739 --- gnu/bootloader.scm | 51 ++++++++++++++++++++++++++++++++++----------- gnu/system/boot.scm | 1 + 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index c77de6f55e..f1352122a9 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -51,15 +51,17 @@ (define-module (gnu bootloader) menu-entry? menu-entry-label menu-entry-device + menu-entry-device-mount-point + menu-entry-device-subvol menu-entry-linux menu-entry-linux-arguments menu-entry-initrd - menu-entry-device-mount-point menu-entry-multiboot-kernel menu-entry-multiboot-arguments menu-entry-multiboot-modules menu-entry-chain-loader + normalize-file menu-entry->sexp sexp->menu-entry @@ -126,6 +128,8 @@ (define-record-type* (default #f)) (device-mount-point menu-entry-device-mount-point (default #f)) + (device-subvol menu-entry-device-subvol + (default #f)) (linux menu-entry-linux (default #f)) (linux-arguments menu-entry-linux-arguments @@ -142,6 +146,18 @@ (define-record-type* (chain-loader menu-entry-chain-loader (default #f))) ; string, path of efi file +(define (normalize-file entry file) + "Normalize a file FILE stored in a menu entry into one suitable for a +bootloader. Realizes device-mount-point and device-subvol." + (match-menu-entry entry (device-mount-point device-subvol) + ;; Avoid using cut procedure from SRFI-26 inside G-exp. + (let ((mount (and=> device-mount-point (cut string-trim <> #\/)))) + #~(let* ((file (string-trim #$file #\/)) + (file (if (and #$mount (string-prefix? #$mount file)) + (substring file (string-length #$mount)) + file))) + (string-append (or #$device-subvol "") "/" file))))) + (define (report-menu-entry-error menu-entry) (raise (condition @@ -169,7 +185,7 @@ (define (menu-entry->sexp entry) `(label ,(file-system-label->string label))) (_ device))) (match entry - (($ label device mount-point + (($ label device mount-point subvol (? identity linux) linux-arguments (? identity initrd) #f () () #f) `(menu-entry (version 0) @@ -178,8 +194,9 @@ (define (menu-entry->sexp entry) (device-mount-point ,mount-point) (linux ,linux) (linux-arguments ,linux-arguments) - (initrd ,initrd))) - (($ label device mount-point #f () #f + (initrd ,initrd) + (device-subvol ,subvol))) + (($ label device mount-point subvol #f () #f (? identity multiboot-kernel) multiboot-arguments multiboot-modules #f) `(menu-entry (version 0) @@ -188,19 +205,23 @@ (define (menu-entry->sexp entry) (device-mount-point ,mount-point) (multiboot-kernel ,multiboot-kernel) (multiboot-arguments ,multiboot-arguments) - (multiboot-modules ,multiboot-modules))) - (($ label device mount-point #f () #f #f () () + (multiboot-modules ,multiboot-modules) + (device-subvol ,subvol))) + (($ label device mount-point subvol #f () #f #f () () (? identity chain-loader)) `(menu-entry (version 0) (label ,label) (device ,(device->sexp device)) (device-mount-point ,mount-point) - (chain-loader ,chain-loader))) + (chain-loader ,chain-loader) + (device-subvol ,subvol))) (_ (report-menu-entry-error entry)))) (define (sexp->menu-entry sexp) "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a record." + ;; XXX: The match ORs shadow subvol. + (define subvol #f) (define (sexp->device device-sexp) (match device-sexp (('uuid type uuid-string) @@ -213,35 +234,41 @@ (define (sexp->menu-entry sexp) ('label label) ('device device) ('device-mount-point mount-point) ('linux linux) ('linux-arguments linux-arguments) - ('initrd initrd) _ ...) + ('initrd initrd) + (or ('device-subvol subvol _ ...) (_ ...))) (menu-entry (label label) (device (sexp->device device)) (device-mount-point mount-point) + (device-subvol subvol) (linux linux) (linux-arguments linux-arguments) (initrd initrd))) (('menu-entry ('version 0) ('label label) ('device device) - ('device-mount-point mount-point) + ('device-mount-point mount-point) ('device-subvol subvol) ('multiboot-kernel multiboot-kernel) ('multiboot-arguments multiboot-arguments) - ('multiboot-modules multiboot-modules) _ ...) + ('multiboot-modules multiboot-modules) + (or ('device-subvol subvol _ ...) (_ ...))) (menu-entry (label label) (device (sexp->device device)) (device-mount-point mount-point) + (device-subvol subvol) (multiboot-kernel multiboot-kernel) (multiboot-arguments multiboot-arguments) (multiboot-modules multiboot-modules))) (('menu-entry ('version 0) ('label label) ('device device) - ('device-mount-point mount-point) - ('chain-loader chain-loader) _ ...) + ('device-mount-point mount-point) ('device-subvol subvol) + ('chain-loader chain-loader) + (or ('device-subvol subvol _ ...) (_ ...))) (menu-entry (label label) (device (sexp->device device)) (device-mount-point mount-point) + (device-subvol subvol) (chain-loader chain-loader))))) diff --git a/gnu/system/boot.scm b/gnu/system/boot.scm index 54e5673a54..98fcd2b3a0 100644 --- a/gnu/system/boot.scm +++ b/gnu/system/boot.scm @@ -328,6 +328,7 @@ (define (boot-parameters->menu-entry conf) (label (boot-parameters-label conf)) (device (boot-parameters-store-device conf)) (device-mount-point (boot-parameters-store-mount-point conf)) + (device-subvol (boot-parameters-store-directory-prefix conf)) (linux (and (not multiboot?) kernel)) (linux-arguments (if (not multiboot?) (boot-parameters-kernel-arguments conf)