Subject: bug#28445: match-error in 'device-sexp->device' while building system

From: [email-masked] (Ludovic Courtès)
Date: Wed, 20 Sep 2017 23:27:17 +0200

Hello Mark,

Andy pushed the first half of the fix as
96bc6518002c3b2ad9f15cf36991b20bebcbbe8a.  Could you check whether the
‘ensure-not-/dev’ part below solves the rest?

Thanks,
Ludo’.

[email-masked] (Ludovic Courtès) skribis:

> Mark H Weaver <[email-masked]> skribis:
>
>>  # Set 'root' to the partition that contains /gnu/store.
>> -search --file --set /gnu/store/21ngnlx9k0x9x2jj1px7mdlb4j6mzz6x-grub-2.02/share/grub/unicode.pf2
>> +search --label --set /dev/mapper/jojen-root
>
> Oops.  I believe the patch below does the trick (‘store-device’ must
> never be a Linux device name, and that’s what the patch ensures.)
>
> Thoughts?
>
> (I didn’t notice these issues because I identify my root file system by
> label or UUID rather than hard-coding its /dev/mapper name.)
>
> Ludo’.
>
> diff --git a/gnu/system.scm b/gnu/system.scm
> index d337e5259..d71b9c15b 100644
> --- a/gnu/system.scm
> +++ b/gnu/system.scm
> @@ -243,6 +243,11 @@ directly by the user."
>        ((? string? device)
>         device)))
>  
> +  (define (ensure-not-/dev device)
> +    (if (and (string? device) (string-prefix? "/" device))
> +        #f
> +        device))
> +
>    (match (read port)
>      (('boot-parameters ('version 0)
>                         ('label label) ('root-device root)
> @@ -277,15 +282,16 @@ directly by the user."
>            file)))
>  
>        (store-device
> -       (match (assq 'store rest)
> -         (('store ('device device) _ ...)
> -          (device-sexp->device device))
> -         (_                                       ;the old format
> -          ;; Root might be a device path like "/dev/sda1", which is not a
> -          ;; suitable GRUB device identifier.
> -          (if (string-prefix? "/" root)
> -              #f
> -              root))))
> +       ;; ROOT might be a device path like "/dev/sda1", which is not a
> +       ;; suitable GRUB device identifier.
> +       (ensure-not-/dev
> +        (match (assq 'store rest)
> +          (('store ('device #f) _ ...)
> +           root-device)
> +          (('store ('device device) _ ...)
> +           (device-sexp->device device))
> +          (_                                      ;the old format
> +           root-device))))
>  
>        (store-mount-point
>         (match (assq 'store rest)
> @@ -906,6 +912,7 @@ device in a <menu-entry>."
>    (case (file-system-title fs)
>      ((uuid) (file-system-device fs))
>      ((label) (file-system-device fs))
> +    ((device) (file-system-device fs))
>      (else #f)))
>  
>  (define (operating-system-boot-parameters os system.drv root-device)