From patchwork Fri Jan 25 11:48:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danny Milosavljevic X-Patchwork-Id: 816 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DEE3C169CD; Fri, 25 Jan 2019 11:51:36 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id AA35C169BD for ; Fri, 25 Jan 2019 11:51:36 +0000 (GMT) Received: from localhost ([127.0.0.1]:43097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gn01H-0001O1-M3 for patchwork@mira.cbaines.net; Fri, 25 Jan 2019 06:51:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmzyo-0008AO-Oi for guix-patches@gnu.org; Fri, 25 Jan 2019 06:49:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gmzyn-0003zG-WA for guix-patches@gnu.org; Fri, 25 Jan 2019 06:49:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gmzyn-0003xy-S0 for guix-patches@gnu.org; Fri, 25 Jan 2019 06:49:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gmzyn-0003ax-KJ for guix-patches@gnu.org; Fri, 25 Jan 2019 06:49:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#34195] [PATCH v2] linux-modules: Add modules-soft-dependencies. Resent-From: Danny Milosavljevic Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Jan 2019 11:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34195 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 34195@debbugs.gnu.org, ludo@gnu.org Received: via spool by 34195-submit@debbugs.gnu.org id=B34195.154841693113799 (code B ref 34195); Fri, 25 Jan 2019 11:49:01 +0000 Received: (at 34195) by debbugs.gnu.org; 25 Jan 2019 11:48:51 +0000 Received: from localhost ([127.0.0.1]:44605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gmzyc-0003aV-M2 for submit@debbugs.gnu.org; Fri, 25 Jan 2019 06:48:50 -0500 Received: from dd26836.kasserver.com ([85.13.145.193]:51390) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gmzya-0003aN-R3 for 34195@debbugs.gnu.org; Fri, 25 Jan 2019 06:48:49 -0500 Received: from dayas.3.home (178.112.231.18.wireless.dyn.drei.com [178.112.231.18]) by dd26836.kasserver.com (Postfix) with ESMTPSA id EF88B33614B8; Fri, 25 Jan 2019 12:48:46 +0100 (CET) From: Danny Milosavljevic Date: Fri, 25 Jan 2019 12:48:38 +0100 Message-Id: <20190125114838.8680-1-dannym@scratchpost.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125113032.8372-1-dannym@scratchpost.org> References: <20190125113032.8372-1-dannym@scratchpost.org> MIME-Version: 1.0 Tags: patch X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/build/linux-modules.scm (not-softdep-whitespace): New variable. (module-soft-dependencies): New procedure. --- gnu/build/linux-modules.scm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm index 2d8117504..1632f20d5 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,37 @@ 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 mode 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 _ ...) + (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)))