From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 16 Sep 2008 12:03:17 +0400 From: Alexey Tourbin To: devel@lists.altlinux.org Message-ID: <20080916080317.GG5223@altlinux.org> Mail-Followup-To: devel@lists.altlinux.org References: <20080915205705.GA27760@granary.armor.altlinux.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+1TulI7fc0PCHNy3" Content-Disposition: inline In-Reply-To: <20080915205705.GA27760@granary.armor.altlinux.org> Subject: [devel] shebang.req (Sisyphus-20080916 i586 beehive_status) X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.10b3 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Sep 2008 08:03:18 -0000 Archived-At: List-Archive: List-Post: --+1TulI7fc0PCHNy3 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 16, 2008 at 12:57:05AM +0400, QA Team Robot wrote: > gettext-lint-0.4-alt2 > shebang.req.files: executable script > /usr/src/tmp/gettext-lint-buildroot/usr/share/gettext-lint/Glossary.py i= s not executable > shebang.req: ERROR: /usr/src/tmp/gettext-lint-buildroot/usr/bin/POFileCl= ean: trailing > in interpreter: #!/usr/bin/python > find-requires: ERROR: /usr/lib/rpm/shebang.req failed > RPM build errors: > error: /bin/sh failed > error: Failed to find Requires > File listed twice: /usr/share/gettext-lint =F1 =D2=C5=C1=CC=C9=DA=CF=D7=C1=CC =D0=D2=CF=D7=C5=D2=CB=D5 =CE=C1 =DA=C1= =D0=D5=D3=CB=C1=C5=CD=CF=D3=D4=D8 =D3=CB=D2=C9=D0=D4=CF=D7: =C9=CD=D1 =C9= =CE=D4=C5=D2=D0=D2=C5=D4=C1=D4=CF=D2=C1 =CE=C5 =C4=CF=CC=D6=CE=CF =CF=CB=C1=CE=D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=E4=CC=D1 =D0=C9=D4=CF=CE=CF=D7=D3=CB=C9=C8 =CD=CF=C4=D5=CC=C5=CA =C4=CF=D3= =D4=C1=D4=CF=DE=CE=CF =D3=C4=C5=CC=C1=D4=D8 'chmod -x .../*.py', =D0=CF=D4=CF=CD=D5 =DE=D4=CF =D0=C9=D4=CF=CE =CE=CF=D2=CD=C1=CC=D8=CE=CF = =D7=CF=D3=D0=D2=C9=CE=C9=CD=C1=C5=D4 =CD=CF=C4=D5=CC=C9 =D3 CRLF. =F3 =C4=D2=D5=C7=CF=CA =D3=D4=CF=D2=CF=CE=D9, /bin/sh =CE=C5 =CD=CF=D6=C5= =D4 =D7=D9=D0=CF=CC=CE=D1=D4=D8 =D3=CB=D2=C9=D0=D4=D9 =D3 CRLF =D7=CF=CF=C2= =DD=C5 (=C4=C1=D6=C5 =C5=D3=CC=C9 =CF=CE=C9 =DA=C1=C7=D2=D5=D6=C1=C0=D4=D3=D1 =DE=C5=D2=C5=DA ".= "). =F4=C1=CB=C9=C5 =D3=CB=D2=C9=D0=D4=D9 =CE=C1=C4=CF =CB=CF=CE=D7=C5=D2= =D4=C9=D2=CF=D7=C1=D4=D8: perl -pi -e 's/\r\n/\n/' *.sh commit d0c2f92f051142e398f7f75a753b5a888fa520c9 Author: Alexey Tourbin Date: Sat Sep 13 11:08:31 2008 +0400 shebang.req: validate argc and =20 1) In Linux, execve(2) does not split shebang arguments, which implies that effectively only one argument can be passed to the interpreter. However, some interpreters, esp. perl, can do a magic here, which is to split its arguments. =20 2) Neither /usr/bin/env can split arguments, and no magic is possible at all. =20 3) Interpreter path (or name) must not end with , otherwise execve (resp. /usr/bin/env) is deemed to fail. However, some interpreters, esp. perl, can strip trailing in its command line options. diff --git a/scripts/shebang.req.in b/scripts/shebang.req.in index 4b59a66..ce14f29 100755 --- a/scripts/shebang.req.in +++ b/scripts/shebang.req.in @@ -1,4 +1,14 @@ #!/bin/sh -efu +# +# Make dependencies for for the first line in scripts. +# http://en.wikipedia.org/wiki/Shebang_(Unix) +# +# Copyright (C) 2007, 2008 Alexey Tourbin +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. =20 . @RPMCONFIGDIR@/functions . @RPMCONFIGDIR@/find-package @@ -9,11 +19,50 @@ ShebangReq() line=3D$(sed -n '1s|^#![[:space:]]*/|/|p;q' "$f") [ -n "$line" ] || return 0 set -- $line + + CR=3D$'\r' + line=3D"#!$(echo "$line" |sed -e "s/$CR//g")" + + CheckInterp() + { + case "$1" in + *"$CR") ;; + *) return 0 ;; + esac + Fatal "$f: trailing in interpreter: $line" + } + + CheckArgs() + { + case "$*" in + *"$CR") ;; + *) return 0 ;; + esac + Warning "$f: trailing in arguments: $line" + } + case "$#,$1" in + 1,*) + CheckInterp "$1" + FindPackage "$f" "$1" + ;; 2,/usr/bin/env) - FindPackage "$f" "$1" "$2" ;; + CheckInterp "$2" + FindPackage "$f" "$1" "$2" + ;; + 2,*) + CheckArgs "$2" + FindPackage "$f" "$1" + ;; + *,/usr/bin/env) + CheckArgs "$*" + Fatal "$f: too many arguments: $line" + ;; *) - FindPackage "$f" "$1" ;; + CheckArgs "$*" + Warning "$f: too many arguments: $line" + FindPackage "$f" "$1" + ;; esac } =20 > gle-4.1.2-alt1.beta > /bin/install -p -m 644 build/inittex.ini /usr/src/tmp/gle-buildroot/usr/= share/gle/4.1.2 > /bin/install: cannot stat `build/inittex.ini': No such file or directory > make: [pre_install] Error 1 (ignored) > -- > find-requires: running scripts > (files,lib,pam,perl,pkgconfig,pkgconfiglib,python,shebang,shell,static,s= ymlinks) > shebang.req: ERROR: /usr/src/tmp/gle-buildroot/usr/bin/bbox_gle: trailin= g in > interpreter: #!/bin/sh > find-requires: ERROR: /usr/lib/rpm/shebang.req failed > RPM build errors: > error: /bin/sh failed > error: Failed to find Requires > /bin/sh failed > povray-3.6-alt2 > find-requires: running scripts > (files,lib,pam,perl,pkgconfig,pkgconfiglib,python,shebang,shell,static,s= ymlinks) > shebang.req: ERROR: /usr/src/tmp/povray-buildroot/usr/share/povray-3.6/s= cripts/rerunpov.sh: > trailing in interpreter: #!/bin/sh > find-requires: ERROR: /usr/lib/rpm/shebang.req failed > RPM build errors: > error: /bin/sh failed > error: Failed to find Requires > /bin/sh failed > python-module-OpenGL-2.0.2.01-alt2.1 > shebang.req.files: executable script > /usr/src/tmp/python-module-OpenGL-buildroot/usr/lib/python2.5/site-packa= ges/OpenGL/WGL/__init__.py > is not executable > shebang.req: ERROR: > /usr/src/tmp/python-module-OpenGL-buildroot/usr/lib/python2.5/site-packa= ges/OpenGL/Tk/__init__.py: > trailing in interpreter: #!/usr/bin/env python > find-requires: ERROR: /usr/lib/rpm/shebang.req failed > RPM build errors: > error: /bin/sh failed > error: Failed to find Requires > /bin/sh failed > python-module-silvercity-0.9.7-alt1.1 > /usr/lib/rpm/python.req.py: > /usr/src/tmp/python-module-silvercity-buildroot/usr/lib/python2.5/site-p= ackages/SilverCity/__init__.py: > line=3D10 IGNORE module=3Dos > shebang.req: ERROR: > /usr/src/tmp/python-module-silvercity-buildroot/usr/bin/cgi-styler-form.= py: trailing > in interpreter: #!/usr/bin/env python > find-requires: ERROR: /usr/lib/rpm/shebang.req failed > RPM build errors: > error: /bin/sh failed > error: Failed to find Requires > /bin/sh failed > stardict-tools-2.4.8-alt1 > /usr/src/tmp/stardict-tools-buildroot/usr/bin/ncce2stardict.pl syntax OK > shebang.req: ERROR: /usr/src/tmp/stardict-tools-buildroot/usr/bin/hanzim= 2dict.py: > trailing in interpreter: #!/usr/bin/env python > find-requires: ERROR: /usr/lib/rpm/shebang.req failed > RPM build errors: > error: /bin/sh failed > error: Failed to find Requires > /bin/sh failed --+1TulI7fc0PCHNy3 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkjPaEUACgkQfBKgtDjnu0aRegCcDwuMoy+PitssXUUS9PhS3KqN gGoAn3KaW5ynI+/E2pgrWR6x93CjZisK =6Gl1 -----END PGP SIGNATURE----- --+1TulI7fc0PCHNy3--