From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dor5o-0004mg-32 for guix-patches@gnu.org; Mon, 04 Sep 2017 09:08:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dor4k-0004Dl-0p for guix-patches@gnu.org; Mon, 04 Sep 2017 09:07:08 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:39296) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dor4j-0004DY-UC for guix-patches@gnu.org; Mon, 04 Sep 2017 09:06:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dor4j-0000Be-M5 for guix-patches@gnu.org; Mon, 04 Sep 2017 09:06:01 -0400 Subject: [bug#28251] [PATCH 2/3] import: Add generic data to package converter. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20170827160046.29049-1-rekado@elephly.net> <20170827160046.29049-2-rekado@elephly.net> Date: Mon, 04 Sep 2017 15:04:10 +0200 In-Reply-To: <20170827160046.29049-2-rekado@elephly.net> (Ricardo Wurmus's message of "Sun, 27 Aug 2017 18:00:45 +0200") Message-ID: <87vaky399x.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: Ricardo Wurmus Cc: 28251@debbugs.gnu.org Hello! Ricardo Wurmus skribis: > * guix/import/utils.scm (build-system-modules, guix-modules): New variabl= es. > (lookup-build-system-by-name, specs->package-lists, convert-source, > data->guix-package): New procedures. [...] > +(define build-system-modules > + (all-modules (map (lambda (entry) > + `(,entry . "guix/build-system")) > + %load-path))) > + > +(define guix-modules > + (all-modules (map (lambda (entry) > + `(,entry . "guix")) > + %load-path))) =E2=80=98all-modules=E2=80=99 causes a directory traversal, so it should no= t be called at the top level. The solution is to turn these two things in a promise or a thunk or probably an =E2=80=98mlambda=E2=80=99 thunk (depending on whe= ther they are expected to be called frequently.) > +(define (lookup-build-system-by-name name) > + (fold-module-public-variables (lambda (obj result) Docstring please. :-) > +(define (specs->package-lists specs) > + (map (lambda (spec) > + (let ((pkg (specification->package spec))) > + (list (package-name pkg) pkg))) > + specs)) This should probably use =E2=80=98specification->package+output=E2=80=99 so= that one can use specs like =E2=80=9Chwloc:lib=E2=80=9D. > +(define (convert-source source) Maybe =E2=80=98source-spec->object=E2=80=99? > + (match source > + ((? string? file) (local-file file)) > + (#f #f) > + (orig (let ((sha (match (car (assoc-ref orig "sha256")) > + (("base32" . value) > + (base32 value)) > + (_ #f)))) > + (origin > + (method (match (assoc-ref orig "method") > + ("url-fetch" (@ (guix download) url-fetch)) > + ("git-fetch" (@ (guix git-download) git-fetch)) > + ("svn-fetch" (@ (guix svn-download) svn-fetch)) > + ("hg-fetch" (@ (guix hg-download) hg-fetch)) > + (_ #f))) > + (uri (assoc-ref orig "uri")) > + (sha256 sha)))))) Though as discussed earlier, I=E2=80=99m unsure about exposing =E2=80=9Curl= -fetch=E2=80=9D and co. in the spec that people write. > +(define (data->guix-package meta) Maybe =E2=80=98alist->package=E2=80=99? Ludo=E2=80=99.