From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 07 02:09:40 2020 Received: (at 44353) by debbugs.gnu.org; 7 Nov 2020 07:09:40 +0000 Received: from localhost ([127.0.0.1]:57842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kbILz-0000n0-Tp for submit@debbugs.gnu.org; Sat, 07 Nov 2020 02:09:40 -0500 Received: from mail-qk1-f180.google.com ([209.85.222.180]:40511) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kbILx-0000ml-WA for 44353@debbugs.gnu.org; Sat, 07 Nov 2020 02:09:38 -0500 Received: by mail-qk1-f180.google.com with SMTP id y197so3292494qkb.7 for <44353@debbugs.gnu.org>; Fri, 06 Nov 2020 23:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=npzIU+klpXqY8oZf9eKb2xjRmDxApo/ZkFT004En1T4=; b=W0Y99sdezuaPRaLNNv6mT4jbSuqXYTol4LupEQsdzfz77elrpu31aVjoxdEGH67W32 r5+lpYobv/dlz2zzPzJO58W8Xp28m4ZJ/QWN1yMqjZgZ51ELMe7ZeCMycWHCcepmVe5D YZbMB+eUvoWHr1fUKF2YUKQcw81rL+QVOwNm5lFykrjxebRfUpnseq717MrVPdiSiqQd gxKYG5KxVTgFf5TO4f+zwsFs7u3em7wNfVAv+ui31EbyFn+yfwg83GTuQ7DMvWsDd+Pg Gm82fV/gQ8klQeaf52spjz8Nr21Gmh9lrl1Z0TipjNA77hl1LhkTdxnmmhC57gm4bVM4 fqdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=npzIU+klpXqY8oZf9eKb2xjRmDxApo/ZkFT004En1T4=; b=LaHw6TkgYg7XSIP/SkoypEealqeL4M+4ccabkkWiAzAuv6kmnRE3RLIWYKqSQ1cg8a UgO5UnD+3H4aOquUPLfyFe9a2ieB/vmuEY46bKW8Xu0xNwMVg8WsK3ym/r3ajgR/AvgN AFtauNPZjaD72NtxZCMjz0nSvTP5Us1DBOyTJpNmeZFck/895VLiwYO3USzuLR+FFdn+ sQ+ZrKBPAXWEc2974uygVsG5MdB6QKAFDxi9T6KAJKCKmxdIOQJXnwe0QTHDddkKHL9B 8lU8wbF9wRDpqnFFZeGT+yTLS8yZxXl6RQUPleGaMG5rbTTDL8V1f2rn0KfTDQ67fCnn i7pA== X-Gm-Message-State: AOAM531nQ4B7uvqu4ZUHwDSCFbkPx9IbM+hScIK3xno3JO9/nL3lFpS3 DqeeWtS4rV3RlVPMQGKQC3o= X-Google-Smtp-Source: ABdhPJw1uxN5FAn1/GYE+Dh+6JS/PCBgc8ZboqFwcoEORWrptucq6CZ2pXiDBGXoFNkdhtnbo7n4nA== X-Received: by 2002:a05:620a:230:: with SMTP id u16mr5140843qkm.212.1604732972521; Fri, 06 Nov 2020 23:09:32 -0800 (PST) Received: from hurd (dsl-236-123-209.b2b2c.ca. [207.236.123.209]) by smtp.gmail.com with ESMTPSA id a206sm2150828qkb.64.2020.11.06.23.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 23:09:31 -0800 (PST) From: Maxim Cournoyer To: Jesse Gibbons Subject: Re: bug#44353: guix system disk-image -t raw fails with grub-efi-bootloader References: <1e589f3b-47f8-fd53-b750-d2beff8d91f5@gmail.com> Date: Sat, 07 Nov 2020 02:09:30 -0500 In-Reply-To: <1e589f3b-47f8-fd53-b750-d2beff8d91f5@gmail.com> (Jesse Gibbons's message of "Sat, 31 Oct 2020 10:47:35 -0600") Message-ID: <87lffdtzh1.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44353 Cc: 44353@debbugs.gnu.org, Mathieu Othacehe X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hello! Jesse Gibbons writes: > To replicate: > cd to a git checkout of the source code, gnu/system/examples > The hash for my current checkout is > d7e033b9a153a9e60f52ff64f4eb355c1c3d0a6e which is also the hash for my > current version of guix. > guix system disk-image -t raw lightweight-desktop.tmpl > > lightweight-desktop.tmpl defines an operating-system that uses > grub-efi-bootloader, and is embedded in the info pages as an example > operating system. Since it is lightweight, it doesn't take as long to > build as desktop.tmpl. > > Expected results: guix builds the raw image just fine, and that image > can be copied to an SD card and run on a computer with an efi > bootloader, just like the counterpart with grub-bootloader. There is > nothing in the documentation suggesting that this should not work by > design. > > Actual results: guix fails, see attached log. > > -Jesse Thank you for the report! I'm CC'ing Mathieu as he knows this part of the code much better than I do, having overhauled the generation of disk images recently! Below are two patches I made while investigating this. Mathieu, does that look like a proper fix? It allows images to be generated, but I'm unsure whether they'd be bootable (I couldn't successfully boot either EFI or MBR GRUB-based disk images in QEMU). Anyway, attached are the patches. Thank you! Maxim --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-build-image-Ensure-required-arguments-are-present.patch Content-Transfer-Encoding: quoted-printable From 557a938633ed55c41aed8b41a0f93b6151f00943 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Fri, 6 Nov 2020 21:37:33 -0500 Subject: [PATCH 1/2] build: image: Ensure required arguments are present. * gnu/build/image.scm (initialize-root-partition): Validate arguments. [system-directory, references-graph]: Change from keyword to positional arguments. [doc]: Add space between sentences. * gnu/system/image.scm (system-iso9660-image): Adjust. --- gnu/build/image.scm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gnu/build/image.scm b/gnu/build/image.scm index 640a784204..053972166b 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -5,6 +5,7 @@ ;;; Copyright =C2=A9 2017 Marius Bakke ;;; Copyright =C2=A9 2020 Tobias Geerinckx-Rice ;;; Copyright =C2=A9 2020 Mathieu Othacehe +;;; Copyright =C2=A9 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -179,7 +180,7 @@ to call-with-database." make-device-nodes (wal-mode? #t) #:allow-other-keys) - "Initialize the given ROOT directory. Use BOOTCFG and BOOTCFG-LOCATION to + "Initialize the given ROOT directory. Use BOOTCFG and BOOTCFG-LOCATION = to install the bootloader configuration. =20 If REGISTER-CLOSURES? is true, register REFERENCES-GRAPHS in the store. If @@ -187,6 +188,20 @@ DEDUPLICATE? is true, then also deduplicate files comm= on to CLOSURES and the rest of the store when registering the closures. SYSTEM-DIRECTORY is the = name of the directory of the 'system' derivation. Pass WAL-MODE? to register-closure." + + (define (validate-arguments) + (when bootcfg + (unless bootcfg-location + (error "Missing 'bootcfg-location' argument"))) + (when bootloader-installer + (unless bootloader-package + (error "Missing 'bootloader-package' argument"))) + (unless references-graphs + (error "Missing 'references-graphs' argument")) + (unless system-directory + (error "Missing 'system-directory' argument"))) + + (validate-arguments) (populate-root-file-system system-directory root) (populate-store references-graphs root) =20 --=20 2.28.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-image-Only-attempt-bootloader-installation-when-supp.patch From c642a6984d4961256f50ca5133d1eec5ca1af4e9 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sat, 7 Nov 2020 00:20:49 -0500 Subject: [PATCH 2/2] image: Only attempt bootloader installation when supported. Fixes . The initialize-root-partition in (guix build image) attempts to install a bootloader when BOOTLOADER-INSTALLER is defined. Unfortunately, it relies on a special #f value for the second argument (device), which only the INSTALL-GRUB procedure from (gnu bootloader grub) supports. * gnu/system/image.scm (system-disk-image): Only pass the bootloader installer argument when the bootloader name is 'grub. Add comment. --- gnu/system/image.scm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 4075a26552..d4932466e5 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -345,8 +345,16 @@ used in the image." #:grub-efi #+grub-efi #:bootloader-package #+(bootloader-package bootloader) + ;; Special case: most bootloaders can be copied + ;; directly at some fixed location on the image + ;; disk, but when installed to the master boot + ;; record (MBR), GRUB requires support files + ;; present under /boot/grub, which is handled by + ;; its 'installer' procedure. #:bootloader-installer - #+(bootloader-installer bootloader) + #+(if (eq? 'grub (bootloader-name bootloader)) + (bootloader-installer bootloader) + #f) #:bootcfg #$bootcfg #:bootcfg-location #$(bootloader-configuration-file bootloader)) -- 2.28.0 --=-=-=--