GNU bug report logs - #34195
[PATCH] linux-modules: Add module-soft-dependencies.

Previous Next

Package: guix-patches;

Reported by: Danny Milosavljevic <dannym <at> scratchpost.org>

Date: Fri, 25 Jan 2019 11:31:02 UTC

Severity: normal

Tags: patch

Done: Danny Milosavljevic <dannym <at> scratchpost.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: bug#34195: closed (Re: [PATCH v2] linux-modules: Add
 modules-soft-dependencies.)
Date: Fri, 25 Jan 2019 17:26:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#34195: [PATCH] linux-modules: Add module-soft-dependencies.

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 34195 <at> debbugs.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)]
From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 34195-done <at> debbugs.gnu.org
Subject: Re: [PATCH v2] linux-modules: Add modules-soft-dependencies.
Date: Fri, 25 Jan 2019 18:25:37 +0100
[Message part 3 (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 4 (application/pgp-signature, inline)]
[Message part 5 (message/rfc822, inline)]
From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: guix-patches <at> gnu.org,
	ludo <at> gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH] linux-modules: Add module-soft-dependencies.
Date: Fri, 25 Jan 2019 12:30:32 +0100
* 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)))



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.