unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* gnu/system/u-boot.scm
@ 2016-07-21 20:35 Danny Milosavljevic
  2016-07-22  9:59 ` gnu/system/u-boot.scm Chris Marusich
  2016-07-26 20:49 ` gnu/system/u-boot.scm Ludovic Courtès
  0 siblings, 2 replies; 13+ messages in thread
From: Danny Milosavljevic @ 2016-07-21 20:35 UTC (permalink / raw)
  To: guix-devel

Hi,

below is my (untested!) attempt at an u-boot-configuration for use like this

  (bootloader (u-boot-configuration (device "/dev/sda")))

.

It has been copied from gnu/system/grub.cfg and then I s/grub/u-boot/g and removed all the eyecandy stuff as far as I could. We should end up with U-Boot showing a boot menu if 

(1) The file "extlinux.conf" ends up on the first partition in the root if no partition was marked Active or
(2) The file "extlinux.conf" ends up on the partition which was marked Active using the flag in the MBR/GPT.

and if someone installed u-boot-sunxi-with-spl.bin at a special sector using dd or something.

NB: I think "device" would better be called "drive" or something. Everything is a device at this point. More important is that it isn't a partition or a scanner or something :)

Now how do I make u-boot-configuration available in my /etc/config.scm ? :)

NB: I also researched how to chainload grub and there's https://wiki.linaro.org/LEG/Engineering/Kernel/GRUBonUBOOT that describes it. Do we want that?

NB: menu-entry is unchanged. Might make sense to generalize it and move it to a common location.

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Danny Milosavljevic <dannym+a@scratchpost.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu system u-boot)
  #:use-module (guix store)
  #:use-module (guix packages)
  #:use-module (guix derivations)
  #:use-module (guix records)
  #:use-module (guix monads)
  #:use-module (guix gexp)
  #:use-module (guix download)
  #:use-module (gnu artwork)
  #:use-module (gnu system file-systems)
  #:autoload   (gnu packages u-boot) (make-u-boot-package)
  #:autoload   (gnu packages compression) (gzip)
  #:use-module (ice-9 match)
  #:use-module (ice-9 regex)
  #:use-module (srfi srfi-1)
  #:export (u-boot-configuration
            u-boot-configuration?
            u-boot-configuration-device

            menu-entry
            menu-entry?

            u-boot-configuration-file))

;;; Commentary:
;;;
;;; Configuration of U-Boot.
;;;
;;; Code:

(define-record-type* <u-boot-configuration>
  u-boot-configuration make-u-boot-configuration
  u-boot-configuration?
  (board           u-boot-configuration-board)           ; string ; not optional!
  (u-boot          u-boot-configuration-u-boot           ; package
                   (default (@ (gnu packages u-boot) (make-u-boot-package board))))
  (device          u-boot-configuration-device)        ; string
  (menu-entries    u-boot-configuration-menu-entries   ; list
                   (default '()))
  (default-entry   u-boot-configuration-default-entry  ; integer
                   (default 0))
  (timeout         u-boot-configuration-timeout        ; integer
                   (default 5)))

(define-record-type* <menu-entry>
  menu-entry make-menu-entry
  menu-entry?
  (label           menu-entry-label)
  (linux           menu-entry-linux)
  (linux-arguments menu-entry-linux-arguments
                   (default '()))          ; list of string-valued gexps
  (initrd          menu-entry-initrd))     ; file name of the initrd as a gexp




(define (eye-candy config root-fs system port)
  "dummy"
  (mlet* %store-monad ((image #f))
    (return (and image
                 #~(format #$port "")))))



;;;
;;; Configuration file.
;;;

(define* (u-boot-configuration-file config store-fs entries
                                  #:key
                                  (system (%current-system))
                                  (old-entries '()))
  "Return the U-Boot configuration file corresponding to CONFIG, a
<u-boot-configuration> object, and where the store is available at STORE-FS, a
<file-system> object.  OLD-ENTRIES is taken to be a list of menu entries
corresponding to old generations of the system."
  (define linux-image-name
    (if (string-prefix? "mips" system)
        "vmlinuz"
        "bzImage"))

  (define all-entries
    (append entries (u-boot-configuration-menu-entries config)))

  (define entry->gexp
    (match-lambda
     (($ <menu-entry> label linux arguments initrd)
      #~(format port "LABEL ~s
  MENU LABEL ~a
  LINUX ~a/~a ~a
  INITRD ~a
  FDTDIR .
  APPEND ~a
~%"
                #$label
                #$linux #$linux-image-name
                #$initrd
                (string-join (list #$@arguments))))))

  (mlet %store-monad ((sugar (eye-candy config store-fs system #~port)))
    (define builder
      #~(call-with-output-file #$output
          (lambda (port)
            #$sugar
            (format port "
ui menu.c32
DEFAULT ~a
TIMEOUT ~a~%"
                    #$(u-boot-configuration-default-entry config)
                    #$(u-boot-configuration-timeout config))
            #$@(map entry->gexp all-entries)

            #$@(if (pair? old-entries)
                   #~((format port "~%")
                      #$@(map entry->gexp old-entries)
                      (format port "~%"))
                   #~()))))

    (gexp->derivation "extlinux.conf" builder)))

;;; u-boot.scm ends here

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: gnu/system/u-boot.scm
  2016-07-21 20:35 gnu/system/u-boot.scm Danny Milosavljevic
@ 2016-07-22  9:59 ` Chris Marusich
  2016-07-22 18:21   ` gnu/system/u-boot.scm Danny Milosavljevic
  2016-07-26 20:49 ` gnu/system/u-boot.scm Ludovic Courtès
  1 sibling, 1 reply; 13+ messages in thread
From: Chris Marusich @ 2016-07-22  9:59 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2298 bytes --]

Danny Milosavljevic <dannym@scratchpost.org> writes:

> Hi,
>
> below is my (untested!) attempt at an u-boot-configuration for use like this
>
>   (bootloader (u-boot-configuration (device "/dev/sda")))

Neat!  Kudos to you for getting the ball rolling.  I'm not familiar with
u-boot, but based on recent emails, it sounds like it's important for
getting GuixSD to run on ARM.

> Now how do I make u-boot-configuration available in my /etc/config.scm
> ? :)

A mechanism exists for installing the bootloader and its configuration
files.  You can see it in guix/gnu/build/install.scm (where we actually
execute the install-grub [1] program) and guix/guix/scripts/system.scm.
It seems the code currently assumes that grub is the bootloader.  To
actually install u-boot, you'll probably need to add support for u-boot
somewhere in there.

[1] https://www.gnu.org/software/grub/manual/html_node/Installing-GRUB-using-grub_002dinstall.html#Installing-GRUB-using-grub_002dinstall

I wonder if it would be possible to create a bootloader abstraction of
some kind so that the installation mechanism can work with either u-boot
or grub, without caring about which one it uses?  It would be nice if
the installation mechanism were generic enough so that the same
mechanism could be used to install either bootloader.

> (define-record-type* <u-boot-configuration>
>   u-boot-configuration make-u-boot-configuration
>   u-boot-configuration?
>   (board           u-boot-configuration-board)           ; string ; not optional!
>   (u-boot          u-boot-configuration-u-boot           ; package
>                    (default (@ (gnu packages u-boot) (make-u-boot-package board))))
>   (device          u-boot-configuration-device)        ; string
>   (menu-entries    u-boot-configuration-menu-entries   ; list
>                    (default '()))
>   (default-entry   u-boot-configuration-default-entry  ; integer
>                    (default 0))
>   (timeout         u-boot-configuration-timeout        ; integer
>                    (default 5)))

This looks a little different from the grub-configuration record type
(defined in guix/gnu/system/grub.scm).  How do you intend to integrate
it with the existing bootloader installation mechanism?

-- 
Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: gnu/system/u-boot.scm
  2016-07-22  9:59 ` gnu/system/u-boot.scm Chris Marusich
@ 2016-07-22 18:21   ` Danny Milosavljevic
  0 siblings, 0 replies; 13+ messages in thread
From: Danny Milosavljevic @ 2016-07-22 18:21 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guix-devel

Hi,

On Fri, 22 Jul 2016 02:59:34 -0700
Chris Marusich <cmmarusich@gmail.com> wrote:

> I'm not familiar with u-boot, but based on recent emails, it sounds like it's important for getting GuixSD to run on ARM.

Yeah, because many ARM platforms don't have a BIOS (or any similar replacement), the bootloader has to do things you wouldn't believe. U-Boot has support for that.

There would be support for Grub as an U-Boot payload (in a fork), but I figured it's not really necessary [for now?] and complicates things too much - see how similar the U-Boot config body is to the Grub config body...

> I wonder if it would be possible to create a bootloader abstraction of
> some kind so that the installation mechanism can work with either u-boot
> or grub, without caring about which one it uses?  It would be nice if
> the installation mechanism were generic enough so that the same
> mechanism could be used to install either bootloader.

That would be nice. I'm not sure whether different bootloaders are similar in their installation mechanism, though. 

ARM platforms have... weird ways of booting - so getting all ARM boards to boot in the first place is difficult. Supporting those and Grub should be easy afterwards.

> > (define-record-type* <u-boot-configuration>
> >   u-boot-configuration make-u-boot-configuration
> >   u-boot-configuration?
> >   (board           u-boot-configuration-board)           ; string ; not optional!
> >   (u-boot          u-boot-configuration-u-boot           ; package
> >                    (default (@ (gnu packages u-boot) (make-u-boot-package board))))
> >   (device          u-boot-configuration-device)        ; string
> >   (menu-entries    u-boot-configuration-menu-entries   ; list
> >                    (default '()))
> >   (default-entry   u-boot-configuration-default-entry  ; integer
> >                    (default 0))
> >   (timeout         u-boot-configuration-timeout        ; integer
> >                    (default 5)))  
> 
> This looks a little different from the grub-configuration record type
> (defined in guix/gnu/system/grub.scm).  

It should be very similar.

I added "board" and removed the theme stuff since it's unsupported. I don't think leaving the theme stuff in there would hurt either - it would just be ignored.

>How do you intend to integrate it with the existing bootloader installation mechanism?

I have no idea yet. Have to read up on what's there first :)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: gnu/system/u-boot.scm
  2016-07-21 20:35 gnu/system/u-boot.scm Danny Milosavljevic
  2016-07-22  9:59 ` gnu/system/u-boot.scm Chris Marusich
@ 2016-07-26 20:49 ` Ludovic Courtès
  2016-07-27  9:32   ` gnu/system/u-boot.scm Danny Milosavljevic
  2016-10-06  8:12   ` gnu/system/u-boot.scm Danny Milosavljevic
  1 sibling, 2 replies; 13+ messages in thread
From: Ludovic Courtès @ 2016-07-26 20:49 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Hi!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> below is my (untested!) attempt at an u-boot-configuration for use like this
>
>   (bootloader (u-boot-configuration (device "/dev/sda")))

Nice!

> It has been copied from gnu/system/grub.cfg and then I s/grub/u-boot/g and removed all the eyecandy stuff as far as I could. We should end up with U-Boot showing a boot menu if 
>
> (1) The file "extlinux.conf" ends up on the first partition in the root if no partition was marked Active or
> (2) The file "extlinux.conf" ends up on the partition which was marked Active using the flag in the MBR/GPT.
>
> and if someone installed u-boot-sunxi-with-spl.bin at a special sector using dd or something.

OK.  We’ll need to find out exactly what needs to be done and implement
it, similar to ‘install-grub’ in (gnu build install).

> NB: I think "device" would better be called "drive" or something. Everything is a device at this point. More important is that it isn't a partition or a scanner or something :)

To me “device” is to be understood as “/dev” file name in this context.

> Now how do I make u-boot-configuration available in my /etc/config.scm ? :)

Simply (use-modules (gnu system u-boot)) in your config.

However, at this point it won’t do anything useful obviously.  :-)

> NB: I also researched how to chainload grub and there's https://wiki.linaro.org/LEG/Engineering/Kernel/GRUBonUBOOT that describes it. Do we want that?

Dunno, it’s not clear to me what this buys us.

> NB: menu-entry is unchanged. Might make sense to generalize it and move it to a common location.

For now, let’s simply reuse the one from (gnu system grub).  We can
always move it to a more appropriate place later on.

>   (u-boot          u-boot-configuration-u-boot           ; package
>                    (default (@ (gnu packages u-boot) (make-u-boot-package board))))

The default value has invalid syntax.  Should be simply:

  (default (make-u-boot-package board))

but I think this doesn’t work (‘board’ will be unbound; yeah,
counter-intuitive.)

You could instead do (default #f) and call ‘make-u-boot-package’ when
that value is #f.

> (define (eye-candy config root-fs system port)
>   "dummy"
>   (mlet* %store-monad ((image #f))
>     (return (and image
>                  #~(format #$port "")))))
>

Simply remove it.  :-)

Now, with that in place, we need a few more bits:

  1. An ‘install-u-boot’ procedure that would be the counterpart of
     ‘install-grub’, as discussed above;

  2. (gnu system) should dispatch to either ‘grub-configuration-file’ or
     ‘u-boot-configuration-file’ depending on whether the config
     contains a ‘grub-configuration’ or a ‘u-boot-configuration’ object.

I’m probably forgetting other things, but this is the guts of it.

(Note that I’m happy to provide guidance for the GuixSD side of things,
but I have almost no experience with U-Boot.)

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: gnu/system/u-boot.scm
  2016-07-26 20:49 ` gnu/system/u-boot.scm Ludovic Courtès
@ 2016-07-27  9:32   ` Danny Milosavljevic
  2016-07-27 20:29     ` guix bootloader selection - wip patch Danny Milosavljevic
  2016-07-28 12:26     ` gnu/system/u-boot.scm Ludovic Courtès
  2016-10-06  8:12   ` gnu/system/u-boot.scm Danny Milosavljevic
  1 sibling, 2 replies; 13+ messages in thread
From: Danny Milosavljevic @ 2016-07-27  9:32 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hi Ludo,

On Tue, 26 Jul 2016 22:49:35 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

> >   (u-boot          u-boot-configuration-u-boot           ; package
> >                    (default (@ (gnu packages u-boot) (make-u-boot-package board))))  
> 
> The default value has invalid syntax.  Should be simply:
> 
>   (default (make-u-boot-package board))
> 
> but I think this doesn’t work (‘board’ will be unbound; yeah,
> counter-intuitive.)
> 
> You could instead do (default #f) and call ‘make-u-boot-package’ when
> that value is #f.
> 
> > (define (eye-candy config root-fs system port)
> >   "dummy"
> >   (mlet* %store-monad ((image #f))
> >     (return (and image
> >                  #~(format #$port "")))))
> >  
> 
> Simply remove it.  :-)

Yeah, but there's a 

  (mlet %store-monad ((sugar (eye-candy config store-fs system #~port)))

in the same file.

Can I remove that and #$sugar , too? Will it still work?

Also, I'm trying to s/grub.cfg/bootloader-configuration-file/g right now, but I wonder

(1) Whether it's possible to determine the basename of the config-file derivation in order to find out what bootloader to install
(2) Whether we want to do it that way

.

If so, we could have a install-bootloader routine that detects what the filename of the bootloader-configuration-file object is and then calls either install-grub or install-u-boot.

For an overview, I searched:

$ grep -rl grub . |grep '\.scm'

./gnu/build/vm.scm ; initialize-hard-disk has a key #:grub.cfg
./gnu/build/install.scm ; actual invocation of grub-install is here
./gnu/packages/admin.scm ; fine; some person is called grubb
./gnu/packages/grub.scm ; fine to use it in there
./gnu/system/grub.scm ; fine to use it in there
./gnu/system/vm.scm ; qemu-image has a key #:grub-configuration; source file hardcodes grub package (?)
./gnu/system/install.scm ; references grub package "mostly so xrefs to its manual work"
./gnu/system.scm ; needs to be adapted
./tests/system.scm ; harmless, just uses grub-configuration
./build-aux/hydra/demo-os.scm ; harmless, just uses grub-configuration
./guix/scripts/system.scm ; install-grub* needs to be generalized
./gnu.scm ; %public-modules grub for grub-configuration

Some of these would have to be adapted. 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* guix bootloader selection - wip patch
  2016-07-27  9:32   ` gnu/system/u-boot.scm Danny Milosavljevic
@ 2016-07-27 20:29     ` Danny Milosavljevic
  2016-07-28 12:34       ` Ludovic Courtès
  2016-07-28 12:26     ` gnu/system/u-boot.scm Ludovic Courtès
  1 sibling, 1 reply; 13+ messages in thread
From: Danny Milosavljevic @ 2016-07-27 20:29 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hi,

so far I came up with the patch to Guix below for the actual bootloader selection.

Some places are still broken. Search for "FIXME" below.

For example I need a way to find out what the bootloader config file is supposed to be called in the new routine 'install-bootloader . It will get (derivation->output-path bootloader-configuration-file) as argument. Given it, can I still find out whether the filename is "grub.cfg" or "extlinux.conf"? Is that safe enough?

diff --git a/gnu.scm b/gnu.scm
index 932e4cd..9207e38 100644
--- a/gnu.scm
+++ b/gnu.scm
@@ -35,6 +35,7 @@
         (gnu system mapped-devices)
         (gnu system file-systems)
         (gnu system grub)                         ; 'grub-configuration'
+        (gnu system u-boot)                       ; 'u-boot-configuration'
         (gnu system pam)
         (gnu system shadow)                       ; 'user-account'
         (gnu system linux-initrd)
diff --git a/gnu/build/install.scm b/gnu/build/install.scm
index aebf38c..b799e00 100644
--- a/gnu/build/install.scm
+++ b/gnu/build/install.scm
@@ -21,7 +21,7 @@
   #:use-module (guix build store-copy)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
-  #:export (install-grub
+  #:export (install-bootloader
             populate-root-file-system
             reset-timestamps
             register-closure
@@ -36,27 +36,48 @@
 ;;;
 ;;; Code:
 
-(define* (install-grub grub.cfg device mount-point)
-  "Install GRUB with GRUB.CFG on DEVICE, which is assumed to be mounted on
-MOUNT-POINT.
-
-Note that the caller must make sure that GRUB.CFG is registered as a GC root
-so that the fonts, background images, etc. referred to by GRUB.CFG are not
-GC'd."
-  (let* ((target (string-append mount-point "/boot/grub/grub.cfg"))
-         (pivot  (string-append target ".new")))
+(define* (install-bootloader-config source target)
+  (let* ((pivot  (string-append target ".new")))
     (mkdir-p (dirname target))
 
-    ;; Copy GRUB.CFG instead of just symlinking it, because symlinks won't
+    ;; Copy bootloader config file instead of just symlinking it, because symlinks won't
     ;; work when /boot is on a separate partition.  Do that atomically.
-    (copy-file grub.cfg pivot)
-    (rename-file pivot target)
+    (copy-file source pivot)
+    (rename-file pivot target)))
 
-    (unless (zero? (system* "grub-install" "--no-floppy"
+;; TODO split install-bootloader-config off completely?
+(define* (install-grub grub.cfg device mount-point)
+  "Install bootloader with GRUB.CFG on DEVICE, which is assumed to be
+mounted on MOUNT-POINT.
+
+Note that the caller must make sure that GRUB.CFG is registered as a GC root so that
+the fonts, background images, etc. referred to by GRUB.CFG are not GC'd."
+    (install-bootloader-config grub.cfg
+                               (string-append mount-point
+                                              "/boot/grub/grub.cfg"))
+    (unless (zero? (system* "grub-install"
+                            "--no-floppy"
                             "--boot-directory"
                             (string-append mount-point "/boot")
                             device))
-      (error "failed to install GRUB"))))
+      (error "failed to install GRUB")))
+
+(define* (install-u-boot extlinux.conf device mount-point)
+  "Install U-Boot with EXTLINUX.CONF on DEVICE, which is assumed to be mounted on
+MOUNT-POINT. FIXME is that correct?"
+    (install-bootloader-config extlinux.conf
+                               (string-append mount-point
+                                              "/extlinux.conf"))
+    (unless (zero? (system* "u-boot-install"
+                            (string-append "--boot-directory=" mount-point)
+                            device))
+      (error "failed to install U-Boot")))
+
+(define* (install-bootloader config-filename device mount-point)
+  "Install bootloader with CONFIG-FILENAME on DEVICE, which is assumed to be
+mounted on MOUNT-POINT."
+  ; FIXME install-u-boot match
+  (install-grub config-filename device mount-point))
 
 (define (evaluate-populate-directive directive target)
   "Evaluate DIRECTIVE, an sexp describing a file or directory to create under
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index cc5cf45..c81e437 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -287,18 +287,20 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
     (unless register-closures?
       (reset-timestamps target))))
 
-(define (register-grub.cfg-root target grub.cfg)
-  "On file system TARGET, register GRUB.CFG as a GC root."
+(define (register-bootloader-configuration-file-root target bootloader-configuration-filename)
+  "On file system TARGET, register BOOTLOADER-CONFIGURATION-FILENAME as a GC root."
   (let ((directory (string-append target "/var/guix/gcroots")))
     (mkdir-p directory)
-    (symlink grub.cfg (string-append directory "/grub.cfg"))))
+    ; FIXME fix grub.cfg
+    (symlink bootloader-configuration-filename (string-append directory "/grub.cfg"))))
 
 (define* (initialize-hard-disk device
                                #:key
-                               grub.cfg
+                               bootloader-configuration-filename
                                (partitions '()))
   "Initialize DEVICE as a disk containing all the <partition> objects listed
-in PARTITIONS, and using GRUB.CFG as its bootloader configuration file.
+in PARTITIONS, and using BOOTLOADER-CONFIGURATION-FILENAME
+as its bootloader configuration file.
 
 Each partition is initialized by calling its 'initializer' procedure,
 passing it a directory name where it is mounted."
@@ -313,10 +315,10 @@ 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-bootloader bootloader-configuration-filename device target)
 
-    ;; Register GRUB.CFG as a GC root.
-    (register-grub.cfg-root target grub.cfg)
+    ;; Register BOOTLOADER-CONFIGURATION-FILENAME as a GC root.
+    (register-bootloader-configuration-file-root target bootloader-configuration-filename)
 
     (umount target)))
 
diff --git a/gnu/system.scm b/gnu/system.scm
index 476720b..3cee2f7 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -47,6 +47,7 @@
   #:use-module (gnu services shepherd)
   #:use-module (gnu services base)
   #:use-module (gnu system grub)
+  #:use-module (gnu system u-boot)
   #:use-module (gnu system shadow)
   #:use-module (gnu system nss)
   #:use-module (gnu system locale)
@@ -89,11 +90,13 @@
 
             operating-system-derivation
             operating-system-profile
-            operating-system-grub.cfg
+            operating-system-bootloader-configuration-file
             operating-system-etc-directory
             operating-system-locale-directory
             operating-system-boot-script
 
+            bootloader-configuration-device
+
             boot-parameters
             boot-parameters?
             boot-parameters-label
@@ -122,7 +125,7 @@
           (default linux-libre))
   (kernel-arguments operating-system-kernel-arguments
                     (default '()))                ; list of gexps/strings
-  (bootloader operating-system-bootloader)        ; <grub-configuration>
+  (bootloader operating-system-bootloader)        ; <grub-configuration> or <u-boot-configuration>
 
   (initrd operating-system-initrd                 ; (list fs) -> M derivation
           (default base-initrd))
@@ -695,8 +698,15 @@ listed in OS.  The C library expects to find it under
   "Return the file system that contains the store of OS."
   (store-file-system (operating-system-file-systems os)))
 
-(define* (operating-system-grub.cfg os #:optional (old-entries '()))
-  "Return the GRUB configuration file for OS.  Use OLD-ENTRIES to populate the
+(define (bootloader-configuration-device bootloader-configuration)
+    (match bootloader-configuration
+      (($ <grub-configuration> config)
+       (grub-configuration-device config))
+      (($ <u-boot-configuration> config)
+       (u-boot-configuration-device config))))
+
+(define* (operating-system-bootloader-configuration-file os #:optional (old-entries '()))
+  "Return the bootloader configuration file for OS.  Use OLD-ENTRIES to populate the
 \"old entries\" menu."
   (mlet* %store-monad
       ((system      (operating-system-derivation os))
@@ -716,13 +726,19 @@ listed in OS.  The C library expects to find it under
                                                     "/boot")
                                    (operating-system-kernel-arguments os)))
                            (initrd #~(string-append #$system "/initrd"))))))
-    (grub-configuration-file (operating-system-bootloader os)
-                             store-fs entries
-                             #:old-entries old-entries)))
+    (match (operating-system-bootloader os)
+      (($ <grub-configuration> config)
+       (grub-configuration-file config
+                                 store-fs entries
+                                 #:old-entries old-entries))
+      (($ <u-boot-configuration> config)
+       (u-boot-configuration-file config
+                                 store-fs entries
+                                 #:old-entries old-entries)))))
 
 (define (operating-system-parameters-file os)
   "Return a file that describes the boot parameters of OS.  The primary use of
-this file is the reconstruction of GRUB menu entries for old configurations."
+this file is the reconstruction of bootloader menu entries for old configurations."
   (mlet %store-monad ((initrd   (operating-system-initrd-file os))
                       (root ->  (operating-system-root-file-system os))
                       (label -> (kernel->grub-label
diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
index 45b46ca..a38bcca 100644
--- a/gnu/system/grub.scm
+++ b/gnu/system/grub.scm
@@ -47,6 +47,7 @@
             %background-image
             %default-theme
 
+            <grub-configuration>
             grub-configuration
             grub-configuration?
             grub-configuration-device
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index c31e3a8..a615855 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -188,7 +188,7 @@ made available under the /xchg CIFS share."
                      (file-system-type "ext4")
                      file-system-label
                      os-derivation
-                     grub-configuration
+                     bootloader-configuration-filename
                      (register-closures? #t)
                      (inputs '())
                      copy-inputs?)
@@ -196,8 +196,9 @@ made available under the /xchg CIFS share."
 'qcow2' or 'raw'), with a root partition of type FILE-SYSTEM-TYPE.
 Optionally, FILE-SYSTEM-LABEL can be specified as the volume name for the root
 partition.  The returned image is a full disk image that runs OS-DERIVATION,
-with a GRUB installation that uses GRUB-CONFIGURATION as its configuration
-file (GRUB-CONFIGURATION must be the name of a file in the VM.)
+with a bootloader installation that uses BOOTLOADER-CONFIGURATION-FILENAME as its
+configuration file (BOOTLOADER-CONFIGURATION-FILENAME must be the name of a
+file in the VM.)
 
 INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
@@ -243,7 +244,8 @@ the image."
                                      (initializer initialize)))))
              (initialize-hard-disk "/dev/vda"
                                    #:partitions partitions
-                                   #:grub.cfg #$grub-configuration)
+                                   #:bootloader-configuration-filename
+                                   #$bootloader-configuration-filename)
              (reboot)))))
    #:system system
    #:make-disk-image? #t
@@ -295,10 +297,10 @@ to USB sticks meant to be read-only."
                                   file-systems-to-keep)))))
 
     (mlet* %store-monad ((os-drv   (operating-system-derivation os))
-                         (grub.cfg (operating-system-grub.cfg os)))
+                         (bootloader-configuration-filename (operating-system-bootloader-configuration-file os)))
       (qemu-image #:name name
                   #:os-derivation os-drv
-                  #:grub-configuration grub.cfg
+                  #:bootloader-configuration-filename bootloader-configuration-filename
                   #:disk-image-size disk-image-size
                   #:disk-image-format "raw"
                   #:file-system-type file-system-type
@@ -306,7 +308,7 @@ to USB sticks meant to be read-only."
                   #:copy-inputs? #t
                   #:register-closures? #t
                   #:inputs `(("system" ,os-drv)
-                             ("grub.cfg" ,grub.cfg))))))
+                             ("grub.cfg" ,bootloader-configuration-filename))))))
 
 (define* (system-qemu-image os
                             #:key
@@ -340,13 +342,13 @@ of the GNU system as described by OS."
                                   file-systems-to-keep)))))
     (mlet* %store-monad
         ((os-drv      (operating-system-derivation os))
-         (grub.cfg    (operating-system-grub.cfg os)))
+         (bootloader-configuration-filename    (operating-system-bootloader-configuration-file os)))
       (qemu-image  #:os-derivation os-drv
-                   #:grub-configuration grub.cfg
+                   #:bootloader-configuration-filename bootloader-configuration-filename
                    #:disk-image-size disk-image-size
                    #:file-system-type file-system-type
                    #:inputs `(("system" ,os-drv)
-                              ("grub.cfg" ,grub.cfg))
+                              ("grub.cfg" ,bootloader-configuration-filename))
                    #:copy-inputs? #t))))
 
 \f
@@ -428,16 +430,16 @@ When FULL-BOOT? is true, return an image that does a complete boot sequence,
 bootloaded included; thus, make a disk image that contains everything the
 bootloader refers to: OS kernel, initrd, bootloader data, etc."
   (mlet* %store-monad ((os-drv   (operating-system-derivation os))
-                       (grub.cfg (operating-system-grub.cfg os)))
+                       (bootloader-configuration-file (operating-system-bootloader-configuration-file os)))
     ;; XXX: When FULL-BOOT? is true, we end up creating an image that contains
-    ;; GRUB.CFG and all its dependencies, including the output of OS-DRV.
-    ;; This is more than needed (we only need the kernel, initrd, GRUB for its
+    ;; BOOTLOADER-CONFIGURATION-FILENAME and all its dependencies, including the output of OS-DRV.
+    ;; This is more than needed (we only need the kernel, initrd, the bootloader for its
     ;; font, and the background image), but it's hard to filter that.
     (qemu-image #:os-derivation os-drv
-                #:grub-configuration grub.cfg
+                #:bootloader-configuration-filename bootloader-configuration-file
                 #:disk-image-size disk-image-size
                 #:inputs (if full-boot?
-                             `(("grub.cfg" ,grub.cfg))
+                             `(("grub.cfg" ,bootloader-configuration-file))
                              '())
 
                 ;; XXX: Passing #t here is too slow, so let it off by default.
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index e2c6b2e..7214a36 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -125,9 +125,10 @@ TARGET, and register them."
               (map (cut copy-item <> target #:log-port log-port)
                    to-copy))))
 
-(define (install-grub* grub.cfg device target)
-  "This is a variant of 'install-grub' with error handling, lifted in
+(define (install-bootloader* cfg device target)
+  "This is a variant of 'install-bootloader' with error handling, lifted in
 %STORE-MONAD"
+; FIXME name
   (let* ((gc-root      (string-append target %gc-roots-directory
                                       "/grub.cfg"))
          (temp-gc-root (string-append gc-root ".new"))
@@ -135,26 +136,27 @@ TARGET, and register them."
          (make-symlink (lift2 switch-symlinks %store-monad))
          (rename       (lift2 rename-file %store-monad)))
     (mbegin %store-monad
-      ;; Prepare the symlink to GRUB.CFG to make sure that it's a GC root when
-      ;; 'install-grub' completes (being a bit paranoid.)
-      (make-symlink temp-gc-root grub.cfg)
+      ;; Prepare the symlink to CFG to make sure that it's a GC root when
+      ;; 'install-bootloader' completes (being a bit paranoid.)
+      (make-symlink temp-gc-root cfg)
 
-      (munless (false-if-exception (install-grub grub.cfg device target))
+      (munless (false-if-exception (install-bootloader cfg device target))
         (delete-file temp-gc-root)
-        (leave (_ "failed to install GRUB on device '~a'~%") device))
+        (leave (_ "failed to install bootloader on device '~a'~%") device))
 
-      ;; Register GRUB.CFG as a GC root so that its dependencies (background
+      ;; Register CFG as a GC root so that its dependencies (background
       ;; image, font, etc.) are not reclaimed.
       (rename temp-gc-root gc-root))))
 
 (define* (install os-drv target
                   #:key (log-port (current-output-port))
-                  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.
+                  bootloader? bootloader-configuration-filename device)
+  "Copy the closure of BOOTLOADER-CONFIGURATION-FILENAME, which includes the
+output of OS-DRV, to directory TARGET.  TARGET must be an absolute directory
+name since that's what 'guix-register' expects.
 
-When GRUB? is true, install GRUB on DEVICE, using GRUB.CFG."
+When BOOTLOADER? is true, install bootloader on DEVICE, using
+BOOTLOADER-CONFIGURATION-FILENAME."
   (define (maybe-copy to-copy)
     (with-monad %store-monad
       (if (string=? target "/")
@@ -183,16 +185,16 @@ the ownership of '~a' may be incorrect!~%")
         (populate (lift2 populate-root-file-system %store-monad)))
 
     (mbegin %store-monad
-      ;; Copy the closure of GRUB.CFG, which includes OS-DIR, GRUB's
-      ;; background image and so on.
-      (maybe-copy grub.cfg)
+      ;; Copy the closure of BOOTLOADER-CONFIGURATION-FILENAME,
+      ;; which includes OS-DIR, the background image and so on.
+      (maybe-copy bootloader-configuration-filename)
 
       ;; Create a bunch of additional files.
       (format log-port "populating '~a'...~%" target)
       (populate os-dir target)
 
-      (mwhen grub?
-        (install-grub* grub.cfg device target)))))
+      (mwhen bootloader?
+        (install-bootloader* bootloader-configuration-filename device target)))))
 
 \f
 ;;;
@@ -384,7 +386,7 @@ it atomically, and then run OS's activation script."
     (date->string (time-utc->date time)
                   "~Y-~m-~d ~H:~M")))
 
-(define* (previous-grub-entries #:optional (profile %system-profile))
+(define* (previous-bootloader-entries #:optional (profile %system-profile))
   "Return a list of 'menu-entry' for the generations of PROFILE."
   (define (system->grub-entry system number time)
     (unless-file-not-found
@@ -543,13 +545,13 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
     (warning (_ "Failing to do that may downgrade your system!~%"))))
 
 (define* (perform-action action os
-                         #:key grub? dry-run? derivations-only?
+                         #:key bootloader? dry-run? derivations-only?
                          use-substitutes? device target
                          image-size full-boot?
                          (mappings '()))
-  "Perform ACTION for OS.  GRUB? specifies whether to install GRUB; DEVICE is
-the target devices for GRUB; TARGET is the target root directory; IMAGE-SIZE
-is the size of the image to be built, for the 'vm-image' and 'disk-image'
+  "Perform ACTION for OS.  BOOTLOADER? specifies whether to install the bootloade;
+DEVICE is the target device for the bootloader; TARGET is the target root directory;
+IMAGE-SIZE is the size of the image to be built, for the 'vm-image' and 'disk-image'
 actions.  FULL-BOOT? is used for the 'vm' action; it determines whether to
 boot directly to the kernel or to the bootloader.
 
@@ -566,21 +568,21 @@ building anything."
                                                 #:image-size image-size
                                                 #:full-boot? full-boot?
                                                 #:mappings mappings))
-       (grub      (package->derivation grub))
-       (grub.cfg  (if (eq? 'container action)
+       (grub      (package->derivation grub)) ; FIXME U-Boot
+       (bootloader-configuration-file (if (eq? 'container action)
                       (return #f)
-                      (operating-system-grub.cfg os
+                      (operating-system-bootloader-configuration-file os
                                                  (if (eq? 'init action)
                                                      '()
-                                                     (previous-grub-entries)))))
+                                                     (previous-bootloader-entries)))))
 
-       ;; For 'init' and 'reconfigure', always build GRUB.CFG, even if
-       ;; --no-grub is passed, because GRUB.CFG because we then use it as a GC
-       ;; root.  See <http://bugs.gnu.org/21068>.
+       ;; For 'init' and 'reconfigure', always build BOOTLOADER-CONFIGURATION-FILE,
+       ;; even if --no-bootloader is passed, because we then use
+       ;; it as a GC root.  See <http://bugs.gnu.org/21068>.
        (drvs   -> (if (memq action '(init reconfigure))
-                      (if grub?
-                          (list sys grub.cfg grub)
-                          (list sys grub.cfg))
+                      (if bootloader?
+                          (list sys bootloader-configuration-file grub) ; FIXME U-Boot
+                          (list sys bootloader-configuration-file))
                       (list sys)))
        (%         (if derivations-only?
                       (return (for-each (compose println derivation-file-name)
@@ -595,8 +597,8 @@ building anything."
                     drvs)
 
           ;; Make sure GRUB is accessible.
-          (when grub?
-            (let ((prefix (derivation->output-path grub)))
+          (when bootloader?
+            (let ((prefix (derivation->output-path grub))) ; FIXME bootloader
               (setenv "PATH"
                       (string-append  prefix "/bin:" prefix "/sbin:"
                                       (getenv "PATH")))))
@@ -605,16 +607,16 @@ building anything."
             ((reconfigure)
              (mbegin %store-monad
                (switch-to-system os)
-               (mwhen grub?
-                 (install-grub* (derivation->output-path grub.cfg)
+               (mwhen bootloader?
+                 (install-bootloader* (derivation->output-path bootloader-configuration-file)
                                 device "/"))))
             ((init)
              (newline)
              (format #t (_ "initializing operating system under '~a'...~%")
                      target)
              (install sys (canonicalize-path target)
-                      #:grub? grub?
-                      #:grub.cfg (derivation->output-path grub.cfg)
+                      #:bootloader? bootloader?
+                      #:bootloader-configuration-filename (derivation->output-path bootloader-configuration-file)
                       #:device device))
             (else
              ;; All we had to do was to build SYS.
@@ -684,7 +686,7 @@ Build the operating system declared in FILE according to ACTION.\n"))
   (display (_ "
       --image-size=SIZE  for 'vm-image', produce an image of SIZE"))
   (display (_ "
-      --no-grub          for 'init', do not install GRUB"))
+      --no-bootloader    for 'init', do not install bootloader"))
   (display (_ "
       --share=SPEC       for 'vm', share host file system according to SPEC"))
   (display (_ "
@@ -719,9 +721,9 @@ Build the operating system declared in FILE according to ACTION.\n"))
                  (lambda (opt name arg result)
                    (alist-cons 'image-size (size->number arg)
                                result)))
-         (option '("no-grub") #f #f
+         (option '("no-bootloader") #f #f
                  (lambda (opt name arg result)
-                   (alist-cons 'install-grub? #f result)))
+                   (alist-cons 'install-bootloader? #f result)))
          (option '("full-boot") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'full-boot? #t result)))
@@ -755,7 +757,7 @@ Build the operating system declared in FILE according to ACTION.\n"))
     (max-silent-time . 3600)
     (verbosity . 0)
     (image-size . ,(* 900 (expt 2 20)))
-    (install-grub? . #t)))
+    (install-bootloader? . #t)))
 
 \f
 ;;;
@@ -777,12 +779,12 @@ resulting from command-line parsing."
                        (leave (_ "no configuration file specified~%"))))
 
          (dry?     (assoc-ref opts 'dry-run?))
-         (grub?    (assoc-ref opts 'install-grub?))
+         (bootloader?   (assoc-ref opts 'install-bootloader?))
          (target   (match args
                      ((first second) second)
                      (_ #f)))
-         (device   (and grub?
-                        (grub-configuration-device
+         (device   (and bootloader?
+                        (bootloader-configuration-device
                          (operating-system-bootloader os)))))
 
     (with-store store
@@ -809,7 +811,7 @@ resulting from command-line parsing."
                                                        m)
                                                       (_ #f))
                                                     opts)
-                             #:grub? grub?
+                             #:bootloader? bootloader?
                              #:target target #:device device))))
         #:system system))))
 

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: gnu/system/u-boot.scm
  2016-07-27  9:32   ` gnu/system/u-boot.scm Danny Milosavljevic
  2016-07-27 20:29     ` guix bootloader selection - wip patch Danny Milosavljevic
@ 2016-07-28 12:26     ` Ludovic Courtès
  1 sibling, 0 replies; 13+ messages in thread
From: Ludovic Courtès @ 2016-07-28 12:26 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> On Tue, 26 Jul 2016 22:49:35 +0200
> ludo@gnu.org (Ludovic Courtès) wrote:
>
>> >   (u-boot          u-boot-configuration-u-boot           ; package
>> >                    (default (@ (gnu packages u-boot) (make-u-boot-package board))))  
>> 
>> The default value has invalid syntax.  Should be simply:
>> 
>>   (default (make-u-boot-package board))
>> 
>> but I think this doesn’t work (‘board’ will be unbound; yeah,
>> counter-intuitive.)
>> 
>> You could instead do (default #f) and call ‘make-u-boot-package’ when
>> that value is #f.
>> 
>> > (define (eye-candy config root-fs system port)
>> >   "dummy"
>> >   (mlet* %store-monad ((image #f))
>> >     (return (and image
>> >                  #~(format #$port "")))))
>> >  
>> 
>> Simply remove it.  :-)
>
> Yeah, but there's a 
>
>   (mlet %store-monad ((sugar (eye-candy config store-fs system #~port)))
>
> in the same file.
>
> Can I remove that and #$sugar , too? Will it still work?

Yes.

> Also, I'm trying to s/grub.cfg/bootloader-configuration-file/g right now, but I wonder
>
> (1) Whether it's possible to determine the basename of the config-file derivation in order to find out what bootloader to install
> (2) Whether we want to do it that way
>
> .
>
> If so, we could have a install-bootloader routine that detects what the filename of the bootloader-configuration-file object is and then calls either install-grub or install-u-boot.

I think we need two separate procedures on the build side:
‘install-grub’, and ‘install-u-boot’.

Choosing between GRUB and U-Boot should happen on the “host side”,
mostly likely in (gnu system).

HTH,
Ludo’.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: guix bootloader selection - wip patch
  2016-07-27 20:29     ` guix bootloader selection - wip patch Danny Milosavljevic
@ 2016-07-28 12:34       ` Ludovic Courtès
  2016-07-29  8:21         ` Danny Milosavljevic
  0 siblings, 1 reply; 13+ messages in thread
From: Ludovic Courtès @ 2016-07-28 12:34 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> so far I came up with the patch to Guix below for the actual bootloader selection.

Nice!

> Some places are still broken. Search for "FIXME" below.
>
> For example I need a way to find out what the bootloader config file is supposed to be called in the new routine 'install-bootloader . It will get (derivation->output-path bootloader-configuration-file) as argument. Given it, can I still find out whether the filename is "grub.cfg" or "extlinux.conf"? Is that safe enough?

[...]

> +(define* (install-u-boot extlinux.conf device mount-point)
> +  "Install U-Boot with EXTLINUX.CONF on DEVICE, which is assumed to be mounted on
> +MOUNT-POINT. FIXME is that correct?"
> +    (install-bootloader-config extlinux.conf
> +                               (string-append mount-point
> +                                              "/extlinux.conf"))
> +    (unless (zero? (system* "u-boot-install"
> +                            (string-append "--boot-directory=" mount-point)
> +                            device))
> +      (error "failed to install U-Boot")))

Really, installing U-Boot is as simple as this?  If it is, that’s
perfect.  :-)

> -(define* (operating-system-grub.cfg os #:optional (old-entries '()))
> -  "Return the GRUB configuration file for OS.  Use OLD-ENTRIES to populate the
> +(define (bootloader-configuration-device bootloader-configuration)
> +    (match bootloader-configuration
> +      (($ <grub-configuration> config)
> +       (grub-configuration-device config))
> +      (($ <u-boot-configuration> config)
> +       (u-boot-configuration-device config))))

Very good, this is where the bootloader selection should occur.  It
seems to me that it’s enough to find out whether to call ‘install-grub’
or ‘install-u-boot’, no?

I would write it as:

  (match bootloader-configuration
    ((? grub-configuration? config)
     (grub-configuration-device config))
    ((? u-boot-configuration? config)
     (u-boot-configuration-device config)))

which does the same thing but allows us to avoid exporting
<grub-configuration> and <u-boot-configuration> (better to keep them
private so that external code doesn’t rely on the structure layout.)

I see three separate things here:

  1. Replacing “grub” by “bootloader” in the API (cosmetic change);

  2. Adding the build-side code to install U-Boot;

  3. Adding the host-side code to handle <u-boot-configuration> and do
     the right thing.

To facilitate review, could you separate these three things?

Also, not critical, but could you send patches as ‘text/x-patch’ MIME
attachments so that my email client can perform color highlighting?  :-)

I’m happy to see fast progress on this, thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: guix bootloader selection - wip patch
  2016-07-28 12:34       ` Ludovic Courtès
@ 2016-07-29  8:21         ` Danny Milosavljevic
  2016-08-02  9:49           ` Ludovic Courtès
  2016-08-02  9:49           ` Ludovic Courtès
  0 siblings, 2 replies; 13+ messages in thread
From: Danny Milosavljevic @ 2016-07-29  8:21 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

> Really, installing U-Boot is as simple as this?  If it is, that’s
> perfect.  :-)

Nope, it's just a placeholder :)

But ideally U-Boot would provide something like that.

I'm looking into writing u-boot-install.c and maybe contributing it to U-Boot - let's see how bad it is.

Right now checking whether libparted allows you to reduce the size of the GPT to max. 56 entries...

> I would write it as:
> 
>   (match bootloader-configuration
>     ((? grub-configuration? config)
>      (grub-configuration-device config))
>     ((? u-boot-configuration? config)
>      (u-boot-configuration-device config)))
> which does the same thing but allows us to avoid exporting
> <grub-configuration> and <u-boot-configuration> (better to keep them
> private so that external code doesn’t rely on the structure layout.)

Yeah, I changed it to that now and removed the exports.

> I see three separate things here:
> 
>   1. Replacing “grub” by “bootloader” in the API (cosmetic change);
> 
>   2. Adding the build-side code to install U-Boot;
> 
>   3. Adding the host-side code to handle <u-boot-configuration> and do
>      the right thing.
> 
> To facilitate review, could you separate these three things?

As far as they are in different files, yes. Which part is the build-side, which part is the host-side?

> Also, not critical, but could you send patches as ‘text/x-patch’ MIME
> attachments so that my email client can perform color highlighting?  :-)

Okay.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: guix bootloader selection - wip patch
  2016-07-29  8:21         ` Danny Milosavljevic
@ 2016-08-02  9:49           ` Ludovic Courtès
  2016-08-02  9:49           ` Ludovic Courtès
  1 sibling, 0 replies; 13+ messages in thread
From: Ludovic Courtès @ 2016-08-02  9:49 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Danny Milosavljevic <dannym@scratchpost.org> skribis:

>> Really, installing U-Boot is as simple as this?  If it is, that’s
>> perfect.  :-)
>
> Nope, it's just a placeholder :)
>
> But ideally U-Boot would provide something like that.
>
> I'm looking into writing u-boot-install.c and maybe contributing it to U-Boot - let's see how bad it is.

I think we should adapt to whatever U-Boot provides for installation.
(I installed it years ago on a plug computer but forgot all the
details.)

>> I see three separate things here:
>> 
>>   1. Replacing “grub” by “bootloader” in the API (cosmetic change);
>> 
>>   2. Adding the build-side code to install U-Boot;
>> 
>>   3. Adding the host-side code to handle <u-boot-configuration> and do
>>      the right thing.
>> 
>> To facilitate review, could you separate these three things?
>
> As far as they are in different files, yes.

Not everything is in separate files I think, but ‘git rebase -i’ or
similar should facilitate the operation.

> Which part is the build-side, which part is the host-side?

The “build side” is the (gnu build …) and (guix build …) modules: they
contain code that is executed as part of build processes, or at run
time.

The “host side” is the rest, which contains package declarations, OS
declarations, service declarations, and code that drives the compilation
of all that.

(See “G-Expressions” in the manual for a discussion of this.)

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: guix bootloader selection - wip patch
  2016-07-29  8:21         ` Danny Milosavljevic
  2016-08-02  9:49           ` Ludovic Courtès
@ 2016-08-02  9:49           ` Ludovic Courtès
  1 sibling, 0 replies; 13+ messages in thread
From: Ludovic Courtès @ 2016-08-02  9:49 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Danny Milosavljevic <dannym@scratchpost.org> skribis:

>> Really, installing U-Boot is as simple as this?  If it is, that’s
>> perfect.  :-)
>
> Nope, it's just a placeholder :)
>
> But ideally U-Boot would provide something like that.
>
> I'm looking into writing u-boot-install.c and maybe contributing it to U-Boot - let's see how bad it is.

I think we should adapt to whatever U-Boot provides for installation.
(I installed it years ago on a plug computer but forgot all the
details.)

>> I see three separate things here:
>> 
>>   1. Replacing “grub” by “bootloader” in the API (cosmetic change);
>> 
>>   2. Adding the build-side code to install U-Boot;
>> 
>>   3. Adding the host-side code to handle <u-boot-configuration> and do
>>      the right thing.
>> 
>> To facilitate review, could you separate these three things?
>
> As far as they are in different files, yes.

Not everything is in separate files I think, but ‘git rebase -i’ or
similar should facilitate the operation.

> Which part is the build-side, which part is the host-side?

The “build side” is the (gnu build …) and (guix build …) modules: they
contain code that is executed as part of build processes, or at run
time.

The “host side” is the rest, which contains package declarations, OS
declarations, service declarations, and code that drives the compilation
of all that.

(See “G-Expressions” in the manual for a discussion of this.)

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: gnu/system/u-boot.scm
  2016-07-26 20:49 ` gnu/system/u-boot.scm Ludovic Courtès
  2016-07-27  9:32   ` gnu/system/u-boot.scm Danny Milosavljevic
@ 2016-10-06  8:12   ` Danny Milosavljevic
  2016-10-06 17:24     ` gnu/system/u-boot.scm David Craven
  1 sibling, 1 reply; 13+ messages in thread
From: Danny Milosavljevic @ 2016-10-06  8:12 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hi,

so now that all of it works, I'd like to propose to change how it's done completely (muhahaha).

Ludo wrote:
>   2. (gnu system) should dispatch to either ‘grub-configuration-file’ or
>      ‘u-boot-configuration-file’ depending on whether the config
>      contains a ‘grub-configuration’ or a ‘u-boot-configuration’ object.

I think it would be better if (gnu system) installed *both* the grub configuration file *and* the u-boot configuration file.

The main advantage would be if the user already had a bootloader, it would be possible to leave the bootloader form off completely in /etc/config.scm . The bootloader configurations would still be updated and the right one should be picked up by the bootloader (Note: Libreboot checks for "grub/libreboot_grub.cfg"; U-Boot checks for "extlinux.conf" (and others); Grub checks for "grub/grub.cfg").

(This is in order to support bootloaders that are in ROM or Flash, mostly. One usually doesn't update those [I guess it doesn't hurt if you install another dummy bootloader on disk, though]. VMs also don't need a bootloader - but do need the config)

Another advantage would be that there would be no "u-boot-configuration" object and the user would not have to choose between it and "grub-configuration". It would be all the same configuration object (by then erroneously called "grub-configuration" - which we can keep for backward compatibility I guess). 

The programs "grub-install" and (future) "u-boot-install" expect a fixed filename for their config file - so they are not confused by it either. So that's neutral :)

There's no need to provide two different configuration objects (they are almost completely the same - save the output procedure). I'd say it's a maintenance advantage not to have them.

And the only disadvantage would be that the bootloader installation procedure would have to check whether "grub-install" exists. If it does, invoke it. Otherwise invoke "u-boot-install". Essentially success would be if either invocation succeeded (that is: the respective executable was found). [We could also add a "grub-install" executable to the u-boot packages if we wanted to avoid that]

grub-configuration would need just one new field "installer" which would list the package of the bootloader-to-install, if any. 

And there would need to be a new procedure "grub-configuration-files" with multiple files *instead* of "grub-configuration-file". (Think of "grub" as "bootloader" in this name)

operating-system-grub.cfg would also need to return multiple files (and maybe their target names, too?).

If we wanted to be backward compatible (probably), we could install grub if there was no field "installer" specified. (Although in a non-backward-compatible world I'd prefer if it installed no bootloader in that case - it wouldn't even have any fallout if it now didn't install the bootloader on existing systems)

What do you think?

If we want to do it, could you help me write "grub-configuration-files" ?

grub-configuration-file seems to use gexp->derivation at the end (which probably form a store monad). Can I just return a Scheme list of those or how would this work?

Do I then need to carry the target filename in a pair?

"grub.cfg" is a gc root. How would this need to be adapted?

If we later wanted to modify GuixSD to switch over to special configurations (although I don't see why we would), we can still do that without backward compat problems. So this wouldn't lock us in.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: gnu/system/u-boot.scm
  2016-10-06  8:12   ` gnu/system/u-boot.scm Danny Milosavljevic
@ 2016-10-06 17:24     ` David Craven
  0 siblings, 0 replies; 13+ messages in thread
From: David Craven @ 2016-10-06 17:24 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

I don't think we need an extlinux and a grub configuration file. But
we can probably improve the decoupling so that we don't need too much
code repetition.

Sorry, I got sidetracked with this. I've been working on rust, inox
(terrible python errors: EOF found but object expected on import,
racecondition? It reproduces, so it's a weird race condition) and
school. I'll probably resume work on guixsd on arm this weekend, but I
ordered a wandaboard after all - the bbb is too underpowered... I'd
like to use guixsd on arm for a small school project due date 11.11,
so I'll be focusing on this again...

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-10-06 17:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-21 20:35 gnu/system/u-boot.scm Danny Milosavljevic
2016-07-22  9:59 ` gnu/system/u-boot.scm Chris Marusich
2016-07-22 18:21   ` gnu/system/u-boot.scm Danny Milosavljevic
2016-07-26 20:49 ` gnu/system/u-boot.scm Ludovic Courtès
2016-07-27  9:32   ` gnu/system/u-boot.scm Danny Milosavljevic
2016-07-27 20:29     ` guix bootloader selection - wip patch Danny Milosavljevic
2016-07-28 12:34       ` Ludovic Courtès
2016-07-29  8:21         ` Danny Milosavljevic
2016-08-02  9:49           ` Ludovic Courtès
2016-08-02  9:49           ` Ludovic Courtès
2016-07-28 12:26     ` gnu/system/u-boot.scm Ludovic Courtès
2016-10-06  8:12   ` gnu/system/u-boot.scm Danny Milosavljevic
2016-10-06 17:24     ` gnu/system/u-boot.scm David Craven

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).