From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Baines Subject: Re: avoid wrapper scripts when possible Date: Fri, 3 Nov 2017 18:54:16 +0000 Message-ID: <20171103185416.0ffc4065@cbaines.net> References: <87mv44gyfv.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/sS/p6ytzJ1bbLgdDkioXDEv"; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAh6o-00036K-Pf for guix-devel@gnu.org; Fri, 03 Nov 2017 14:54:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eAh6k-0003yt-B6 for guix-devel@gnu.org; Fri, 03 Nov 2017 14:54:26 -0400 Received: from mira.cbaines.net ([2a01:7e00::f03c:91ff:fe69:8da9]:55057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAh6k-0003yN-1f for guix-devel@gnu.org; Fri, 03 Nov 2017 14:54:22 -0400 In-Reply-To: <87mv44gyfv.fsf@elephly.net> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ricardo Wurmus Cc: guix-devel@gnu.org --Sig_/sS/p6ytzJ1bbLgdDkioXDEv Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 02 Nov 2017 22:31:16 +0100 Ricardo Wurmus wrote: > Hi Guix, >=20 > the environment activation feature of our =E2=80=9Cconda=E2=80=9D package= currently > fails. This is because the =E2=80=9Cdeactivate=E2=80=9D shell script is = wrapped in > another shell script. This leads to the actual shell script to be > called =E2=80=9C.deactivate-real=E2=80=9D. The script compares the value= of =E2=80=9C$0=E2=80=9D with > the expected name =E2=80=9Cdeactivate=E2=80=9D. This fails so conda misb= ehaves. >=20 > Since =E2=80=9Cdeactivate=E2=80=9D is really just a shell script I think = we could avoid > the renaming and the external wrapper by setting the environment > variables in the =E2=80=9Cdeactivate=E2=80=9D script itself. >=20 > 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. >=20 > For binaries (like emacs) we=E2=80=99d still create shell wrappers where = needed, > because it=E2=80=99s harder to do this natively. >=20 > 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=3D28773 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=3D27003 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.=20 3: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D26752 4: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D25235 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. --Sig_/sS/p6ytzJ1bbLgdDkioXDEv Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAln8u1hfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XeaGxAApGA64uyZ2QatAWuctRAXn7UshSX9pHIoWywAzcDeEXg6b5/LdGwKK9TV fW4FcQ9r97vh+zSLzyAv0RhuVBjATj21Wn7FA+Xpps1aIQ8lz7lDkjYc9I0Aqok4 U4UYWreUhpztiYLUDumVud7j3mSaJ9bmM1sKqmZRGhDZCxX+ICqIt63k7KViV0Ph 04kI5/o8RObL/BpZyvTredzy1CR+sKBrKJydVVwq6NQKdQhPydJ/rYxSgOA0+L6N LtOQfUNb65mr5K1TQPpIBciAJ8tHzodGZrt/FjAkmhFS4OFi38/equ9qK3v2hEj6 z3b5jV/dcMaoDNAU8i3q+fPzpiBPszihpfIOrxeiYOyUxwpjQnrBj/NnVxyeXrFy JhWkqaw7vxWOPVaphULYD7vvkFJmc/aMQobW6qurVyC7Qeh2+sE95Dtorlex38s1 xV4t5Q9A6iIOGF38/qrN+bl0xJ2TJT6jKmFh6qYbvhvhv7XM3Est26v9PbJtPPrx TScnH+DE1nfybDzcCl5itM7/ur504utL/EKM8r1TaihyojqxxA2JpY6ZC1PvGx5G 7etY+BzBSnXtOJ4sXx1RP2yfy1Ig2C/EXXh7LNaIALwdNZ0zRfjr/wO8wst+jjx7 aZSr9rgTFCQCXjr/tI8JhK9iu1xX8i+jM2M2+6sv61KIiDeEdb0= =k5K0 -----END PGP SIGNATURE----- --Sig_/sS/p6ytzJ1bbLgdDkioXDEv--