diff options
| author | Mathieu Othacehe <othacehe@gnu.org> | 2020-07-05 12:23:21 +0200 |
|---|---|---|
| committer | Mathieu Othacehe <othacehe@gnu.org> | 2020-08-25 11:53:20 +0200 |
| commit | 755f365b02b42a5d1e8ef3000dadef069553a478 (patch) | |
| tree | 57ce759104439219c2c6076aa3c1af875487c5c1 /gnu/system/linux-initrd.scm | |
| parent | 46ef674b34fd63f6bcd5bd07348d5c66eb8bdf29 (diff) | |
linux-libre: Support module compression.
This commit adds support for GZIP compression for linux-libre kernel
modules. The initrd modules are kept uncompressed as the initrd is already
compressed as a whole.
The linux-libre kernel also supports XZ compression, but as Guix does not have
any available bindings for now, and the compression time is far more
significant, GZIP seems to be a better option.
* gnu/build/linux-modules.scm (modinfo-section-contents): Use
'call-with-gzip-input-port' to read from a module file using '.gz' extension,
(strip-extension): new procedure,
(dot-ko): adapt to support compression,
(ensure-dot-ko): ditto,
(file-name->module-name): ditto,
(find-module-file): ditto,
(load-linux-module*): ditto,
(module-name->file-name/guess): ditto,
(module-name-lookup): ditto,
(write-module-name-database): ditto,
(write-module-alias-database): ditto,
(write-module-device-database): ditto.
* gnu/installer.scm (installer-program): Add "guile-zlib" to the extensions.
* gnu/machine/ssh.scm (machine-check-initrd-modules): Ditto.
* gnu/services.scm (activation-script): Ditto.
* gnu/services/base.scm (default-serial-port): Ditto,
(agetty-shepherd-service): ditto,
(udev-service-type): ditto.
* gnu/system/image.scm (gcrypt-sqlite3&co): Ditto.
* gnu/system/linux-initrd.scm (flat-linux-module-directory): Add "guile-zlib"
to the extensions and make sure that the initrd only contains
uncompressed module files.
* gnu/system/shadow.scm (account-shepherd-service): Add "guile-zlib" to the
extensions.
* guix/profiles.scm (linux-module-database): Ditto.
Diffstat (limited to 'gnu/system/linux-initrd.scm')
| -rw-r--r-- | gnu/system/linux-initrd.scm | 72 |
1 files changed, 45 insertions, 27 deletions
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 0971ec29e21..b8a30c0abc6 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm | |||
| @@ -77,6 +77,9 @@ the derivations referenced by EXP are automatically copied to the initrd." | |||
| 77 | (program-file "init" exp #:guile guile)) | 77 | (program-file "init" exp #:guile guile)) |
| 78 | 78 | ||
| 79 | (define builder | 79 | (define builder |
| 80 | ;; Do not use "guile-zlib" extension here, otherwise it would drag the | ||
| 81 | ;; non-static "zlib" package to the initrd closure. It is not needed | ||
| 82 | ;; anyway because the modules are stored uncompressed within the initrd. | ||
| 80 | (with-imported-modules (source-module-closure | 83 | (with-imported-modules (source-module-closure |
| 81 | '((gnu build linux-initrd))) | 84 | '((gnu build linux-initrd))) |
| 82 | #~(begin | 85 | #~(begin |
| @@ -111,34 +114,49 @@ the derivations referenced by EXP are automatically copied to the initrd." | |||
| 111 | (define (flat-linux-module-directory linux modules) | 114 | (define (flat-linux-module-directory linux modules) |
| 112 | "Return a flat directory containing the Linux kernel modules listed in | 115 | "Return a flat directory containing the Linux kernel modules listed in |
| 113 | MODULES and taken from LINUX." | 116 | MODULES and taken from LINUX." |
| 114 | (define build-exp | 117 | (define imported-modules |
| 115 | (with-imported-modules (source-module-closure | 118 | (source-module-closure '((gnu build linux-modules) |
| 116 | '((gnu build linux-modules))) | 119 | (guix build utils)))) |
| 117 | #~(begin | ||
| 118 | (use-modules (gnu build linux-modules) | ||
| 119 | (srfi srfi-1) | ||
| 120 | (srfi srfi-26)) | ||
| 121 | |||
| 122 | (define module-dir | ||
| 123 | (string-append #$linux "/lib/modules")) | ||
| 124 | 120 | ||
| 125 | (define modules | 121 | (define build-exp |
| 126 | (let* ((lookup (cut find-module-file module-dir <>)) | 122 | (with-imported-modules imported-modules |
| 127 | (modules (map lookup '#$modules))) | 123 | (with-extensions (list guile-zlib) |
| 128 | (append modules | 124 | #~(begin |
| 129 | (recursive-module-dependencies modules | 125 | (use-modules (gnu build linux-modules) |
| 130 | #:lookup-module lookup)))) | 126 | (guix build utils) |
| 131 | 127 | (srfi srfi-1) | |
| 132 | (mkdir #$output) | 128 | (srfi srfi-26)) |
| 133 | (for-each (lambda (module) | 129 | |
| 134 | (format #t "copying '~a'...~%" module) | 130 | (define module-dir |
| 135 | (copy-file module | 131 | (string-append #$linux "/lib/modules")) |
| 136 | (string-append #$output "/" | 132 | |
| 137 | (basename module)))) | 133 | (define modules |
| 138 | (delete-duplicates modules)) | 134 | (let* ((lookup (cut find-module-file module-dir <>)) |
| 139 | 135 | (modules (map lookup '#$modules))) | |
| 140 | ;; Hyphen or underscore? This database tells us. | 136 | (append modules |
| 141 | (write-module-name-database #$output)))) | 137 | (recursive-module-dependencies |
| 138 | modules | ||
| 139 | #:lookup-module lookup)))) | ||
| 140 | |||
| 141 | (define (maybe-uncompress file) | ||
| 142 | ;; If FILE is a compressed module, uncompress it, as the initrd | ||
| 143 | ;; is already gzipped as a whole. | ||
| 144 | (cond | ||
| 145 | ((string-contains file ".ko.gz") | ||
| 146 | (invoke #+(file-append gzip "/bin/gunzip") file)))) | ||
| 147 | |||
| 148 | (mkdir #$output) | ||
| 149 | (for-each (lambda (module) | ||
| 150 | (let ((out-module | ||
| 151 | (string-append #$output "/" | ||
| 152 | (basename module)))) | ||
| 153 | (format #t "copying '~a'...~%" module) | ||
| 154 | (copy-file module out-module) | ||
| 155 | (maybe-uncompress out-module))) | ||
| 156 | (delete-duplicates modules)) | ||
| 157 | |||
| 158 | ;; Hyphen or underscore? This database tells us. | ||
| 159 | (write-module-name-database #$output))))) | ||
| 142 | 160 | ||
| 143 | (computed-file "linux-modules" build-exp)) | 161 | (computed-file "linux-modules" build-exp)) |
| 144 | 162 | ||
