diff options
Diffstat (limited to 'gnu/build')
-rw-r--r-- | gnu/build/file-systems.scm | 14 | ||||
-rw-r--r-- | gnu/build/linux-modules.scm | 28 |
2 files changed, 39 insertions, 3 deletions
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index e3369d8521..c468144170 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -42,6 +42,10 @@ find-partition-by-luks-uuid canonicalize-device-spec + read-partition-label + read-partition-uuid + read-luks-partition-uuid + bind-mount mount-flags->bit-mask @@ -435,6 +439,12 @@ partition field reader that returned a value." (define read-partition-uuid (cut read-partition-field <> %partition-uuid-readers)) +(define luks-partition-field-reader + (partition-field-reader read-luks-header luks-header-uuid)) + +(define read-luks-partition-uuid + (cut read-partition-field <> (list luks-partition-field-reader))) + (define (partition-predicate reader =) "Return a predicate that returns true if the FIELD of partition header that was READ is = to the given value." @@ -451,9 +461,7 @@ was READ is = to the given value." (partition-predicate read-partition-uuid uuid=?)) (define luks-partition-uuid-predicate - (partition-predicate - (partition-field-reader read-luks-header luks-header-uuid) - uuid=?)) + (partition-predicate luks-partition-field-reader uuid=?)) (define (find-partition predicate) "Return the first partition found that matches PREDICATE, or #f if none diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm index 2d81175041..d69bcbf5a2 100644 --- a/gnu/build/linux-modules.scm +++ b/gnu/build/linux-modules.scm @@ -33,6 +33,7 @@ ensure-dot-ko module-aliases module-dependencies + module-soft-dependencies normalize-module-name file-name->module-name find-module-file @@ -100,6 +101,33 @@ contains module names, not actual file names." (('depends . what) (string-tokenize what %not-comma))))) +(define not-softdep-whitespace + (char-set-complement (char-set #\space #\tab))) + +(define (module-soft-dependencies file) + "Return a list of (cons section soft-dependency) of module FILE." + ;; TEXT: "pre: baz blubb foo post: bax bar" + (define (parse-softdep text) + (let loop ((value '()) + (tokens (string-tokenize text not-softdep-whitespace)) + (section #f)) + (match tokens + ((token rest ...) + (if (string=? (string-take-right token 1) ":") ; section + (loop value rest (string-trim-both (string-drop-right token 1))) + (loop (cons (cons section token) value) rest section))) + (() + value)))) + + ;; Note: Multiple 'softdep sections are allowed. + (let ((info (modinfo-section-contents file))) + (concatenate + (filter-map (match-lambda + (('softdep . value) + (parse-softdep value)) + (_ #f)) + (modinfo-section-contents file))))) + (define (module-aliases file) "Return the list of aliases of module FILE." (let ((info (modinfo-section-contents file))) |