GNU bug report logs -
#34195
[PATCH] linux-modules: Add module-soft-dependencies.
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Fri, 25 Jan 2019 18:25:37 +0100
with message-id <20190125182537.0535b710 <at> scratchpost.org>
and subject line Re: [PATCH v2] linux-modules: Add modules-soft-dependencies.
has caused the debbugs.gnu.org bug report #34195,
regarding [PATCH] linux-modules: Add module-soft-dependencies.
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
34195: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=34195
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
* gnu/build/linux-modules.scm (not-softdep-whitespace): New variable.
(module-soft-dependencies): New procedure.
---
gnu/build/linux-modules.scm | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 2d8117504..631c5f577 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,42 @@ 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 the list of soft dependencies of module FILE."
+ (define (add-to-first-acons value alist)
+ (match alist
+ (((k . v) . b)
+ (cons (cons k (cons value v)) b))))
+
+ ;; 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 _ ...)
+ (if (string=? (string-take-right token 1) ":") ; section
+ (loop value
+ (cdr tokens)
+ (string-trim-both token))
+ (loop (cons (cons section token) value)
+ (cdr tokens)
+ section)))
+ (()
+ value))))
+
+ ;; Note: Multiple 'softdep sections are allowed.
+ (let ((info (modinfo-section-contents file)))
+ (apply append
+ (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)))
[Message part 3 (message/rfc822, inline)]
[Message part 4 (text/plain, inline)]
Hi Ludo,
>That was fast! :-)
Yeah, I dislike ticking boot time bombs ;-)
Thanks for the review!
Pushed as 1a5f46621b44aa1458ad7acd4eca5fe1d4574f92
and 519be98c3536b5113cde368f9dc6db2e1ebe073e (tiny fix)
to guix master.
Note that it returns something like
(("pre" . "module-1") ("pre" . "module-2"))
So the user might want to
(1) map cdr (or match ;) ) it
(2) replace dashes by underscores if a filename is desired (normalize-module-name)
(although in practise nobody in the mainline Linux seems to use dashes there
right now, their example in include/linux/module.h has dashes :P)
Example result:
scheme> (module-soft-dependencies "/tmp/vfio.ko")
$2 = (("post" . "vfio_iommu_spapr_tce") ("post" . "vfio_iommu_type1"))
[Message part 5 (application/pgp-signature, inline)]
This bug report was last modified 6 years and 120 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.