From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marius Bakke Subject: Re: [PATCH] Explicitly pass grub to install, install-grub*, install-grub, initialize-hard-disk and qemu-image. Date: Thu, 10 Nov 2016 15:04:49 +0000 Message-ID: <871syjbcku.fsf@kirby.i-did-not-set--mail-host-address--so-tickle-me> References: <20161110090927.13187-1-dannym@scratchpost.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4quS-0005Ki-4w for guix-devel@gnu.org; Thu, 10 Nov 2016 10:05:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4quM-0005B4-No for guix-devel@gnu.org; Thu, 10 Nov 2016 10:05:00 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:38316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4quM-0005AA-J0 for guix-devel@gnu.org; Thu, 10 Nov 2016 10:04:54 -0500 In-Reply-To: <20161110090927.13187-1-dannym@scratchpost.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Danny Milosavljevic , guix-devel@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi Danny, Thanks for this patch! I have verified that it works both for `guix system vm-image` and on my grub-efi system. Do you think this eliminates the need for the "setenv PATH" trick in guix/scripts/system.scm:648? For the record, I tested the patch with that section removed as well, making sure there was no grub-install in my PATH. Other than that this LGTM. Would like a second opinion from more seasoned Guix hackers before committing, though :) Danny Milosavljevic writes: > * gnu/build/install.scm (install-grub): Add grub-store-path parameter. Us= e it. > * gnu/build/vm.scm (initialize-hard-disk): Add grub parameter. Use it. Ca= ll modified install-grub. > * guix/scripts/system.scm (install-grub*): Add grub parameter. Pass it al= ong to install-grub. > * guix/scripts/system.scm (install): Add grub parameter. Call modified in= stall-grub*. > * guix/scripts/system.scm (perform-action): Call modified install. > * gnu/system/vm.scm (qemu-image): Call modified initialize-hard-disk. > --- > gnu/build/install.scm | 5 +++-- > gnu/build/vm.scm | 3 ++- > gnu/system/vm.scm | 1 + > guix/scripts/system.scm | 12 +++++++----- > 4 files changed, 13 insertions(+), 8 deletions(-) > > diff --git a/gnu/build/install.scm b/gnu/build/install.scm > index 3d1594e..6e11538 100644 > --- a/gnu/build/install.scm > +++ b/gnu/build/install.scm > @@ -38,7 +38,7 @@ > ;;; > ;;; Code: >=20=20 > -(define (install-grub grub.cfg device mount-point) > +(define (install-grub grub-store-path grub.cfg device mount-point) > "Install GRUB with GRUB.CFG on DEVICE, which is assumed to be mounted = on > MOUNT-POINT. >=20=20 > @@ -46,7 +46,8 @@ Note that the caller must make sure that GRUB.CFG is re= gistered as a GC root > so that the fonts, background images, etc. referred to by GRUB.CFG are n= ot > GC'd." > (install-grub-config grub.cfg mount-point) > - (unless (zero? (system* "grub-install" "--no-floppy" > + (unless (zero? (system* (string-append grub-store-path "/sbin/grub-ins= tall") > + "--no-floppy" > "--boot-directory" > (string-append mount-point "/boot") > device)) > diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm > index cc5cf45..f9468aa 100644 > --- a/gnu/build/vm.scm > +++ b/gnu/build/vm.scm > @@ -295,6 +295,7 @@ SYSTEM-DIRECTORY is the name of the directory of the = 'system' derivation." >=20=20 > (define* (initialize-hard-disk device > #:key > + grub > grub.cfg > (partitions '())) > "Initialize DEVICE as a disk containing all the objects li= sted > @@ -313,7 +314,7 @@ passing it a directory name where it is mounted." > (display "mounting root partition...\n") > (mkdir-p target) > (mount (partition-device root) target (partition-file-system root)) > - (install-grub grub.cfg device target) > + (install-grub grub grub.cfg device target) >=20=20 > ;; Register GRUB.CFG as a GC root. > (register-grub.cfg-root target grub.cfg) > diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm > index 03f7d6c..e914635 100644 > --- a/gnu/system/vm.scm > +++ b/gnu/system/vm.scm > @@ -231,6 +231,7 @@ the image." > (initializer initialize))))) > (initialize-hard-disk "/dev/vda" > #:partitions partitions > + #:grub #$grub > #:grub.cfg #$grub-configuration) > (reboot))))) > #:system system > diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm > index 71ddccf..3043d2e 100644 > --- a/guix/scripts/system.scm > +++ b/guix/scripts/system.scm > @@ -126,7 +126,7 @@ TARGET, and register them." > (map (cut copy-item <> target #:log-port log-port) > to-copy)))) >=20=20 > -(define (install-grub* grub.cfg device target) > +(define (install-grub* grub grub.cfg device target) > "This is a variant of 'install-grub' with error handling, lifted in > %STORE-MONAD" > (let* ((gc-root (string-append target %gc-roots-directory > @@ -140,7 +140,7 @@ TARGET, and register them." > ;; 'install-grub' completes (being a bit paranoid.) > (make-symlink temp-gc-root grub.cfg) >=20=20 > - (munless (false-if-exception (install-grub grub.cfg device target)) > + (munless (false-if-exception (install-grub grub grub.cfg device ta= rget)) > (delete-file temp-gc-root) > (leave (_ "failed to install GRUB on device '~a'~%") device)) >=20=20 > @@ -150,7 +150,7 @@ TARGET, and register them." >=20=20 > (define* (install os-drv target > #:key (log-port (current-output-port)) > - grub? grub.cfg device) > + grub? grub grub.cfg device) > "Copy the closure of GRUB.CFG, which includes the output of OS-DRV, to > directory TARGET. TARGET must be an absolute directory name since that'= s what > 'guix-register' expects. > @@ -193,7 +193,7 @@ the ownership of '~a' may be incorrect!~%") > (populate os-dir target) >=20=20 > (mwhen grub? > - (install-grub* grub.cfg device target))))) > + (install-grub* grub grub.cfg device target))))) >=20=20 > > ;;; > @@ -657,7 +657,8 @@ building anything." > (mbegin %store-monad > (switch-to-system os) > (mwhen grub? > - (install-grub* (derivation->output-path grub.cfg) > + (install-grub* (derivation->output-path grub) > + (derivation->output-path grub.cfg) > device "/")))) > ((init) > (newline) > @@ -665,6 +666,7 @@ building anything." > target) > (install sys (canonicalize-path target) > #:grub? grub? > + #:grub (derivation->output-path grub) > #:grub.cfg (derivation->output-path grub.cfg) > #:device device)) > (else --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBCgAGBQJYJIyRAAoJEKKgbfKjOlT6CqoIALeWwipcwKPi0HppmH2v7JAx R/LoQ8wKkDAMrnBI7WxeAffspXFDJqKYHkk9AS6zUXPzihBC39F83qFmw9Q+mftg LZXrGu1o3gu1GKtzI4YpX6lv5V4nlKsVsKg6ro8cyKaO7WrJ+dCFAGMEB6PDBk0B 4N5C56zvHi9Fv1U0jzqv4SK+zXzfSrdOioFM9s1lHBJ5Wix7//qNfylujWotLeQ8 36UE5aK4RjtR7lyCO1/Ilvlf2YhVBsto0INStcAz5NKID0pic3QEVUc6F/P5AwPs rcr/NcbYHSmc8WcLXqXN93pN1StdpjAVPeMay4wPEIFnpKlboS7HY2ZdvcMwCF4= =vRPj -----END PGP SIGNATURE----- --=-=-=--