unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57307: guix system reports an error when uuid is used in menu-entry
@ 2022-08-20 10:08 tiantian
  2022-08-21  8:39 ` Josselin Poiret via Bug reports for GNU Guix
  0 siblings, 1 reply; 6+ messages in thread
From: tiantian @ 2022-08-20 10:08 UTC (permalink / raw)
  To: 57307


[-- Attachment #1.1.1.1: Type: text/plain, Size: 1006 bytes --]

I want to add an menu-entry in bootloader-configuration. I use uuid to 
specify the partition in device field of menu-entry , because my 
partition has no label. But when I use 'guix system reconfigure', guix 
system reports an error: "guix system: error: #<<uuid> type: dce bv: 
#vu8(109 91 19 212 96 146 70 208 139 228 7 61 192 116 19 204)>: invalid 
G-expression input"

After asking friends in #guixcn, I still can't get more error messages. 
It's the only error message. I can't find its reason.

To find the problem, I also simplified my configuration file and tried 
to use ‘git bisect’ to find it, but I failed. I couldn't find a good 
commit. I rolled back to c1719a0 commit in git repository, but I still 
got the error message after building and using './pre-inst-env guix 
system build ./config-test.scm'. I had to give up solving it and just 
send an email to report the bug.

My English is poor. I use translation software. If the grammar is wrong, 
please forgive me.

[-- Attachment #1.1.1.2: Type: text/html, Size: 1430 bytes --]

[-- Attachment #1.1.2: config-test.scm --]
[-- Type: text/x-scheme, Size: 1498 bytes --]

(use-modules (gnu)
             (gnu system nss)
             (gnu system linux-initrd)
             (gnu bootloader grub)
             (guix gexp)
             (guix channels)
             (guix inferior)
             (srfi srfi-1))
(use-service-modules desktop xorg mail nix networking sddm docker)
(use-package-modules certs gnome fonts xfce linux)


(operating-system
 (host-name "guix-pc")
 (timezone "Asia/Shanghai")
 (locale "zh_CN.utf8")
 (keyboard-layout (keyboard-layout "cn"))
 (bootloader (bootloader-configuration
              (bootloader grub-efi-bootloader)
              (target "/boot/efi")
	      (menu-entries
	       (list
		;; (menu-entry
		;;   (label "archlinux")
		;;   (device (uuid "1C31-A17C" 'fat))
		;;   (chain-loader "/EFI/ArchLinux/grubx64.efi"))
		(menu-entry
		 (label "test")
		 (device (uuid "6d5b13d4-6092-46d0-8be4-073dc07413cc"))
		 (linux "/rootfs/gnu/store/7rbmca2wcgsbxhdh4w1whmz7q6rndmlm-linux-5.18.14/bzImage")
		 (initrd "/rootfs/gnu/store/22zfdzd6c7blr2k009armbdwgji20a4b-raw-initrd/initrd.cpio.gz"))))
              (keyboard-layout keyboard-layout)))
 (file-systems (cons*
		(file-system
		 (device (file-system-label "guix-root"))
		 (mount-point "/")
		 (type "btrfs")
		 (options "subvol=rootfs,ssd,discard,compress"))
		(file-system
		 (device (file-system-label "Linux_home"))
		 (mount-point "/home")
		 (type "ext4"))
		(file-system
		 (device (uuid "1C31-A17C" 'fat))
		 (mount-point "/boot/efi")
		 (type "vfat"))
		%base-file-systems))
 )

[-- Attachment #1.1.3: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 4233 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 665 bytes --]

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

* bug#57307: guix system reports an error when uuid is used in menu-entry
  2022-08-20 10:08 bug#57307: guix system reports an error when uuid is used in menu-entry tiantian
@ 2022-08-21  8:39 ` Josselin Poiret via Bug reports for GNU Guix
  2022-08-21  8:41   ` bug#57307: [PATCH 1/2] bootloader: Convert device in menu-entry to proper sexp Josselin Poiret via Bug reports for GNU Guix
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Josselin Poiret via Bug reports for GNU Guix @ 2022-08-21  8:39 UTC (permalink / raw)
  To: tiantian, 57307

Hi, 

tiantian <typ22@foxmail.com> writes:

> I want to add an menu-entry in bootloader-configuration. I use uuid to 
> specify the partition in device field of menu-entry , because my 
> partition has no label. But when I use 'guix system reconfigure', guix 
> system reports an error: "guix system: error: #<<uuid> type: dce bv: 
> #vu8(109 91 19 212 96 146 70 208 139 228 7 61 192 116 19 204)>: invalid 
> G-expression input"

Right, this is an issue with how we translate the menu-entries to sexps
through `menu-entry->sexp`, which then get embedded into a g-exp via
`operating-system-boot-parameters-file`!  We didn't take into account
non-string devices there.  The following two patches should fix the
issue and introduce some tests for it.

Best,
-- 
Josselin Poiret




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

* bug#57307: [PATCH 1/2] bootloader: Convert device in menu-entry to proper sexp.
  2022-08-21  8:39 ` Josselin Poiret via Bug reports for GNU Guix
@ 2022-08-21  8:41   ` Josselin Poiret via Bug reports for GNU Guix
  2022-08-21  8:41   ` bug#57307: [PATCH 2/2] tests: Add test for menu-entry roundtrips as sexps Josselin Poiret via Bug reports for GNU Guix
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Josselin Poiret via Bug reports for GNU Guix @ 2022-08-21  8:41 UTC (permalink / raw)
  To: Josselin Poiret, tiantian, 57307

Previously, menu-entry->sexp didn't try to convert `device` to a
proper sexp, which was inserted directly into the boot parameters
G-exp, leading to a G-exp input error.  Now convert both uuid and
file-system-label possibilities to sexps, and add parsing code to
sexp->menu-entry.  This fixes #57307.

* gnu/bootloader.scm (menu-entry->sexp, sexp->menu-entry): Take
non-string devices into account.
---
 gnu/bootloader.scm | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 9cf5457873..1f08ab170e 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -21,6 +21,8 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu bootloader)
+  #:use-module (gnu system file-systems)
+  #:use-module (gnu system uuid)
   #:use-module (guix discovery)
   #:use-module (guix gexp)
   #:use-module (guix profiles)
@@ -105,12 +107,19 @@ (define-record-type* <menu-entry>
 
 (define (menu-entry->sexp entry)
   "Return ENTRY serialized as an sexp."
+  (define (device->sexp device)
+    (match device
+      ((? uuid? uuid)
+       `(uuid ,(uuid-type uuid) ,(uuid->string uuid)))
+      ((? file-system-label? label)
+       `(label ,(file-system-label->string label)))
+      (_ device)))
   (match entry
     (($ <menu-entry> label device mount-point linux linux-arguments initrd #f
                      ())
      `(menu-entry (version 0)
                   (label ,label)
-                  (device ,device)
+                  (device ,(device->sexp device))
                   (device-mount-point ,mount-point)
                   (linux ,linux)
                   (linux-arguments ,linux-arguments)
@@ -119,7 +128,7 @@ (define (menu-entry->sexp entry)
                      multiboot-kernel multiboot-arguments multiboot-modules)
      `(menu-entry (version 0)
                   (label ,label)
-                  (device ,device)
+                  (device ,(device->sexp device))
                   (device-mount-point ,mount-point)
                   (multiboot-kernel ,multiboot-kernel)
                   (multiboot-arguments ,multiboot-arguments)
@@ -128,6 +137,13 @@ (define (menu-entry->sexp entry)
 (define (sexp->menu-entry sexp)
   "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry>
 record."
+  (define (sexp->device device-sexp)
+    (match device-sexp
+      (('uuid type uuid-string)
+       (uuid uuid-string type))
+      (('label label)
+       (file-system-label label))
+      (_ device-sexp)))
   (match sexp
     (('menu-entry ('version 0)
                   ('label label) ('device device)
@@ -136,7 +152,7 @@ (define (sexp->menu-entry sexp)
                   ('initrd initrd) _ ...)
      (menu-entry
       (label label)
-      (device device)
+      (device (sexp->device device))
       (device-mount-point mount-point)
       (linux linux)
       (linux-arguments linux-arguments)
@@ -149,7 +165,7 @@ (define (sexp->menu-entry sexp)
                   ('multiboot-modules multiboot-modules) _ ...)
      (menu-entry
       (label label)
-      (device device)
+      (device (sexp->device device))
       (device-mount-point mount-point)
       (multiboot-kernel multiboot-kernel)
       (multiboot-arguments multiboot-arguments)

base-commit: b8f2eb286ec52c97048e23d326d94ae5772797e8
-- 
2.37.1





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

* bug#57307: [PATCH 2/2] tests: Add test for menu-entry roundtrips as sexps.
  2022-08-21  8:39 ` Josselin Poiret via Bug reports for GNU Guix
  2022-08-21  8:41   ` bug#57307: [PATCH 1/2] bootloader: Convert device in menu-entry to proper sexp Josselin Poiret via Bug reports for GNU Guix
@ 2022-08-21  8:41   ` Josselin Poiret via Bug reports for GNU Guix
       [not found]   ` <016c770e-b5d6-e2ab-b6b3-552b83496cc9@foxmail.com>
  2022-08-28 21:46   ` Marius Bakke
  3 siblings, 0 replies; 6+ messages in thread
From: Josselin Poiret via Bug reports for GNU Guix @ 2022-08-21  8:41 UTC (permalink / raw)
  To: Josselin Poiret, tiantian, 57307

* tests/boot-parameters.scm (%uuid-menu-entry,
%file-system-label-menu-entry): New variables.
("menu-entry roundtrip, uuid", "menu-entry roundtrip,
file-system-label"): New tests.
---
 tests/boot-parameters.scm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/boot-parameters.scm b/tests/boot-parameters.scm
index 8e48e1775e..811ecffd75 100644
--- a/tests/boot-parameters.scm
+++ b/tests/boot-parameters.scm
@@ -303,4 +303,26 @@ (define operating-system-boot-parameters
    (operating-system-boot-parameters %default-operating-system
                                      %default-root-device)))
 
+(define %uuid-menu-entry
+  (menu-entry
+   (label "test")
+   (device (uuid "6d5b13d4-6092-46d0-8be4-073dc07413cc"))
+   (linux "/boot/bzImage")
+   (initrd "/boot/initrd.cpio.gz")))
+
+(define %file-system-label-menu-entry
+  (menu-entry
+   (label "test")
+   (device (file-system-label "test-label"))
+   (linux "/boot/bzImage")
+   (initrd "/boot/initrd.cpio.gz")))
+
+(test-equal "menu-entry roundtrip, uuid"
+  %uuid-menu-entry
+  (sexp->menu-entry (menu-entry->sexp %uuid-menu-entry)))
+
+(test-equal "menu-entry roundtrip, file-system-label"
+  %file-system-label-menu-entry
+  (sexp->menu-entry (menu-entry->sexp %file-system-label-menu-entry)))
+
 (test-end "boot-parameters")
-- 
2.37.1





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

* bug#57307: guix system reports an error when uuid is used in menu-entry
       [not found]     ` <tencent_2CD86BF61F4285B61885E32B31122D6A0C09@qq.com>
@ 2022-08-21 13:03       ` Josselin Poiret via Bug reports for GNU Guix
  0 siblings, 0 replies; 6+ messages in thread
From: Josselin Poiret via Bug reports for GNU Guix @ 2022-08-21 13:03 UTC (permalink / raw)
  To: tiantian, 57307

Hi again,

tiantian <typ22@foxmail.com> writes:

> Should I close this bug now?

Let's wait for a maintainer to push the fix first, they will most likely
close the bug themselves.

I'm glad this fix worked and that you were able to figure out your other
issue!  See you around.

Best,
-- 
Josselin Poiret




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

* bug#57307: guix system reports an error when uuid is used in menu-entry
  2022-08-21  8:39 ` Josselin Poiret via Bug reports for GNU Guix
                     ` (2 preceding siblings ...)
       [not found]   ` <016c770e-b5d6-e2ab-b6b3-552b83496cc9@foxmail.com>
@ 2022-08-28 21:46   ` Marius Bakke
  3 siblings, 0 replies; 6+ messages in thread
From: Marius Bakke @ 2022-08-28 21:46 UTC (permalink / raw)
  To: Josselin Poiret, tiantian, 57307-done

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

Josselin Poiret via Bug reports for GNU Guix <bug-guix@gnu.org> skriver:

> Hi, 
>
> tiantian <typ22@foxmail.com> writes:
>
>> I want to add an menu-entry in bootloader-configuration. I use uuid to 
>> specify the partition in device field of menu-entry , because my 
>> partition has no label. But when I use 'guix system reconfigure', guix 
>> system reports an error: "guix system: error: #<<uuid> type: dce bv: 
>> #vu8(109 91 19 212 96 146 70 208 139 228 7 61 192 116 19 204)>: invalid 
>> G-expression input"
>
> Right, this is an issue with how we translate the menu-entries to sexps
> through `menu-entry->sexp`, which then get embedded into a g-exp via
> `operating-system-boot-parameters-file`!  We didn't take into account
> non-string devices there.  The following two patches should fix the
> issue and introduce some tests for it.

Pushed in:

  3294fa2ba4 tests: Add test for menu-entry roundtrips as sexps.
  0811d2cb8d bootloader: Convert device in menu-entry to proper sexp.

Thanks!

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

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

end of thread, other threads:[~2022-08-28 21:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-20 10:08 bug#57307: guix system reports an error when uuid is used in menu-entry tiantian
2022-08-21  8:39 ` Josselin Poiret via Bug reports for GNU Guix
2022-08-21  8:41   ` bug#57307: [PATCH 1/2] bootloader: Convert device in menu-entry to proper sexp Josselin Poiret via Bug reports for GNU Guix
2022-08-21  8:41   ` bug#57307: [PATCH 2/2] tests: Add test for menu-entry roundtrips as sexps Josselin Poiret via Bug reports for GNU Guix
     [not found]   ` <016c770e-b5d6-e2ab-b6b3-552b83496cc9@foxmail.com>
     [not found]     ` <tencent_2CD86BF61F4285B61885E32B31122D6A0C09@qq.com>
2022-08-21 13:03       ` bug#57307: guix system reports an error when uuid is used in menu-entry Josselin Poiret via Bug reports for GNU Guix
2022-08-28 21:46   ` Marius Bakke

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).