unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 26166@debbugs.gnu.org
Subject: bug#26166: [PATCH] gnu: cargo: Simplify unpacking.
Date: Fri, 07 Apr 2017 22:58:32 +0200	[thread overview]
Message-ID: <87pogosznr.fsf@gnu.org> (raw)
In-Reply-To: <20170319002844.19407-1-dannym@scratchpost.org> (Danny Milosavljevic's message of "Sun, 19 Mar 2017 01:28:44 +0100")

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> 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	other threads:[~2017-04-07 20:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170319002844.19407-1-dannym@scratchpost.org>
2017-04-07 20:58 ` Ludovic Courtès [this message]
2017-04-13 22:04   ` bug#26166: [PATCH v2] gnu: cargo: Simplify unpacking Danny Milosavljevic
2017-04-13 22:20   ` bug#26166: [PATCH] " Danny Milosavljevic
2017-04-19  9:54     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pogosznr.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=26166@debbugs.gnu.org \
    --cc=dannym@scratchpost.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).