From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:46307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnPSB-0001EA-PT for guix-patches@gnu.org; Sat, 26 Jan 2019 10:01:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gnPSA-0002O8-UH for guix-patches@gnu.org; Sat, 26 Jan 2019 10:01:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:47405) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gnPSA-0002N7-Re for guix-patches@gnu.org; Sat, 26 Jan 2019 10:01:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gnPSA-0000PF-EG for guix-patches@gnu.org; Sat, 26 Jan 2019 10:01:02 -0500 Subject: [bug#34195] [PATCH v2] linux-modules: Add modules-soft-dependencies. Resent-Message-ID: Date: Sat, 26 Jan 2019 16:00:36 +0100 From: Danny Milosavljevic Message-ID: <20190126160036.17dda684@scratchpost.org> In-Reply-To: <87womrjyr0.fsf@gnu.org> References: <20190125113032.8372-1-dannym@scratchpost.org> <20190125114838.8680-1-dannym@scratchpost.org> <87bm44oedg.fsf@gnu.org> <20190125182537.0535b710@scratchpost.org> <87womrjyr0.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/K3Uo0z3ou=D55/YIM4q.mFG"; protocol="application/pgp-signature" 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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 34195-done@debbugs.gnu.org --Sig_/K3Uo0z3ou=D55/YIM4q.mFG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ludo, On Sat, 26 Jan 2019 15:10:27 +0100 Ludovic Court=C3=A8s wrote: > Danny Milosavljevic skribis: >=20 > > scheme> (module-soft-dependencies "/tmp/vfio.ko") =20 > > $2 =3D (("post" . "vfio_iommu_spapr_tce") ("post" . "vfio_iommu_type1")= ) =20 >=20 > That=E2=80=99s probably not the best interface. :-) >=20 > Perhaps it should return two values: the list of modules to be loaded > before (=E2=80=9Cpre=E2=80=9D), followed by the list of modules to be loa= ded after > (=E2=80=9Cpost=E2=80=9D). I had thought about it - but for our use case it makes it slower and more complicated. I still have the previous version (see below). Moreover, it did the wrong thing for multiple 'softdep sections. I guess I can use an external grouper routine (something like a hypothetical group-by-first - does it exist?) on the result of module-soft-dependencies. But at that point the caller can call it himself :-> We could hard-code "pre" and "post" as the two only possible sections (and kmod does), but that would make it break in the future even though we don't care about the sections, just the module names. Complicated version: (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)))) (define (parse-softdep text) (let loop ((value '()) (tokens (string-tokenize text not-softdep-whitespace)) (section #f)) (write tokens) (newline) (match tokens ((token _ ...) (if (string=3D? (string-take-right token 1) ":") ; section (loop (acons (string-drop-right token 1) '() value) (cdr tokens) (string-trim-both token)) (loop (add-to-first-acons token value) (cdr tokens) section))) (() value)))) (let ((info (modinfo-section-contents file))) (filter-map (match-lambda (('softdep . value) (parse-softdep value)) (_ #f)) (modinfo-section-contents file)))) --Sig_/K3Uo0z3ou=D55/YIM4q.mFG Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlxMdhQACgkQ5xo1VCww uqXqOQgAlVZm/4VW+vELWXvdxOt0CEhDFO5oyFuT9lf69wQEQgZOoJHagWauL21+ xJjC6E0dCRDYB/M1uuBAEY5Bxvwqgtoo1zspp2nb6GEWySnMCSv0oCmWmfanDNUL oSg899KGF7Uc6Ry6pJ1tAGZk6D8szzOZMSmE0LIdUAeX2wEEmj82pNb80svSyFG4 AH7e42IPi95W2cIBBx58oGj25Nsy2H6W1bhCkcF4mmYr6FnTAVrDxbY+0ioD+t+Q 5/PnE5a4MWBWlZwYLVCzL8pSZAD9BdcJrbwSkbpqS/pd9f87fve1T/HL/ahSlXJQ bb7lMdQf3+QN2u0nyCYIfa2GyrvW0Q== =sTur -----END PGP SIGNATURE----- --Sig_/K3Uo0z3ou=D55/YIM4q.mFG--