From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 6qe1JljMwl+EIwAA0tVLHw (envelope-from ) for ; Sat, 28 Nov 2020 22:16:56 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id KIbfIVjMwl8kMQAAbx9fmQ (envelope-from ) for ; Sat, 28 Nov 2020 22:16:56 +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 E576F940482 for ; Sat, 28 Nov 2020 22:16:55 +0000 (UTC) Received: from localhost ([::1]:60514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kj8WU-0006ct-EU for larch@yhetil.org; Sat, 28 Nov 2020 17:16:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kj8Ve-0006cf-8h for guix-patches@gnu.org; Sat, 28 Nov 2020 17:16:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:37750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kj8Ve-00012V-0n for guix-patches@gnu.org; Sat, 28 Nov 2020 17:16:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kj8Vd-0005bc-Sw for guix-patches@gnu.org; Sat, 28 Nov 2020 17:16: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: Sat, 28 Nov 2020 22:16: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 Cc: 41066@debbugs.gnu.org, Mathieu Othacehe , Efraim Flashner , Maxim Cournoyer Received: via spool by 41066-submit@debbugs.gnu.org id=B41066.160660170721480 (code B ref 41066); Sat, 28 Nov 2020 22:16:01 +0000 Received: (at 41066) by debbugs.gnu.org; 28 Nov 2020 22:15:07 +0000 Received: from localhost ([127.0.0.1]:49296 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kj8Ul-0005aN-1z for submit@debbugs.gnu.org; Sat, 28 Nov 2020 17:15:07 -0500 Received: from vsmx011.vodafonemail.xion.oxcs.net ([153.92.174.89]:31218) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kj8Ui-0005ZV-Cw for 41066@debbugs.gnu.org; Sat, 28 Nov 2020 17:15:05 -0500 Received: from vsmx003.vodafonemail.xion.oxcs.net (unknown [192.168.75.197]) by mta-5-out.mta.xion.oxcs.net (Postfix) with ESMTP id D71C559D646; Sat, 28 Nov 2020 22:14:58 +0000 (UTC) Received: from macbook-pro.kuh-wiese.my-router.de (unknown [88.70.113.247]) by mta-7-out.mta.xion.oxcs.net (Postfix) with ESMTPA id 045E65399F0; Sat, 28 Nov 2020 22:14:47 +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: <10AB4620-ECD3-4199-A9E4-CE0F906AC3BE@vodafonemail.de> Date: Sat, 28 Nov 2020 23:14:47 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <98EF392F-E84E-4CEB-8166-C28D16552057@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> X-Mailer: Apple Mail (2.3124) X-VADE-STATUS: LEGIT X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.7 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.27 X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; 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-TUID: Pd/U04xsRUli * gnu/bootloader.scm (chain-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-bootloader-installer) if the = #:installer argument is false. * (bootloader-collection manifest): Removed unneeded imported modules. * gnu/bootloader/grub.scm (font-file): Using (canonicalize-path), as = symlinks from a bootloader profile do not work on a tftp server when network = booting. The new chain-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-bootloader-installer (install-grub-efi-netboot = "efi/boot"))) (target "/boot")))) --- gnu/bootloader.scm | 70 ++++++++++++++++++++++++++++------------- gnu/bootloader/grub.scm | 15 +++++++-- 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 6d7352ddd2..491a839a65 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -70,6 +70,7 @@ %bootloaders lookup-bootloader-by-name =20 + chain-bootloader-installer efi-bootloader-chain)) =20 ^L @@ -233,14 +234,14 @@ record." (leave (G_ "~a: no such bootloader~%") name))) =20 (define (efi-bootloader-profile files bootloader-package hooks) - "Creates a profile with BOOTLOADER-PACKAGE and a directory = collection/ with + "Creates a profile with BOOTLOADER-PACKAGE and a directory collection = with links to additional FILES from the store. This collection is meant to = be used by the bootloader installer. =20 FILES is a list of file or directory names from the store, which will = be -symlinked into the collection/ directory. If a directory name ends = with '/', +symlinked into the collection directory. If a directory name ends with = '/', then the directory content instead of the directory itself will be = symlinked -into the collection/ directory. +into the collection directory. =20 FILES may contain file like objects produced by functions like = plain-file, local-file, etc., or package contents produced with file-append. @@ -248,10 +249,7 @@ local-file, etc., or package contents produced with = file-append. HOOKS lists additional hook functions to modify the profile." (define (bootloader-collection manifest) (define build - (with-imported-modules '((guix build utils) - (ice-9 ftw) - (srfi srfi-1) - (srfi srfi-26)) + (with-imported-modules '((guix build utils)) #~(begin (use-modules ((guix build utils) #:select (mkdir-p strip-store-file-name)) @@ -311,6 +309,37 @@ HOOKS lists additional hook functions to modify the = profile." (allow-collisions? #f) (relative-symlinks? #f))) =20 +(define (chain-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-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"))) + (when (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")))))) + + (define* (efi-bootloader-chain files final-bootloader #:key @@ -319,21 +348,27 @@ HOOKS lists additional hook functions to modify = the profile." "Define a bootloader chain with FINAL-BOOTLOADER as the final = bootloader and certain directories and files from the store given in the list of = FILES. =20 -FILES may contain file like objects produced by functions like = plain-file, +FILES may contain file like objects produced by procedures like = plain-file, local-file, etc., or package contents produced with file-append. They = will be -collected inside a directory collection/ inside a generated bootloader = profile, +collected inside a directory collection inside a generated bootloader = profile, which will be passed to the INSTALLER. =20 If a directory name in FILES ends with '/', then the directory content = instead -of the directory itself will be symlinked into the collection/ = directory. +of the directory itself will be symlinked into the collection = directory. =20 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-bootloader-installer (bootloader-installer FINAL-BOOTLOADER)) + +will be used to install the bootloader." (let* ((final-installer (or installer - (bootloader-installer final-bootloader))) + (chain-bootloader-installer + (bootloader-installer = final-bootloader)))) (profile (efi-bootloader-profile files (bootloader-package = final-bootloader) (if (list? hooks) @@ -342,11 +377,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)))) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index af7b7561ff..3177452dfb 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -191,9 +191,18 @@ fi~%" (define font-file (let* ((bootloader (bootloader-configuration-bootloader config)) (grub (bootloader-package bootloader))) - (normalize-file (file-append grub "/share/grub/unicode.pf2") - store-mount-point - store-directory-prefix))) + ;; The bootloader-package may be a profile with only symlinks. + ;; If network booting, then a symlink to the font may not work on = the + ;; server side. Therefore we canonicalize the file name of the = font. + ;; TODO: The font gets installed by (install-grub-efi-netboot) = and + ;; (install-grub-efi). The installed font could be referred to = as + ;; "unicode". But it is currently unclear if = (install-grub-disk-image) + ;; and (install-grub) both install the font as well. + ;; Actually this should be preferred. + #~(canonicalize-path + #+(normalize-file (file-append grub "/share/grub/unicode.pf2") + store-mount-point + store-directory-prefix)))) =20 (define image (normalize-file (grub-background-image config) --=20 2.29.2