unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#51599] [PATCH 1/2] gnu: genimage: upgrade to v14
@ 2021-11-04  8:35 Ryan Sundberg via Guix-patches via
  2021-11-04  8:35 ` [bug#51598] [PATCH 2/2] image: Support generating GPT images via `partition-table-type` Ryan Sundberg via Guix-patches via
  2021-11-12 13:32 ` bug#51599: [PATCH 1/2] gnu: genimage: upgrade to v14 Mathieu Othacehe
  0 siblings, 2 replies; 4+ messages in thread
From: Ryan Sundberg via Guix-patches via @ 2021-11-04  8:35 UTC (permalink / raw)
  To: 51599; +Cc: Ryan Sundberg

Upgrades genimage from version 11 to 14. A patch is required for the
tests due to differences in ext tooling.

* gnu/local.mk: Replace patch reference
* gnu/packages/genimage.scm: Update package source
* gnu/packages/patches/genimage-mke2fs-test.patch: New patch file
* gnu/packages/patches/genimage-signedness.patch: Delete obsolete patch
---
 gnu/local.mk                                  |  2 +-
 gnu/packages/genimage.scm                     |  8 ++--
 .../patches/genimage-mke2fs-test.patch        | 40 +++++++++++++++++++
 .../patches/genimage-signedness.patch         | 24 -----------
 4 files changed, 45 insertions(+), 29 deletions(-)
 create mode 100644 gnu/packages/patches/genimage-mke2fs-test.patch
 delete mode 100644 gnu/packages/patches/genimage-signedness.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 17d8cb60e0..d550cff648 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1112,7 +1112,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gdk-pixbuf-CVE-2020-29385.patch		\
   %D%/packages/patches/gdm-default-session.patch		\
   %D%/packages/patches/geary-CVE-2020-24661.patch		\
-  %D%/packages/patches/genimage-signedness.patch		\
+  %D%/packages/patches/genimage-mke2fs-test.patch		\
   %D%/packages/patches/geoclue-config.patch			\
   %D%/packages/patches/ghc-8.0-fall-back-to-madv_dontneed.patch	\
   %D%/packages/patches/ghc-testsuite-dlopen-pie.patch		\
diff --git a/gnu/packages/genimage.scm b/gnu/packages/genimage.scm
index bd77e4dc33..366ff62ab4 100644
--- a/gnu/packages/genimage.scm
+++ b/gnu/packages/genimage.scm
@@ -42,7 +42,7 @@
 (define-public genimage
   (package
     (name "genimage")
-    (version "11")
+    (version "14")
     (source (origin
               (method git-fetch)
               (uri (git-reference
@@ -51,9 +51,9 @@
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "15jmh17lvm3jw9c92bjarly7iwhmnfl322d91mprfv10ppb9ip54"))
-              ;; will be shipped with release 14
-              (patches (search-patches "genimage-signedness.patch"))))
+                "1l45djpbaffhyw0allq3mgzwrdilk05iyj0nvp8l3s47vnp5bnbs"))
+              ;; Different version of ext4 
+              (patches (search-patches "genimage-mke2fs-test.patch"))))
     (build-system gnu-build-system)
     (arguments
      `(#:phases
diff --git a/gnu/packages/patches/genimage-mke2fs-test.patch b/gnu/packages/patches/genimage-mke2fs-test.patch
new file mode 100644
index 0000000000..c4a17590f2
--- /dev/null
+++ b/gnu/packages/patches/genimage-mke2fs-test.patch
@@ -0,0 +1,40 @@
+diff --git a/test/mke2fs.dump b/test/mke2fs.dump
+index 8e63662..0c25798 100644
+--- a/test/mke2fs.dump
++++ b/test/mke2fs.dump
+@@ -11,7 +11,7 @@ Filesystem OS type:       Linux
+ Inode count:              8192
+ Block count:              32768
+ Reserved block count:     1638
+-Free blocks:              26568
++Free blocks:              26566
+ Free inodes:              8141
+ First block:              1
+ Block size:               1024
+@@ -29,7 +29,7 @@ Mount count:              0
+ Maximum mount count:      -1
+ Last checked:             Sat Jan  1 00:00:00 2000
+ Check interval:           0 (<none>)
+-Lifetime writes:          141 kB
++Lifetime writes:          143 kB
+ Reserved blocks uid:      0 (user root)
+ Reserved blocks gid:      0 (group root)
+ First inode:              11
+@@ -49,13 +49,13 @@ Journal sequence:         0x00000001
+ Journal start:            0
+ 
+ 
+-Group 0: (Blocks 1-8192) csum 0x74a0 [ITABLE_ZEROED]
++Group 0: (Blocks 1-8192) csum 0x3f30 [ITABLE_ZEROED]
+   Primary superblock at 1, Group descriptors at 2-2
+-  Block bitmap at 3 (+2), csum 0x16cec4db
++  Block bitmap at 3 (+2), csum 0x8d67cdef
+   Inode bitmap at 7 (+6), csum 0xb1052088
+   Inode table at 11-522 (+10)
+-  6093 free blocks, 1997 free inodes, 18 directories, 1997 unused inodes
+-  Free blocks: 2100-8192
++  6091 free blocks, 1997 free inodes, 18 directories, 1997 unused inodes
++  Free blocks: 2102-8192
+   Free inodes: 52-2048
+ Group 1: (Blocks 8193-16384) csum 0x8fde [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
+   Backup superblock at 8193, Group descriptors at 8194-8194
diff --git a/gnu/packages/patches/genimage-signedness.patch b/gnu/packages/patches/genimage-signedness.patch
deleted file mode 100644
index 2204dfb545..0000000000
--- a/gnu/packages/patches/genimage-signedness.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-commit 6574665f9d6c0757e8f55ccb465afbcaa90bf019
-Author: Timotej Lazar <timotej.lazar@araneo.si>
-Date:   Wed Aug 19 19:36:02 2020 +0200
-
-    test: normalize flags reported by dumpe2fs
-    
-    Filesystem flags depend on the system – usually signed_directory_hash,
-    but unsigned_directory_hash at least on arm64.
-    
-    Signed-off-by: Timotej Lazar <timotej.lazar@araneo.si>
-
-diff --git a/test/basic-images.test b/test/basic-images.test
-index f6685e1..cb104c3 100755
---- a/test/basic-images.test
-+++ b/test/basic-images.test
-@@ -158,6 +158,8 @@ check_ext() {
- 	# format change
- 	csum2="Group 0: (Blocks 1-4095) \\[ITABLE_ZEROED\\]\|  Checksum .*, unused inodes 205"
- 	dumpe2fs "${1}" | grep -v "^\($uuid\|$seed\|$csum1\|$csum2\)" > "dump" &&
-+	# some architectures (including arm64) use unsigned char
-+	sed -i 's/un\(signed_directory_hash\)/\1/' "dump" &&
- 	# fixup for ext3 journal size with old tune2fs
- 	sed -i 's/^\(Journal size:             \)1029k$/\11024k/' "dump" &&
- 	# output format changed with some version
-- 
2.31.1





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

* [bug#51598] [PATCH 2/2] image: Support generating GPT images via `partition-table-type`
  2021-11-04  8:35 [bug#51599] [PATCH 1/2] gnu: genimage: upgrade to v14 Ryan Sundberg via Guix-patches via
@ 2021-11-04  8:35 ` Ryan Sundberg via Guix-patches via
  2021-11-12 13:37   ` bug#51598: " Mathieu Othacehe
  2021-11-12 13:32 ` bug#51599: [PATCH 1/2] gnu: genimage: upgrade to v14 Mathieu Othacehe
  1 sibling, 1 reply; 4+ messages in thread
From: Ryan Sundberg via Guix-patches via @ 2021-11-04  8:35 UTC (permalink / raw)
  To: 51598; +Cc: Ryan Sundberg

* gnu/image.scm: Add partition-table-type field to image
* gnu/system/image.scm: Implement partition-table-type logic for
genimage.
---
 gnu/image.scm        |  3 +++
 gnu/system/image.scm | 59 +++++++++++++++++++++++++++++++-------------
 2 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/gnu/image.scm b/gnu/image.scm
index 75d489490d..b83c4275da 100644
--- a/gnu/image.scm
+++ b/gnu/image.scm
@@ -37,6 +37,7 @@
             image-target
             image-size
             image-operating-system
+            image-partition-table-type
             image-partitions
             image-compression?
             image-volatile-root?
@@ -84,6 +85,8 @@
                       (default 'guess))
   (operating-system   image-operating-system  ;<operating-system>
                       (default #f))
+  (partition-table-type image-partition-table-type ; 'mbr or 'gpt
+                      (default 'mbr))
   (partitions         image-partitions ;list of <partition>
                       (default '()))
   (compression?       image-compression? ;boolean
diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index 7a3a637e47..ed22484a62 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -309,6 +309,14 @@ used in the image."
          ((member 'esp flags) "0xEF")
          (else "0x83"))))
 
+    (define (partition->gpt-type partition)
+      ;; Return the genimage GPT partition type code corresponding to PARTITION.
+      ;; See https://github.com/pengutronix/genimage/blob/master/README.rst
+      (let ((flags (partition-flags partition)))
+        (cond
+          ((member 'esp flags) "U")
+          (else "L"))))
+
     (define (partition-image partition)
       ;; Return as a file-like object, an image of the given PARTITION.  A
       ;; directory, filled by calling the PARTITION initializer procedure, is
@@ -358,26 +366,43 @@ used in the image."
                        #:local-build? #f
                        #:options `(#:references-graphs ,inputs))))
 
-    (define (partition->config partition)
+    (define (gpt-image? image)
+      (eq? 'gpt (image-partition-table-type image)))
+
+    (define (partition-type-values image partition)
+      (if (gpt-image? image)
+          (values "partition-type-uuid" (partition->gpt-type partition))
+          (values "partition-type" (partition->dos-type partition))))
+
+    (define (partition->config image partition)
       ;; Return the genimage partition configuration for PARTITION.
-      (let ((label (partition-label partition))
-            (dos-type (partition->dos-type partition))
-            (image (partition-image partition))
-            (offset (partition-offset partition)))
-        #~(format #f "~/partition ~a {
-~/~/partition-type = ~a
-~/~/image = \"~a\"
-~/~/offset = \"~a\"
-~/}"
-                  #$label
-                  #$dos-type
-                  #$image
-                  #$offset)))
+      (let-values (((partition-type-attribute partition-type-value) (partition-type-values image partition)))
+        (let ((label (partition-label partition))
+              (image (partition-image partition))
+              (offset (partition-offset partition)))
+          #~(format #f "~/partition ~a {
+  ~/~/~a = ~a
+  ~/~/image = \"~a\"
+  ~/~/offset = \"~a\"
+  ~/}"
+                    #$label
+                    #$partition-type-attribute
+                    #$partition-type-value
+                    #$image
+                    #$offset))))
+
+    (define (genimage-type-options image-type image)
+      (cond
+        ((equal? image-type "hdimage")
+         (format #f "~%~/~/gpt = ~a~%~/" 
+                 (if (gpt-image? image) "true" "false")))
+        (else "")))
 
     (let* ((format (image-format image))
            (image-type (format->image-type format))
+           (image-type-options (genimage-type-options image-type image))
            (partitions (image-partitions image))
-           (partitions-config (map partition->config partitions))
+           (partitions-config (map (cut partition->config image <>) partitions))
            (builder
             #~(begin
                 (let ((format (@ (ice-9 format) format)))
@@ -386,9 +411,9 @@ used in the image."
                       (format port
                               "\
 image ~a {
-~/~a {}
+~/~a {~a}
 ~{~a~^~%~}
-}~%" #$genimage-name #$image-type (list #$@partitions-config))))))))
+}~%" #$genimage-name #$image-type #$image-type-options (list #$@partitions-config))))))))
       (computed-file "genimage.cfg" builder)))
 
   (let* ((image-name (image-name image))
-- 
2.31.1





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

* bug#51599: [PATCH 1/2] gnu: genimage: upgrade to v14
  2021-11-04  8:35 [bug#51599] [PATCH 1/2] gnu: genimage: upgrade to v14 Ryan Sundberg via Guix-patches via
  2021-11-04  8:35 ` [bug#51598] [PATCH 2/2] image: Support generating GPT images via `partition-table-type` Ryan Sundberg via Guix-patches via
@ 2021-11-12 13:32 ` Mathieu Othacehe
  1 sibling, 0 replies; 4+ messages in thread
From: Mathieu Othacehe @ 2021-11-12 13:32 UTC (permalink / raw)
  To: Ryan Sundberg; +Cc: 51599-done


Hello Ryan,

> * gnu/local.mk: Replace patch reference
> * gnu/packages/genimage.scm: Update package source
> * gnu/packages/patches/genimage-mke2fs-test.patch: New patch file
> * gnu/packages/patches/genimage-signedness.patch: Delete obsolete patch

Pushed with an edited commit message.

Thanks,

Mathieu




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

* bug#51598: [PATCH 2/2] image: Support generating GPT images via `partition-table-type`
  2021-11-04  8:35 ` [bug#51598] [PATCH 2/2] image: Support generating GPT images via `partition-table-type` Ryan Sundberg via Guix-patches via
@ 2021-11-12 13:37   ` Mathieu Othacehe
  0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Othacehe @ 2021-11-12 13:37 UTC (permalink / raw)
  To: Ryan Sundberg; +Cc: 51598-done


Hello Ryan

Nice one! I tried to generate a GPT image like so:

--8<---------------cut here---------------start------------->8---
$ cat /tmp/my-img.scm
(use-modules (gnu)
             (gnu image)
             (gnu system image))

(define my-os
  (primitive-load "/home/mathieu/guix/gnu/system/examples/lightweight-desktop.tmpl"))

(image
 (inherit
  (os->image my-os #:type efi-raw-image-type))
 (name 'raw-gpt)
 (partition-table-type 'gpt))

$ ./pre-inst-env guix system image /tmp/img.scm
--8<---------------cut here---------------end--------------->8---

However, the resulting image was not bootable because Grub was lacking
the part_gpt module. This is now fixed with
fb3df2011692b2a6fea9f4fefd71dd788453fbae.

I also noticed that trying to build a GPT image with a grub-bootloader
(bare-bones.tmpl image for instance), failed at build time, probably
because install-grub-disk-image is expecting an msdos partition.

It would be great if you could have a look to this issue as a follow-up :).

I pushed this patch anyway as 096a2bf8c59a955c634cc838e7f7111941c07b37.

Thanks,

Mathieu




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

end of thread, other threads:[~2021-11-12 13:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-04  8:35 [bug#51599] [PATCH 1/2] gnu: genimage: upgrade to v14 Ryan Sundberg via Guix-patches via
2021-11-04  8:35 ` [bug#51598] [PATCH 2/2] image: Support generating GPT images via `partition-table-type` Ryan Sundberg via Guix-patches via
2021-11-12 13:37   ` bug#51598: " Mathieu Othacehe
2021-11-12 13:32 ` bug#51599: [PATCH 1/2] gnu: genimage: upgrade to v14 Mathieu Othacehe

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