diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2015-06-24 17:41:43 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2015-06-24 18:05:03 +0200 |
| commit | e8277f90c88be9d65b948c299620fd9d6d9b28ae (patch) | |
| tree | 59b7b3e3fbaed726ac1a5a416b542373610d3284 /gnu/build/linux-initrd.scm | |
| parent | 7a18c3cc1098eab7499f6c8352211258432a527a (diff) | |
linux-initrd: Use (guix cpio) instead of GNU cpio.
* gnu/build/linux-initrd.scm (write-cpio-archive): Remove 'open-pipe*' and
related calls. Compute list of files in 'files' variable. Use
'cpio:write-cpio-archive'. Remove #:cpio parameter.
(build-initrd): Remove #:cpio parameter.
* gnu/system/linux-initrd.scm (expression->initrd): Likewise, and adjust
BUILDER accordingly. Add (guix cpio) to #:modules.
Diffstat (limited to 'gnu/build/linux-initrd.scm')
| -rw-r--r-- | gnu/build/linux-initrd.scm | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm index 54639bd319b..2c148836f35 100644 --- a/gnu/build/linux-initrd.scm +++ b/gnu/build/linux-initrd.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; This file is part of GNU Guix. | 4 | ;;; This file is part of GNU Guix. |
| 5 | ;;; | 5 | ;;; |
| @@ -17,12 +17,12 @@ | |||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | ||
| 19 | (define-module (gnu build linux-initrd) | 19 | (define-module (gnu build linux-initrd) |
| 20 | #:use-module ((guix cpio) #:prefix cpio:) | ||
| 20 | #:use-module (guix build utils) | 21 | #:use-module (guix build utils) |
| 21 | #:use-module (guix build store-copy) | 22 | #:use-module (guix build store-copy) |
| 22 | #:use-module (system base compile) | 23 | #:use-module (system base compile) |
| 23 | #:use-module (rnrs bytevectors) | 24 | #:use-module (rnrs bytevectors) |
| 24 | #:use-module ((system foreign) #:select (sizeof)) | 25 | #:use-module ((system foreign) #:select (sizeof)) |
| 25 | #:use-module (ice-9 popen) | ||
| 26 | #:use-module (ice-9 ftw) | 26 | #:use-module (ice-9 ftw) |
| 27 | #:export (write-cpio-archive | 27 | #:export (write-cpio-archive |
| 28 | build-initrd)) | 28 | build-initrd)) |
| @@ -38,42 +38,42 @@ | |||
| 38 | (define* (write-cpio-archive output directory | 38 | (define* (write-cpio-archive output directory |
| 39 | #:key | 39 | #:key |
| 40 | (compress? #t) | 40 | (compress? #t) |
| 41 | (cpio "cpio") (gzip "gzip")) | 41 | (gzip "gzip")) |
| 42 | "Write a cpio archive containing DIRECTORY to file OUTPUT, using CPIO. When | 42 | "Write a cpio archive containing DIRECTORY to file OUTPUT. When |
| 43 | COMPRESS? is true, compress it using GZIP. On success, return OUTPUT." | 43 | COMPRESS? is true, compress it using GZIP. On success, return OUTPUT." |
| 44 | 44 | ||
| 45 | ;; Note: don't use '--no-absolute-filenames' since that strips leading | 45 | ;; Note: as per `ramfs-rootfs-initramfs.txt', always add directory entries |
| 46 | ;; slashes from symlink targets. | 46 | ;; before the files that are inside of it: "The Linux kernel cpio |
| 47 | (let ((pipe (open-pipe* OPEN_WRITE cpio "-o" "-O" output | 47 | ;; extractor won't create files in a directory that doesn't exist, so the |
| 48 | "-H" "newc" "--null"))) | 48 | ;; directory entries must go before the files that go in those |
| 49 | (define (print0 file) | 49 | ;; directories." |
| 50 | (format pipe "~a\0" file)) | ||
| 51 | |||
| 52 | ;; Note: as per `ramfs-rootfs-initramfs.txt', always add directory entries | ||
| 53 | ;; before the files that are inside of it: "The Linux kernel cpio | ||
| 54 | ;; extractor won't create files in a directory that doesn't exist, so the | ||
| 55 | ;; directory entries must go before the files that go in those | ||
| 56 | ;; directories." | ||
| 57 | 50 | ||
| 51 | (define files | ||
| 58 | ;; XXX: Use a deterministic order. | 52 | ;; XXX: Use a deterministic order. |
| 59 | (file-system-fold (const #t) | 53 | (reverse |
| 60 | (lambda (file stat result) ; leaf | 54 | (file-system-fold (const #t) ;enter? |
| 61 | (print0 file)) | 55 | (lambda (file stat result) ;leaf |
| 62 | (lambda (dir stat result) ; down | 56 | (cons file result)) |
| 63 | (unless (string=? dir directory) | 57 | (lambda (dir stat result) ;down |
| 64 | (print0 dir))) | 58 | (if (string=? dir directory) |
| 65 | (const #f) ; up | 59 | result |
| 66 | (const #f) ; skip | 60 | (cons dir result))) |
| 67 | (const #f) | 61 | (lambda (file stat result) |
| 68 | #f | 62 | result) |
| 69 | directory) | 63 | (const #f) ;skip |
| 70 | 64 | (const #f) ;error | |
| 71 | (and (zero? (close-pipe pipe)) | 65 | '() |
| 72 | (or (not compress?) | 66 | directory))) |
| 73 | (and (zero? (system* gzip "--best" output)) | 67 | |
| 74 | (rename-file (string-append output ".gz") | 68 | (call-with-output-file output |
| 75 | output)) | 69 | (lambda (port) |
| 76 | output)))) | 70 | (cpio:write-cpio-archive files port))) |
| 71 | |||
| 72 | (or (not compress?) | ||
| 73 | (and (zero? (system* gzip "--best" output)) | ||
| 74 | (rename-file (string-append output ".gz") | ||
| 75 | output)) | ||
| 76 | output)) | ||
| 77 | 77 | ||
| 78 | (define (cache-compiled-file-name file) | 78 | (define (cache-compiled-file-name file) |
| 79 | "Return the file name of the in-cache .go file for FILE, relative to the | 79 | "Return the file name of the in-cache .go file for FILE, relative to the |
| @@ -105,7 +105,6 @@ This is similar to what 'compiled-file-name' in (system base compile) does." | |||
| 105 | #:key | 105 | #:key |
| 106 | guile init | 106 | guile init |
| 107 | (references-graphs '()) | 107 | (references-graphs '()) |
| 108 | (cpio "cpio") | ||
| 109 | (gzip "gzip")) | 108 | (gzip "gzip")) |
| 110 | "Write an initial RAM disk (initrd) to OUTPUT. The initrd starts the script | 109 | "Write an initial RAM disk (initrd) to OUTPUT. The initrd starts the script |
| 111 | at INIT, running GUILE. It contains all the items referred to by | 110 | at INIT, running GUILE. It contains all the items referred to by |
| @@ -134,8 +133,7 @@ REFERENCES-GRAPHS." | |||
| 134 | (utime file 0 0 0 0))) | 133 | (utime file 0 0 0 0))) |
| 135 | (find-files "." ".*")) | 134 | (find-files "." ".*")) |
| 136 | 135 | ||
| 137 | (write-cpio-archive output "." | 136 | (write-cpio-archive output "." #:gzip gzip)) |
| 138 | #:cpio cpio #:gzip gzip)) | ||
| 139 | 137 | ||
| 140 | (delete-file-recursively "contents")) | 138 | (delete-file-recursively "contents")) |
| 141 | 139 | ||
