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 Jq+BK/Zv1l9KfAAA0tVLHw (envelope-from ) for ; Sun, 13 Dec 2020 19:48:06 +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 6JXOJvZv1l/sAwAA1q6Kng (envelope-from ) for ; Sun, 13 Dec 2020 19:48:06 +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 3D6F19402A2 for ; Sun, 13 Dec 2020 19:48:06 +0000 (UTC) Received: from localhost ([::1]:52276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koXLh-0008Tq-1t for larch@yhetil.org; Sun, 13 Dec 2020 14:48:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koXKg-0008Pi-SK for guix-patches@gnu.org; Sun, 13 Dec 2020 14:47:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:38778) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1koXKf-0001pk-UT for guix-patches@gnu.org; Sun, 13 Dec 2020 14:47:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1koXKf-0000cB-RL for guix-patches@gnu.org; Sun, 13 Dec 2020 14:47:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#41066] [PATCH] gnu: bootloader: Improve support for chain loading. Resent-From: Stefan Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 13 Dec 2020 19:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41066 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Danny Milosavljevic Received: via spool by 41066-submit@debbugs.gnu.org id=B41066.16078887662093 (code B ref 41066); Sun, 13 Dec 2020 19:47:01 +0000 Received: (at 41066) by debbugs.gnu.org; 13 Dec 2020 19:46:06 +0000 Received: from localhost ([127.0.0.1]:50316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koXJl-0000Xh-NS for submit@debbugs.gnu.org; Sun, 13 Dec 2020 14:46:06 -0500 Received: from smtpout2.vodafonemail.de ([145.253.239.133]:58484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koXJi-0000WG-TM for 41066@debbugs.gnu.org; Sun, 13 Dec 2020 14:46:04 -0500 Received: from smtp.vodafone.de (unknown [10.2.0.34]) by smtpout2.vodafonemail.de (Postfix) with ESMTP id 9C1D9127165; Sun, 13 Dec 2020 20:28:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafonemail.de; s=vfde-smtpout-mb-15sep; t=1607887738; bh=Px+2IVbzpgznVtt6PaLFpQqZbMbwzEumBYBxWDYL5fc=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=PPK/kcsVTEX3gKeddZpui3dkr9Fx/Pg9VrcbpWVxFYy4kMqwsn5JQN0JZnu7nTfql u8JGWobz9RCMdTENpJeigSSiAFFYQdzrPpebQNWfsuFG2HJzwhFsLhirttwAzsEBb7 fBTa0ujslwuP+XroNpsJPvwD/sAgylDhiwdpAwBc= Received: from macbook-pro.kuh-wiese.my-router.de (dslb-002-202-077-025.002.202.pools.vodafone-ip.de [2.202.77.25]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.vodafone.de (Postfix) with ESMTPSA id 60736140236; Sun, 13 Dec 2020 19:28:58 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) From: Stefan In-Reply-To: <9A42CB53-1D8B-406C-B046-46883BC9962F@vodafonemail.de> Date: Sun, 13 Dec 2020 20:28:57 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <101A8A97-C37B-46B4-84E2-DDE68D74B3F0@vodafonemail.de> References: <7A4ABEA8-4500-4D55-BCCE-BFB37FB06B2C@vodafonemail.de> <20200524131316.4c6e8a50@scratchpost.org> <3197004D-0131-4781-99FD-60EBE434E794@vodafonemail.de> <023CBBED-35CD-4AD3-97C4-0DE0B7623B9A@vodafonemail.de> <6E5ECFBA-57F4-485F-9403-1D04CF82062D@vodafonemail.de> <4D71A75A-5722-457C-A5CE-98CE51A53450@vodafonemail.de> <975EC414-6A81-444B-9BB0-AE303C6A9511@vodafonemail.de> <20201116103346.55ff8422@scratchpost.org> <20201117164755.1a27422b@scratchpost.org> <20201118190559.1f9fed82@scratchpost.org> <10AB4620-ECD3-4199-A9E4-CE0F906AC3BE@vodafonemail.de> <98EF392F-E84E-4CEB-8166-C28D16552057@vodafonemail.de> <7FDE10B2-EA52-4598-AE22-25181DE76A86@vodafonemail.de> <20201213154149.47423b18@scratchpost.org> <9A42CB53-1D8B-406C-B046-46883BC9962F@vodafonemail.de> X-Mailer: Apple Mail (2.3124) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 5458 X-purgate-ID: 155817::1607887738-000006AA-6996ED6B/0/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: , Cc: 41066@debbugs.gnu.org, Mathieu Othacehe Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 0.70 Authentication-Results: aspmx1.migadu.com; dkim=fail (headers rsa verify failed) header.d=vodafonemail.de header.s=vfde-smtpout-mb-15sep header.b=PPK/kcsV; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 3D6F19402A2 X-Spam-Score: 0.70 X-Migadu-Scanner: scn1.migadu.com X-TUID: 4rFy2QRXrLFl * gnu/bootloader.scm (chain-efi-bootloader-installer): New function to = call its final-installer argument before copying files from the collection = directory of a bootloader profile to the bootloader target directory, preferring a = target of /mnt/boot/efi over /boot/efi, and only copying if source and destination directories exist. * (efi-bootloader-chain): Using (chain-efi-bootloader-installer) if the = #:installer argument is false. The new chain-efi-bootloader-installer allows a customization of = installers like (install-grub-efi-netboot): (operating-system (bootloader (bootloader-configuration (bootloader (efi-bootloader-chain (list (file-append firmware "/boot/") (file-append u-boot-my-scb "/libexec/u-boot.bin") (plain-file "config.txt" "kernel=3Du-boot.bin")) grub-efi-netboot-bootloader #:hooks my-special-bootloader-profile-manipulator #:installer (chain-efi-bootloader-installer (install-grub-efi-netboot = "efi/boot"))) (target "/boot")))) --- gnu/bootloader.scm | 54 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 6d7352ddd2..ce62d315ef 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -70,6 +70,7 @@ %bootloaders lookup-bootloader-by-name =20 + chain-efi-bootloader-installer efi-bootloader-chain)) =20 ^L @@ -311,6 +312,38 @@ HOOKS lists additional hook functions to modify the = profile." (allow-collisions? #f) (relative-symlinks? #f))) =20 +(define (chain-efi-bootloader-installer final-installer) + "Define a new bootloader installer gexp, which will invoke = FINAL-INSTALLER +before it will copy the content from a collection/ directory of its = 'bootloader' +argument into the directory of its 'target' argument. + +This order is by intention to allow overwriting bootloader files like +device-trees with own files provided in that collection/ directory. + +The generated bootloader function will usually be used in this way: + + (efi-bootloader-chain =E2=80=A6 #:installer = (chain-efi-bootloader-installer =E2=80=A6))" + + #~(lambda (bootloader target mount-point) + (#$final-installer bootloader target mount-point) + (let* ((mount-point/target (string-append mount-point target)) + ;; When installing Guix, it is common to mount TARGET = below + ;; MOUNT-POINT rather than the root directory. + (bootloader-target (if (file-exists? mount-point/target) + mount-point/target + target)) + (collection (string-append bootloader "/collection"))) + (if (and (eq? (and=3D> (stat collection #f) stat:type) + 'directory) + (eq? (and=3D> (stat bootloader-target #f) stat:type) + 'directory)) + ;; Now copy the content of the collection directory. + (copy-recursively collection bootloader-target + #:follow-symlinks? #t + #:log (%make-void-port "w")) + (error "expecting two directories for bootloader = installation" + collection bootloader-target))))) + (define* (efi-bootloader-chain files final-bootloader #:key @@ -330,10 +363,16 @@ of the directory itself will be symlinked into the = collection/ directory. The procedures in the HOOKS list can be used to further modify the = bootloader profile. It is possible to pass a single function instead of a list. =20 -If the INSTALLER argument is used, then this function will be called to = install -the bootloader. Otherwise the installer of the FINAL-BOOTLOADER will = be called." +If the INSTALLER argument is used, then this procedure will be called = to install +the bootloader and handle the files inside the collection directory of = the +profile. Otherwise the generated procedure from + + (chain-efi-bootloader-installer (bootloader-installer = FINAL-BOOTLOADER)) + +will be used to install the bootloader." (let* ((final-installer (or installer - (bootloader-installer final-bootloader))) + (chain-efi-bootloader-installer + (bootloader-installer = final-bootloader)))) (profile (efi-bootloader-profile files (bootloader-package = final-bootloader) (if (list? hooks) @@ -342,11 +381,4 @@ the bootloader. Otherwise the installer of the = FINAL-BOOTLOADER will be called. (bootloader (inherit final-bootloader) (package profile) - (installer - #~(lambda (bootloader target mount-point) - (#$final-installer bootloader target mount-point) - (copy-recursively - (string-append bootloader "/collection") - (string-append mount-point target) - #:follow-symlinks? #t - #:log (%make-void-port "w"))))))) + (installer final-installer)))) --=20 2.29.2