guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#28251] [PATCH 2/3] import: Add generic data to package converter.


From: Ludovic Courtès
Subject: [bug#28251] [PATCH 2/3] import: Add generic data to package converter.
Date: Mon, 04 Sep 2017 15:04:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Hello!

Ricardo Wurmus <address@hidden> 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’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]