From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esFKz-0000ES-5f for guix-patches@gnu.org; Sat, 03 Mar 2018 17:09:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1esFKv-0006Bn-VH for guix-patches@gnu.org; Sat, 03 Mar 2018 17:09:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:35347) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1esFKv-0006Bb-Ry for guix-patches@gnu.org; Sat, 03 Mar 2018 17:09:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1esFKv-0006vE-Nb for guix-patches@gnu.org; Sat, 03 Mar 2018 17:09:01 -0500 Subject: [bug#30604] [PATCH v8 2/7] linux-modules: Add install-modules. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20180302153408.14091-1-dannym@scratchpost.org> <20180303135533.6112-1-dannym@scratchpost.org> <20180303135533.6112-3-dannym@scratchpost.org> Date: Sat, 03 Mar 2018 23:07:57 +0100 In-Reply-To: <20180303135533.6112-3-dannym@scratchpost.org> (Danny Milosavljevic's message of "Sat, 3 Mar 2018 14:55:28 +0100") Message-ID: <87y3j84xtu.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Danny Milosavljevic Cc: 30604@debbugs.gnu.org Danny Milosavljevic skribis: > * gnu/build/linux-modules.scm (install-modules): New procedure. > (%not-dash): New variable. We could reuse modules.alias and modules.devname from the =E2=80=98linux-li= bre=E2=80=99 package (right?), but I guess it doesn=E2=80=99t hurt to generate custom on= es. > +(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-majo= r|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 mi= nor))))) > + (((? (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 mi= nor))))) > + (_ #f)) > + aliases)))))) I think we need different procedures here: (write-module-alias-database modules port) ;for =E2=80=9Cmodules.alias= =E2=80=9D (write-module-device-database modules port) ;for =E2=80=9Cmodules.devname= =E2=80=9D with docstrings. I=E2=80=99m not sure we need =E2=80=98install-module-files=E2=80=99 itself.= Perhaps we can inline it at the call site? For the devname code, please avoid =E2=80=98set!=E2=80=99. Instead you can= thread the current devname as the state of a loop: (let loop ((devname #f) (aliases aliases)) (match aliases (() =E2=80=A6) (((? devname-alias? devname) . rest) (loop devname rest)) =E2=80=A6)) =20=20=20=20=20=20=20 The indentation of =E2=80=98match=E2=80=99 forms is wrong. Would it be OK = for you to pass it through ./etc/indent-code.el? (It=E2=80=99s non interactive, you d= on=E2=80=99t need to actually use Emacs.) Thanks, Ludo=E2=80=99.