guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#41560] [PATCH 1/8] bootloader: Add 'disk-image-installer'.


From: Ludovic Courtès
Subject: [bug#41560] [PATCH 1/8] bootloader: Add 'disk-image-installer'.
Date: Thu, 28 May 2020 23:37:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * gnu/bootloader.scm (<bootloader>)[disk-image-installer]: New field,
> (bootloader-disk-image-installer): export it.
> * gnu/bootloader/grub.scm (install-grub-disk-image): New procedure ...
> (grub-bootloader): ... used as "disk-image-installer" here.
> (grub-efi-bootloader): set "disk-image-installer" to #f.
> * gnu/system/image.scm (root-partition?, find-root-partition): Move to
> "Helpers" section.
> (root-partition-index): New procedure.
> (system-disk-image): Honor disk-image-installer, and
> use it to install the bootloader directly on the disk-image, if supported.

[...]

> +  (disk-image-installer            bootloader-disk-image-installer
> +                                   (default #f))

My only concern here is that we’re making an interface that’s only
implemented by one bootloader, and I fear bitrot of the other
bootloaders longer term.  I guess we’ll see, this concern shouldn’t
block progress.

> +(define install-grub-disk-image
> +  #~(lambda (bootloader root-index image)
> +      ;; Install GRUB on the given IMAGE. The root partition index is
> +      ;; ROOT-INDEX.
> +      (let ((grub-mkimage
> +             (string-append bootloader "/bin/grub-mkimage"))
> +            (modules '("biosdisk" "part_msdos" "fat" "ext2"))
> +            (grub-bios-setup
> +             (string-append bootloader "/sbin/grub-bios-setup"))
> +            (root-device (format #f "hd0,msdos~a" root-index))
> +            (boot-img (string-append bootloader 
> "/lib/grub/i386-pc/boot.img"))
> +            (device-map "device.map"))
> +
> +        ;; Create a minimal, standalone Grub image that will be written
> +        ;; directly in the MBR-GAP (space between the end of the MBR and the
> +        ;; first partition).
> +        (apply invoke grub-mkimage
> +               "-O" "i386-pc"
> +               "-o" "core.img"
> +               "-p" (format #f "(~a)/boot/grub" root-device)
> +               modules)

Very smart.  s/Grub/GRUB/ everywhere please. :-)

> +(define (root-partition-index image)
> +  "Return the index of the root partition of the given IMAGE."
> +  (1+ (srfi-1:list-index identity
> +                         (map root-partition? (image-partitions image)))))

Isn’t it just (list-index root-partition (image-partitions image))?

Otherwise LGTM!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]