[opensuse-packaging] use of sed to fix python2 script interpreter
Hi everyone, I am packaging pyrenamer [0] in order to submit it to Factory. As it is, I got this warning [1] because of the 'shebang' calling '/usr/bin/env python' instead of '/usr/bin/python' (which should be 'python2'). I have fixed it by adding the following: sed -i 's|/usr/bin/env\ python|/usr/bin/python2|1' %{buildroot}/%{_bindir}/%{name} in %install section. Is it a good way to do it or is there a more recommended way ? Thank you [0] https://build.opensuse.org/package/show/utilities/pyrenamer [1] full warning is: pyrenamer.noarch: E: env-script-interpreter (Badness: 9) /usr/bin/pyrenamer /usr/bin/env python This script uses 'env' as an interpreter. For the rpm runtime dependency detection to work, the shebang #!/usr/bin/env python needs to be patched into #!/usr/bin/python otherwise the package dependency generator merely adds a dependency on /usr/bin/env rather than the actual interpreter /usr/bin/python. Alternatively, if the file should not be executed, then ensure that it is not marked as executable or don't install it in a path that is reserved for executables. -- Sébastien 'sogal' Poher -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On jeudi, 22 mars 2018 10.39:39 h CET Sébastien 'sogal' Poher wrote:
Hi everyone,
I am packaging pyrenamer [0] in order to submit it to Factory. As it is, I got this warning [1] because of the 'shebang' calling '/usr/bin/env python' instead of '/usr/bin/python' (which should be 'python2'). I have fixed it by adding the following:
sed -i 's|/usr/bin/env\ python|/usr/bin/python2|1' %{buildroot}/%{_bindir}/%{name}
in %install section.
Is it a good way to do it or is there a more recommended way ?
Thank you
[0] https://build.opensuse.org/package/show/utilities/pyrenamer
[1] full warning is: pyrenamer.noarch: E: env-script-interpreter (Badness: 9) /usr/bin/pyrenamer /usr/bin/env python This script uses 'env' as an interpreter. For the rpm runtime dependency detection to work, the shebang #!/usr/bin/env python needs to be patched into #!/usr/bin/python otherwise the package dependency generator merely adds a dependency on /usr/bin/env rather than the actual interpreter /usr/bin/python. Alternatively, if the file should not be executed, then ensure that it is not marked as executable or don't install it in a path that is reserved for executables.
I wonder why you have it in utilities when it's available in pypi I would say it should goes to devel:languages:python repository even if it's an application. Using pypi you will find the 1.1 version certainly better than the older 0.6.0 https://pypi.python.org/pypi/pyrenamer Bonus there's no env line to fix in it. And you will be able to build it for python2 and python3 -- Bruno Friedmann Ioda-Net Sàrl www.ioda-net.ch Bareos Partner, openSUSE Member, fsfe fellowship GPG KEY : D5C9B751C4653227 irc: tigerfoot -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Hi Bruno, Le jeudi 22 mars 2018 à 02:36:13, Bruno Friedmann a écrit :
On jeudi, 22 mars 2018 10.39:39 h CET Sébastien 'sogal' Poher wrote:
Hi everyone,
I am packaging pyrenamer [0] in order to submit it to Factory. As it is, I got this warning [1] because of the 'shebang' calling '/usr/bin/env python' instead of '/usr/bin/python' (which should be 'python2'). I have fixed it by adding the following:
sed -i 's|/usr/bin/env\ python|/usr/bin/python2|1' %{buildroot}/%{_bindir}/%{name}
in %install section.
Is it a good way to do it or is there a more recommended way ?
Thank you
[0] https://build.opensuse.org/package/show/utilities/pyrenamer
[1] full warning is: pyrenamer.noarch: E: env-script-interpreter (Badness: 9) /usr/bin/pyrenamer /usr/bin/env python This script uses 'env' as an interpreter. For the rpm runtime dependency detection to work, the shebang #!/usr/bin/env python needs to be patched into #!/usr/bin/python otherwise the package dependency generator merely adds a dependency on /usr/bin/env rather than the actual interpreter /usr/bin/python. Alternatively, if the file should not be executed, then ensure that it is not marked as executable or don't install it in a path that is reserved for executables.
I wonder why you have it in utilities when it's available in pypi I would say it should goes to devel:languages:python repository even if it's an application.
Using pypi you will find the 1.1 version certainly better than the older 0.6.0 https://pypi.python.org/pypi/pyrenamer
Bonus there's no env line to fix in it. And you will be able to build it for python2 and python3
Actually we are no speaking of the same thing. I am not trying to package py-renamer (the py module you are thinking of) but Pyrenamer [0] the Python2 + gtk2 graphical mass renaming app :) That is also the reason why it fits in utilities. [0] https://launchpad.net/pyrenamer -- Sébastien 'sogal' Poher -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 03/22/2018 10:39 AM, Sébastien 'sogal' Poher wrote:
sed -i 's|/usr/bin/env\ python|/usr/bin/python2|1' %{buildroot}/%{_bindir}/%{name} __________________________________________________^
I've never seen '1' after the 's' command; what should that do? You probably want to do that only in line 1 - so putting the address /before/ the 's' command: sed -i '1 s|/usr/bin/env\ python|/usr/bin/python2|' %{buildroot}/%{_bindir}/%{name} Have a nice day, Berny -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 2018-03-23 00:28:32 +0100, Bernhard Voelker wrote:
On 03/22/2018 10:39 AM, Sébastien 'sogal' Poher wrote:
sed -i 's|/usr/bin/env\ python|/usr/bin/python2|1' %{buildroot}/%{_bindir}/%{name} __________________________________________________^
I've never seen '1' after the 's' command; what should that do?
It replaces the first match. For instance, marcus@linux:~> echo -e "foobarbar\nfoobar" | sed -e 's/bar/xxx/2' foobarxxx foobar marcus@linux:~> Marcus -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 03/23/2018 01:07 AM, Marcus Hüwe wrote:
On 2018-03-23 00:28:32 +0100, Bernhard Voelker wrote:
On 03/22/2018 10:39 AM, Sébastien 'sogal' Poher wrote:
sed -i 's|/usr/bin/env\ python|/usr/bin/python2|1' %{buildroot}/%{_bindir}/%{name} __________________________________________________^
I've never seen '1' after the 's' command; what should that do?
It replaces the first match. For instance,
marcus@linux:~> echo -e "foobarbar\nfoobar" | sed -e 's/bar/xxx/2' foobarxxx foobar
Ah, nice - found it in the manual now, thanks! https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.ht... Still, I don't think this is needed for shebang replacement. Instead, limiting the address range of the 's' action to line number 1 seems more useful to me. Have a nice day, Berny -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Le vendredi 23 mars 2018 à 08:09:48, Bernhard Voelker a écrit :
On 03/23/2018 01:07 AM, Marcus Hüwe wrote:
On 2018-03-23 00:28:32 +0100, Bernhard Voelker wrote:
On 03/22/2018 10:39 AM, Sébastien 'sogal' Poher wrote:
sed -i 's|/usr/bin/env\ python|/usr/bin/python2|1' %{buildroot}/%{_bindir}/%{name} __________________________________________________^
I've never seen '1' after the 's' command; what should that do?
It replaces the first match. For instance,
marcus@linux:~> echo -e "foobarbar\nfoobar" | sed -e 's/bar/xxx/2' foobarxxx foobar
Ah, nice - found it in the manual now, thanks!
https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.ht...
Still, I don't think this is needed for shebang replacement. Instead, limiting the address range of the 's' action to line number 1 seems more useful to me.
Indeed, both are valid but your approach might be safer. Thanks. But my question was less about the 'sed' syntax and more about 'does it seem correct to you to use sed in the %install section of a specfile' ? :) -- Sébastien 'sogal' Poher -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (5)
-
Bernhard Voelker
-
Bruno Friedmann
-
Marcus Hüwe
-
Sébastien 'sogal' Poher
-
Sébastien Poher