[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: avoid wrapper scripts when possible
From: |
Christopher Baines |
Subject: |
Re: avoid wrapper scripts when possible |
Date: |
Fri, 3 Nov 2017 18:54:16 +0000 |
On Thu, 02 Nov 2017 22:31:16 +0100
Ricardo Wurmus <address@hidden> wrote:
> Hi Guix,
>
> the environment activation feature of our “conda” package currently
> fails. This is because the “deactivate” shell script is wrapped in
> another shell script. This leads to the actual shell script to be
> called “.deactivate-real”. The script compares the value of “$0” with
> the expected name “deactivate”. This fails so conda misbehaves.
>
> Since “deactivate” is really just a shell script I think we could avoid
> the renaming and the external wrapper by setting the environment
> variables in the “deactivate” script itself.
>
> This made me wonder if we could avoid shell wrappers in more cases. If
> the target script is a Python script we could set the environment
> variables right after the Python shebang with Python code. If the
> target script is a shell script we can set environment variables right
> there after the shebang.
>
> For binaries (like emacs) we’d still create shell wrappers where needed,
> because it’s harder to do this natively.
>
> What do you think?
I recently tried to implement automatic wrapping for the ruby build
system [1]. I ended up implementing a ruby specific wrapping function,
that generated a ruby wrapper, rather than a bash wrapper.
I first tried using a bash wrapper, but it broke using the -S flag
with ruby to execute the script, as when -S is passed to ruby, it
expects the script on the PATH to use ruby in the shebang, and not bash.
1: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28773
After I wrote this, I also stumbled upon #27003: Generalized wrap phase
for perl, python. I haven't read through the thread enough to work out
what the state of it is.
2: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27003
I've also found some other bugs relating to wrapping, [3] is about the
issue you mention, and [4] relates to the native inputs problem, that I
came across when I was working on the ruby-build-system wrapping.
3: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26752
4: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25235
I haven't read through all of these in much detail though.
Back to your specific question about avoiding shell wrappers. For ruby,
I found this necessary to avoid breaking one way of invoking the
scripts.
However, I think that the file wrapping approach has advantages for
visibility. Maybe it could be tweaked to keep ensure the wrapper script
has the same name as the script its wrapping, e.g. when wrapping foo,
replace foo with a bash script, and move the real script
to .wrapped-bin/foo.
pgpvQXLCEu0a1.pgp
Description: OpenPGP digital signature
Re: avoid wrapper scripts when possible, Dave Love, 2017/11/06