From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ermiD-0000uj-9u for guix-patches@gnu.org; Fri, 02 Mar 2018 10:35:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ermi9-0001cq-7l for guix-patches@gnu.org; Fri, 02 Mar 2018 10:35:09 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:33527) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ermi9-0001cj-5W for guix-patches@gnu.org; Fri, 02 Mar 2018 10:35:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ermi7-0003dy-96 for guix-patches@gnu.org; Fri, 02 Mar 2018 10:35:04 -0500 Subject: [bug#30604] [PATCH v7 2/6] linux-modules: Add install-modules. Resent-Message-ID: From: Danny Milosavljevic Date: Fri, 2 Mar 2018 16:34:04 +0100 Message-Id: <20180302153408.14091-3-dannym@scratchpost.org> In-Reply-To: <20180302153408.14091-1-dannym@scratchpost.org> References: <20180302141606.10669-1-dannym@scratchpost.org> <20180302153408.14091-1-dannym@scratchpost.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 30604@debbugs.gnu.org * gnu/build/linux-modules.scm (install-modules): New procedure. (%not-dash): New variable. --- gnu/build/linux-modules.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm index 364339df9..af217c974 100644 --- a/gnu/build/linux-modules.scm +++ b/gnu/build/linux-modules.scm @@ -36,6 +36,7 @@ modules-loaded module-loaded? load-linux-module* + install-module-files current-module-debugging-port @@ -379,4 +380,55 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by module))) known-aliases)) +(define %not-dash + (char-set-complement (char-set #\-))) + +(define (install-module-files module-files output) + "Install MODULE-FILES to OUTPUT. +Precondition: OUTPUT is an empty directory." + (let ((aliases + (map (lambda (module-file-name) + (format #t "copying '~a'...~%" module-file-name) + (copy-file module-file-name + (string-append output "/" + (basename module-file-name))) + `(,(file-name->module-name module-file-name) . + ,(module-aliases module-file-name))) + (sort module-files string<)))) + (call-with-output-file (string-append output "/modules.alias") + (lambda (port) + (format port + "# Aliases extracted from modules themselves.\n") + (for-each (match-lambda ((module . aliases) + (for-each (lambda (alias) + (format port "alias ~a ~a\n" alias + module)) + aliases))) + aliases))) + (call-with-output-file (string-append output "/modules.devname") + (lambda (port) + (format port + "# Device nodes to trigger on-demand module loading.\n") + (let* ((aliases (append-map (match-lambda + ((module . aliases) aliases)) + aliases)) + (devname #f)) + ;; Note: there's only one devname and then only one (char-major|block-major). + (for-each + (match-lambda + (((? (cut string-prefix? "devname:" <>) alias) . value) + (set! devname (string-drop value (string-length "devname:")))) + (((? (cut string-prefix? "char-major-" <>) alias) . value) + (let ((parts (string-tokenize %not-dash))) + (match parts + ((a b major minor) + (format port "~a ~a ~a:~a\n" devname "c" major minor))))) + (((? (cut string-prefix? "block-major-" <>) alias) . value) + (let ((parts (string-tokenize %not-dash))) + (match parts + ((a b major minor) + (format port "~a ~a ~a:~a\n" devname "b" major minor))))) + (_ #f)) + aliases)))))) + ;;; linux-modules.scm ends here