From: ludo@gnu.org (Ludovic Courtès)
To: Eric Bavier <ericbavier@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] utils: Allow wrap-program to be called multiple times.
Date: Thu, 11 Sep 2014 15:10:26 +0200 [thread overview]
Message-ID: <8738byti9p.fsf@gnu.org> (raw)
In-Reply-To: <871trk2yis.fsf@member.fsf.org> (Eric Bavier's message of "Tue, 09 Sep 2014 17:56:59 -0500")
Eric Bavier <ericbavier@gmail.com> skribis:
> Currently, if (@ (guix build utils) wrap-program) is called multiple
> times for the same file, the original file ends up being overwritten.
OK, you’ve convinced me that this improvement is welcome.
Some comments on the patch:
> From 231130db4444685d8f3264e61d680634eaead9fb Mon Sep 17 00:00:00 2001
> From: Eric Bavier <bavier@member.fsf.org>
> Date: Tue, 9 Sep 2014 17:47:31 -0500
> Subject: [PATCH] utils: Allow wrap-program to be called multiple times.
>
> * guix/build/utils.scm (wrap-program): Multiple invocations of
> wrap-program for the same file create successive wrappers.
> ---
> guix/build/utils.scm | 26 +++++++++++++++++++++-----
> 1 file changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/guix/build/utils.scm b/guix/build/utils.scm
> index 2f3dc9c..d4435b4 100644
> --- a/guix/build/utils.scm
> +++ b/guix/build/utils.scm
> @@ -711,8 +711,24 @@ contents:
> This is useful for scripts that expect particular programs to be in $PATH, for
> programs that expect particular shared libraries to be in $LD_LIBRARY_PATH, or
> modules in $GUILE_LOAD_PATH, etc."
> - (let ((prog-real (string-append (dirname prog) "/." (basename prog) "-real"))
> - (prog-tmp (string-append (dirname prog) "/." (basename prog) "-tmp")))
> + (define (wrapper-path num)
> + (format #f "~a/.~a-wrap-~2'0d" (dirname prog) (basename prog) num))
Make it ‘wrapper-file-name’ (in GNU, “path” means “search path”.)
> + (let* ((current-wrappers
> + (find-files (dirname prog)
> + (string-append "\\." (basename prog) "-wrap-.*")))
> + (wrapper-num (if (null? current-wrappers)
> + 0
> + (string->number
> + (string-take-right (last current-wrappers) 2))))
These two could be factorized as a local ‘next-wrapper-number’
procedure.
For local variables, it’s better to use shorter names, such as
‘wrappers’ and ‘number’ here.
> + (wrapper-tgt (if (zero? wrapper-num)
> + (let ((prog-real (string-append
> + (dirname prog) "/."
> + (basename prog) "-real")))
> + (copy-file prog prog-real)
> + prog-real)
> + (wrapper-path wrapper-num)))
Make it a ‘wrapper-target’ local procedure, and change ‘wrapper-tgt’ to
‘target’.
It looks OK. It would be ideal if a test in tests/build-utils.scm made
sure that ‘wrap-program’ uses the right file names when called multiple
times, but I won’t object if the patch doesn’t have it.
Thanks,
Ludo’.
next prev parent reply other threads:[~2014-09-11 13:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 22:56 [PATCH] utils: Allow wrap-program to be called multiple times Eric Bavier
2014-09-10 13:40 ` Ludovic Courtès
2014-09-10 19:16 ` Eric Bavier
2014-09-11 13:10 ` Ludovic Courtès [this message]
2014-09-13 6:12 ` Eric Bavier
2014-09-13 12:20 ` Ludovic Courtès
2014-09-14 4:05 ` mhw
2014-09-14 14:27 ` Ludovic Courtès
2014-09-14 15:16 ` Eric Bavier
2014-09-14 15:58 ` Mark H Weaver
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8738byti9p.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=ericbavier@gmail.com \
--cc=guix-devel@gnu.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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.