Subject: bug#41541: merge wip-hurd-vm

From: Jan Nieuwenhuizen <[email-masked]>
Date: Wed, 27 May 2020 13:11:12 +0200

Mathieu Othacehe writes:

Hello Mathieu,

> That's a good summary of the (complex) situation, thank you!

Yeah...well sorry for helping create such a mess :-)

>> Mattieu is looking into cleaning up of
>>
>> b605a36031 * origin/wip-hurd-vm WIP hurd-directives
>
> About that, I'd like to limit at maximum the (if hurd ...) conditionals
> in (gnu system image).

Yes, please!

> So for the "make-device-node", I would propose to "link" it to the
> image definition, as proposed in the attached patch.
>
> I'll see if we can do something similar for the "extra-directives" and
> the "boot-activation".

This looks beautiful!  It works for me when using this extra ugly patch
(yes, it contains an IF that has to go :-)

diff --git a/gnu/build/image.scm b/gnu/build/image.scm
index 70f1a61b9d..f4727b8bf5 100644
--- a/gnu/build/image.scm
+++ b/gnu/build/image.scm
@@ -67,7 +67,8 @@ take the partition metadata size into account, take a 25% margin."
 (define* (make-ext-image partition target root
                          #:key
                          (owner-uid 0)
-                         (owner-gid 0))
+                         (owner-gid 0)
+                         (options '()))
   "Handle the creation of EXT2/3/4 partition images. See
 'make-partition-image'."
   (let ((size (partition-size partition))
@@ -82,6 +83,7 @@ take the partition metadata size into account, take a 25% margin."
              "-E" ,(format #f "root_owner=~a:~a,~a"
                            owner-uid owner-gid journal-options)
              ,@fs-options
+             ,@options
              ,target
              ,(format #f "~ak"
                       (size-in-kib
@@ -105,14 +107,14 @@ take the partition metadata size into account, take a 25% margin."
                           (string-append "::" file))))
               (scandir root))))
 
-(define* (make-partition-image partition-sexp target root)
+(define* (make-partition-image partition-sexp target root #:key (options '()))
   "Create and return the image of PARTITION-SEXP as TARGET.  Use the given
 ROOT directory to populate the image."
   (let* ((partition (sexp->partition partition-sexp))
          (type (partition-file-system partition)))
     (cond
      ((string-prefix? "ext" type)
-      (make-ext-image partition target root))
+      (make-ext-image partition target root #:options options))
      ((string=? type "vfat")
       (make-vfat-image partition target root))
      (else
diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index db12a40cb4..3400e01b1a 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -277,13 +277,15 @@ used in the image."
               (computed-file "partition-image-root" root-builder
                              #:options `(#:references-graphs ,inputs)))
              (type (partition-file-system partition))
+             (options (if (hurd-target?) '("-o" "hurd" "-O" "ext_attr") '()))
              (image-builder
               (with-imported-modules*
                (let ((inputs '#+(list e2fsprogs dosfstools mtools)))
                  (set-path-environment-variable "PATH" '("bin" "sbin") inputs)
                  (make-partition-image #$(partition->gexp partition)
                                        #$output
-                                       #$image-root)))))
+                                       #$image-root
+                                       #:options '#$options)))))
         (computed-file "partition.img" image-builder)))
 
     (define (partition->config partition)

until the point where it lacks the "/hurd" symlink from the directives.

So, apart from removing the IF above in a nice way, we (you?) could try
to find a nice way to insert extra-directives

> @@ -168,6 +170,9 @@ of the directory of the 'system' derivation."
>    (populate-root-file-system system-directory root)

                                                     ^ here 
I guess...and then we'd be done.

I'm not sure as to what extent the extra-directives is/was a kludge?

Janneke

-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com