GNU bug report logs - #28251
[PATCH 0/3] Add generic JSON importer

Previous Next

Package: guix-patches;

Reported by: Ricardo Wurmus <rekado <at> elephly.net>

Date: Sun, 27 Aug 2017 15:59:01 UTC

Severity: normal

Tags: patch

Done: Ricardo Wurmus <rekado <at> elephly.net>

Bug is archived. No further changes may be made.

Full log


Message #26 received at 28251 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Ricardo Wurmus <rekado <at> elephly.net>
Cc: 28251 <at> debbugs.gnu.org
Subject: Re: [bug#28251] [PATCH 2/3] import: Add generic data to package
 converter.
Date: Mon, 04 Sep 2017 15:04:10 +0200
Hello!

Ricardo Wurmus <rekado <at> elephly.net> skribis:

> * guix/import/utils.scm (build-system-modules, guix-modules): New variables.
> (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)))

‘all-modules’ causes a directory traversal, so it should not be called
at the top level.  The solution is to turn these two things in a promise
or a thunk or probably an ‘mlambda’ thunk (depending on whether 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 ‘specification->package+output’ so that one can
use specs like “hwloc:lib”.

> +(define (convert-source source)

Maybe ‘source-spec->object’?

> +  (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’m unsure about exposing “url-fetch” and
co. in the spec that people write.

> +(define (data->guix-package meta)

Maybe ‘alist->package’?

Ludo’.




This bug report was last modified 7 years and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.