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 UPnZBKHFkV8IGAAA0tVLHw (envelope-from ) for ; Thu, 22 Oct 2020 17:47:13 +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 UGHSOqDFkV+FVQAAbx9fmQ (envelope-from ) for ; Thu, 22 Oct 2020 17:47:12 +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 6B77C9403A6 for ; Thu, 22 Oct 2020 17:47:12 +0000 (UTC) Received: from localhost ([::1]:35840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVeg9-0001c5-RY for larch@yhetil.org; Thu, 22 Oct 2020 13:47:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVeg2-0001bB-MJ for guix-patches@gnu.org; Thu, 22 Oct 2020 13:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42230) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVeg2-0007Ah-Co for guix-patches@gnu.org; Thu, 22 Oct 2020 13:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kVeg2-0002a0-B8 for guix-patches@gnu.org; Thu, 22 Oct 2020 13:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41066] [PATCH] gnu: bootloader: Support for chain loading. Resent-From: Danny Milosavljevic Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 22 Oct 2020 17:47:02 +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: Stefan , Cc: 41066@debbugs.gnu.org, Mathieu Othacehe , Efraim Flashner , Maxim Cournoyer Received: via spool by 41066-submit@debbugs.gnu.org id=B41066.16033887989879 (code B ref 41066); Thu, 22 Oct 2020 17:47:02 +0000 Received: (at 41066) by debbugs.gnu.org; 22 Oct 2020 17:46:38 +0000 Received: from localhost ([127.0.0.1]:53776 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVefd-0002ZG-VS for submit@debbugs.gnu.org; Thu, 22 Oct 2020 13:46:38 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:36120) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVefc-0002Z7-12 for 41066@debbugs.gnu.org; Thu, 22 Oct 2020 13:46:36 -0400 Received: from localhost (80-110-126-103.cgn.dynamic.surfer.at [80.110.126.103]) by dd26836.kasserver.com (Postfix) with ESMTPSA id AF3903367C9C; Thu, 22 Oct 2020 19:46:33 +0200 (CEST) Date: Thu, 22 Oct 2020 19:46:30 +0200 From: Danny Milosavljevic Message-ID: <20201022194630.597302a2@scratchpost.org> In-Reply-To: <975EC414-6A81-444B-9BB0-AE303C6A9511@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> X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/98PrK3G5UQkoZY94jZHx_+n"; protocol="application/pgp-signature"; micalg=pgp-sha512 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-Scanner: scn0 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-Spam-Score: 0.39 X-TUID: 30T8ukcrGRyp --Sig_/98PrK3G5UQkoZY94jZHx_+n Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Stefan, this looks very good in general. I have only a few doubts--mostly concerning the end-user API "bootloader-ch= ain": On Sun, 18 Oct 2020 13:21:28 +0200 Stefan wrote: > (bootloader-chain grub-efi-netboot-bootloader > (list u-boot-my-scb > firmware) > '("libexec/u-boot.bin" > "firmware/") > (list (plain-file "config.txt" > "kernel=3Du-boot.bin")) > #:installer (install-grub-efi-netboot "efi/boot= ")) I would prefer if it was possible to do the following: (bootloader-chain (list firmware (plain-file "config.txt" "kernel=3Du-boot= .bin") u-boot-my-scb) grub-efi-netboot-bootloader) (I would put the main bootloader last because the user probably thinks of t= he list of bootloaders in the order they are loaded at boot) [maybe even (bootloader-chain (list u-boot-my-scb firmware (plain-file "config.txt" "k= ernel=3Du-boot.bin") grub-efi-netboot-bootloader)) -- with documentation that the order of the entries matters. But maybe that would be too magical--since only the last entry in that list would have the= ir installer called, and the actual guix generations also only go into the last one's configuration. But maybe that would be OK anyway] Also, I don't like the ad hoc derivation subset selection mechanism you hav= e. I understand that it can be nice to be able to select a subset in general, = but: * Usually we make a special package, inherit from the original package, and= then just make it put the files we want into the derivation output directory. The user would put "u-boot-my-scb-minimal" instead of "u-boot-my-scb" in that case, and then only get the subset. * In this special case of chaining bootloaders, I think that the profile ho= ok can take care of deleting all the unnecessary files, and of all the other w= eird complications (installing FILES, moving stuff around etc--maybe even genera= ting or updating that config.txt one day). One of the reasons I suggested using a profile in the first place is that now the profile hook can do all the dirty work, even long term. * If that isn't possible either, it would be nicer to have a helper procedure that allows you to select a subset of the files that are in the derivation of a package, and not have this subset selection ming= led into the innards of bootloader-chain. (separation of concerns) Maybe there could even be a package transformation to do that. I know that there are probably good reasons why you did it like you did. But still, I think a profile hook is exactly the right kind of tool to hide the extra setup complexity that my API requires, and the API would be less complicated to use and more stable (less likely to ever need to be changed). What do you think? Also, if it is difficult to collect bootloader packages into a profile automatically (without extra user-supplied information) because of the subd= ir "libexec" in u-boot derivations, then we can modify all the u-boot packages (for good) to put u-boot into "$output/" instead of "$output/libexec". I would prefer fixing things instead of having to put workarounds into user configuration. Please tell me if you want that--we can do that. > #:installer (install-grub-efi-netboot "efi/boot= ")) That should be automatic but overridable. This seems to be the case already. Nice! > +(define (bootloader-profile packages package-contents files) If using my suggested bootloader-chain API, this would just get PACKAGES, not PACKAGE-CONTENTS and FILES (FILES would be mixed into the PACKAGES list= --which thus should be renamed to ITEMS or something). > + (define (bootloader-collection manifest) > + (define build > + (with-imported-modules '((guix build utils) > + (ice-9 ftw) > + (srfi srfi-1)) > + #~(begin > + (use-modules ((guix build utils) > + #:select (mkdir-p strip-store-file-name)) > + ((ice-9 ftw) > + #:select (scandir)) > + ((srfi srfi-1) > + #:select (append-map every remove))) > + (define (symlink-to file directory transform) > + "Creates a symlink to FILE named (TRANSFORM FILE) in DIREC= TORY." > + (when (file-exists? file) > + (symlink file > + (string-append directory "/" (transform fil= e))))) > + (define (directory-content directory) > + "Creates a list of absolute path names inside DIRECTORY." > + (map (lambda (name) > + (string-append directory name)) > + (sort (or (scandir directory > + (lambda (name) > + (not (member name '("." ".."))))) > + '()) > + string + (define (select-names select names) > + "Set SELECT to 'filter' or 'remove' names ending with '/'." > + (select (lambda (name) > + (string-suffix? "/" name)) > + names)) > + (define (filter-names-without-slash names) > + (select-names remove names)) > + (define (filter-names-with-slash names) > + (select-names filter names)) I would prefer these to be in another procedure that can be used to transfo= rm any package (or profile?) like this. @Ludo: What do you think? [...] > + (gexp->derivation "bootloader-collection" > + build > + #:local-build? #t > + #:substitutable? #f > + #:properties > + `((type . profile-hook) > + (hook . bootloader-collection)))) > + > + (profile (content (packages->manifest packages)) > + (name "bootloader-profile") > + (hooks (list bootloader-collection)) > + (locales? #f) > + (allow-collisions? #f) > + (relative-symlinks? #f))) > + > +(define* (bootloader-chain [...] > + (bootloader > + (inherit final-bootloader) > + (package profile) I like that. Smart way to reuse existing code. > + (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"))))))) Thanks! --Sig_/98PrK3G5UQkoZY94jZHx_+n Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl+RxXYACgkQ5xo1VCww uqUPHggAjbAJc065/6YBaVwh1TvClzzplghTe9vBlibTysxgz5XImKlGKJA3vI/M LFS4/ZjVT8z76FuAUCVnSIZyC/SwQQu9d1U31FxIwl/o1ZjAQ7MYDLSp/sDi3gPq bfVlHSfCqB20N99PSRdxz/srQBzTRJ+V7pohhw9Xw/BJ9BncT1I9gLzWUv3FlGdV TictMiivSGzRQURNhdqlaWB93dBZAVJ2cthdCIBBKncxEpvLltiDabqiEg7+X/oT 8cHTphNuYV8Gy6QLvqj/FnXCTFJFz55+3bqNHQXBgeIU1VFepENvKa5GjY42taKr sOe5gZLrCR7qMYW65mLQ4VaTiJhOQQ== =ej98 -----END PGP SIGNATURE----- --Sig_/98PrK3G5UQkoZY94jZHx_+n--