guix-patches
[Top][All Lists]
Advanced

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

bug#26166: [PATCH] gnu: cargo: Simplify unpacking.


From: Ludovic Courtès
Subject: bug#26166: [PATCH] gnu: cargo: Simplify unpacking.
Date: Fri, 07 Apr 2017 22:58:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hi Danny,

Danny Milosavljevic <address@hidden> skribis:

> * gnu/packages/rust.scm (cargo): Simplify unpacking.

One minor issue: Please describe the changes in terms of code: add
#:modules, modify ‘unpack-submodule-sources’ phase such that this and
that, etc.

>  gnu/packages/rust.scm | 60 
> +++++++++++++++++++++++++++++++++------------------
>  1 file changed, 39 insertions(+), 21 deletions(-)

It’s not immediately obvious that it’s a simplification.  ;-)

>           (delete 'patch-usr-bin-file)
>           (add-after 'unpack 'unpack-submodule-sources
>             (lambda* (#:key inputs #:allow-other-keys)
> -             (let ((unpack (lambda (source target)
> -                             (mkdir-p target)
> -                             (with-directory-excursion target
> -                               (zero? (system* "tar" "xf"
> -                                               source
> -                                               "--strip-components=1"))))))
> +             (let* ((unpack
> +                      (lambda (source target)
> +                        (mkdir-p target)
> +                        (with-directory-excursion target
> +                          (zero? (system* "tar" "xf"
> +                                          source
> +                                          "--strip-components=1")))))
> +                    (touch
> +                      (lambda (file-name)
> +                        (call-with-output-file file-name (const #t))))
> +                    (install-rust-library
> +                      (lambda (entry)
> +                        (match entry
> +                          ((name . src)
> +                           (if (string-prefix? "rust-" name)
> +                             (let* ((rust-length (string-length "rust-"))
> +                                    (rust-name (string-drop name
> +                                                            rust-length))
> +                                    (rsrc (string-append "vendor/"
> +                                                         rust-name))
> +                                    (unpack-status (unpack src rsrc)))
> +                               (touch (string-append rsrc "/.cargo-ok"))
> +                               (generate-checksums rsrc src)
> +                               unpack-status)))

For clarity it may help to replace the ‘let’ with “internal defines”,
like this:

  (lambda* …
    (define (unpack source target)
      …)
    (define (touch file)
      …)
    (define (install-rust-library entry)
      …)

    body …)

> +               (mkdir ".cargo")
> +               ;(setenv "CARGO_HOME" (string-append (getcwd) "/cargohome"))
                  ^
Leftover?

I don’t fully understand this file, but if it sounds good to you, we
should apply it.  OK to send an updated patch?

Thank you!

Ludo’.





reply via email to

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