diff options
| author | Mathieu Othacehe <othacehe@gnu.org> | 2022-08-31 14:59:06 +0200 |
|---|---|---|
| committer | Mathieu Othacehe <othacehe@gnu.org> | 2022-08-31 14:59:43 +0200 |
| commit | 16a6cbe94700da82ab223999df1ed4ba049676b1 (patch) | |
| tree | 9102c60ee76a0ac5bd85a4e6f1a5194ab721d6c0 /gnu/image.scm | |
| parent | c263cf3b3677c9d92525ceff96d344d7b73e1d0d (diff) | |
image: Add comments.
* gnu/image.scm: Add some comments across the whole module.
Diffstat (limited to 'gnu/image.scm')
| -rw-r--r-- | gnu/image.scm | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gnu/image.scm b/gnu/image.scm index 64bae48d515..a031e879243 100644 --- a/gnu/image.scm +++ b/gnu/image.scm | |||
| @@ -64,6 +64,9 @@ | |||
| 64 | ;;; Sanitizers. | 64 | ;;; Sanitizers. |
| 65 | ;;; | 65 | ;;; |
| 66 | 66 | ||
| 67 | ;; Image and partition sizes can be either be a size in bytes or the 'guess | ||
| 68 | ;; symbol denoting that the size should be estimated by Guix, according to the | ||
| 69 | ;; image content. | ||
| 67 | (define-with-syntax-properties (validate-size (value properties)) | 70 | (define-with-syntax-properties (validate-size (value properties)) |
| 68 | (unless (and value | 71 | (unless (and value |
| 69 | (or (eq? value 'guess) (integer? value))) | 72 | (or (eq? value 'guess) (integer? value))) |
| @@ -82,6 +85,7 @@ | |||
| 82 | ;;; Partition record. | 85 | ;;; Partition record. |
| 83 | ;;; | 86 | ;;; |
| 84 | 87 | ||
| 88 | ;; The partition offset should be a bytes count as an integer. | ||
| 85 | (define-with-syntax-properties (validate-partition-offset (value properties)) | 89 | (define-with-syntax-properties (validate-partition-offset (value properties)) |
| 86 | (unless (and value (integer? value)) | 90 | (unless (and value (integer? value)) |
| 87 | (raise | 91 | (raise |
| @@ -94,6 +98,7 @@ | |||
| 94 | numeric expression ~%") value 'field)))) | 98 | numeric expression ~%") value 'field)))) |
| 95 | value) | 99 | value) |
| 96 | 100 | ||
| 101 | ;; The supported partition flags. | ||
| 97 | (define-with-syntax-properties (validate-partition-flags (value properties)) | 102 | (define-with-syntax-properties (validate-partition-flags (value properties)) |
| 98 | (let ((bad-flags (lset-difference eq? value '(boot esp)))) | 103 | (let ((bad-flags (lset-difference eq? value '(boot esp)))) |
| 99 | (unless (and (list? value) (null? bad-flags)) | 104 | (unless (and (list? value) (null? bad-flags)) |
| @@ -144,8 +149,11 @@ that is not in SET, mentioning FIELD in the error message." | |||
| 144 | (formatted-message (G_ "~s: invalid '~a' value") value 'field)))) | 149 | (formatted-message (G_ "~s: invalid '~a' value") value 'field)))) |
| 145 | value)) | 150 | value)) |
| 146 | 151 | ||
| 152 | ;; The supported image formats. | ||
| 147 | (define-set-sanitizer validate-image-format format | 153 | (define-set-sanitizer validate-image-format format |
| 148 | (disk-image compressed-qcow2 docker iso9660)) | 154 | (disk-image compressed-qcow2 docker iso9660)) |
| 155 | |||
| 156 | ;; The supported partition table types. | ||
| 149 | (define-set-sanitizer validate-partition-table-type partition-table-type | 157 | (define-set-sanitizer validate-partition-table-type partition-table-type |
| 150 | (mbr gpt)) | 158 | (mbr gpt)) |
| 151 | 159 | ||
| @@ -184,6 +192,22 @@ that is not in SET, mentioning FIELD in the error message." | |||
| 184 | ;;; Image type. | 192 | ;;; Image type. |
| 185 | ;;; | 193 | ;;; |
| 186 | 194 | ||
| 195 | ;; The role of this record is to provide a constructor that is able to turn an | ||
| 196 | ;; <operating-system> record into an <image> record. Some basic <image-type> | ||
| 197 | ;; records are defined in the (gnu system image) module. They are able to | ||
| 198 | ;; turn an <operating-system> record into an EFI or an ISO 9660 bootable | ||
| 199 | ;; image, a Docker image or even a QCOW2 image. | ||
| 200 | ;; | ||
| 201 | ;; Other <image-type> records are defined in the (gnu system images ...) | ||
| 202 | ;; modules. They are dedicated to specific machines such as Novena and Pine64 | ||
| 203 | ;; SoC boards that require specific images. | ||
| 204 | ;; | ||
| 205 | ;; All the available <image-type> records are collected by the 'image-modules' | ||
| 206 | ;; procedure. This allows the "guix system image" command to turn a given | ||
| 207 | ;; <operating-system> record into an image, thanks to the specified | ||
| 208 | ;; <image-type>. In that case, the <image-type> look up is done using the | ||
| 209 | ;; name field of the <image-type> record. | ||
| 210 | |||
| 187 | (define-record-type* <image-type> | 211 | (define-record-type* <image-type> |
| 188 | image-type make-image-type | 212 | image-type make-image-type |
| 189 | image-type? | 213 | image-type? |
| @@ -196,10 +220,15 @@ that is not in SET, mentioning FIELD in the error message." | |||
| 196 | ;;; | 220 | ;;; |
| 197 | 221 | ||
| 198 | (define* (os->image os #:key type) | 222 | (define* (os->image os #:key type) |
| 223 | "Use the image constructor from TYPE, an <image-type> record to turn the | ||
| 224 | given OS, an <operating-system> record into an image and return it." | ||
| 199 | (let ((constructor (image-type-constructor type))) | 225 | (let ((constructor (image-type-constructor type))) |
| 200 | (constructor os))) | 226 | (constructor os))) |
| 201 | 227 | ||
| 202 | (define* (os+platform->image os platform #:key type) | 228 | (define* (os+platform->image os platform #:key type) |
| 229 | "Use the image constructor from TYPE, an <image-type> record to turn the | ||
| 230 | given OS, an <operating-system> record into an image targeting PLATFORM, a | ||
| 231 | <platform> record and return it." | ||
| 203 | (image | 232 | (image |
| 204 | (inherit (os->image os #:type type)) | 233 | (inherit (os->image os #:type type)) |
| 205 | (platform platform))) | 234 | (platform platform))) |
