From: Alexey Tourbin <at@altlinux.ru> To: devel@lists.altlinux.org Subject: [devel] shebang.req (Sisyphus-20080916 i586 beehive_status) Date: Tue, 16 Sep 2008 12:03:17 +0400 Message-ID: <20080916080317.GG5223@altlinux.org> (raw) In-Reply-To: <20080915205705.GA27760@granary.armor.altlinux.org> [-- Attachment #1: Type: text/plain, Size: 6392 bytes --] 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 is not executable > shebang.req: ERROR: /usr/src/tmp/gettext-lint-buildroot/usr/bin/POFileClean: trailing > <CR> in interpreter: #!/usr/bin/python<CR> > 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 Я реализовал проверку на запускаемость скриптов: имя интерпретатора не должно оканчиваться на <CR> (то есть '\r'), а при запуске через /usr/bin/env интерпретатору нельзя передавать аргументы. Проверка выполняется только для исполняемых скриптов. Попалось 3 или 4 пакета с настоящими ошибками (в /usr/bin лежат скрипты, которые невозможно запустить естественным способом), пакет povray с какими-то своими приватными скриптами, а также два питоновских пакета, в которых *.py модули запакованы исполняемыми. Для питоновских модулей достаточно сделать 'chmod -x .../*.py', потому что питон нормально воспринимает модули с CRLF. С другой стороны, /bin/sh не может выполнять скрипты с CRLF вообще (даже если они загружаются через "."). Такие скрипты надо конвертировать: perl -pi -e 's/\r\n/\n/' *.sh commit d0c2f92f051142e398f7f75a753b5a888fa520c9 Author: Alexey Tourbin <at@altlinux> Date: Sat Sep 13 11:08:31 2008 +0400 shebang.req: validate argc and <CR> 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. 2) Neither /usr/bin/env can split arguments, and no magic is possible at all. 3) Interpreter path (or name) must not end with <CR>, otherwise execve (resp. /usr/bin/env) is deemed to fail. However, some interpreters, esp. perl, can strip trailing <CR> 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 <at@altlinux.org> +# +# 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. . @RPMCONFIGDIR@/functions . @RPMCONFIGDIR@/find-package @@ -9,11 +19,50 @@ ShebangReq() line=$(sed -n '1s|^#![[:space:]]*/|/|p;q' "$f") [ -n "$line" ] || return 0 set -- $line + + CR=$'\r' + line="#!$(echo "$line" |sed -e "s/$CR/<CR>/g")" + + CheckInterp() + { + case "$1" in + *"$CR") ;; + *) return 0 ;; + esac + Fatal "$f: trailing <CR> in interpreter: $line" + } + + CheckArgs() + { + case "$*" in + *"$CR") ;; + *) return 0 ;; + esac + Warning "$f: trailing <CR> 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 } > 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,symlinks) > shebang.req: ERROR: /usr/src/tmp/gle-buildroot/usr/bin/bbox_gle: trailing <CR> in > interpreter: #!/bin/sh<CR> > 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,symlinks) > shebang.req: ERROR: /usr/src/tmp/povray-buildroot/usr/share/povray-3.6/scripts/rerunpov.sh: > trailing <CR> in interpreter: #!/bin/sh<CR> > 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-packages/OpenGL/WGL/__init__.py > is not executable > shebang.req: ERROR: > /usr/src/tmp/python-module-OpenGL-buildroot/usr/lib/python2.5/site-packages/OpenGL/Tk/__init__.py: > trailing <CR> in interpreter: #!/usr/bin/env python<CR> > 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-packages/SilverCity/__init__.py: > line=10 IGNORE module=os > shebang.req: ERROR: > /usr/src/tmp/python-module-silvercity-buildroot/usr/bin/cgi-styler-form.py: trailing <CR> > in interpreter: #!/usr/bin/env python<CR> > 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/hanzim2dict.py: > trailing <CR> in interpreter: #!/usr/bin/env python<CR> > find-requires: ERROR: /usr/lib/rpm/shebang.req failed > RPM build errors: > error: /bin/sh failed > error: Failed to find Requires > /bin/sh failed [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
next parent reply other threads:[~2008-09-16 8:03 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-09-16 8:03 ` Alexey Tourbin [this message] 2008-09-16 9:53 ` [devel] q: wiki links? (was: shebang.req) Michael Shigorin 2008-09-16 10:22 ` [devel] Пострадавшие от новых glibc-kernheaders (874) Kirill A. Shutemov 2008-09-16 12:02 ` Dmitry V. Levin 2008-09-16 12:09 ` Kirill A. Shutemov 2008-09-16 13:48 ` Dmitry Afanasov 2008-09-16 13:52 ` Kirill A. Shutemov 2008-09-16 13:59 ` Dmitry Afanasov 2008-09-16 13:16 ` Kirill A. Shutemov 2008-09-16 14:53 ` Kirill A. Shutemov 2008-09-16 14:57 ` Хихин Руслан 2008-09-16 15:00 ` Kirill A. Shutemov 2008-09-16 15:24 ` Хихин Руслан 2008-09-16 16:09 ` Mikhail Gusarov 2008-09-24 18:34 ` Michael Shigorin 2008-10-23 17:23 ` [devel] glibc-kernheaders Dmitry V. Levin 2008-10-23 17:57 ` Kirill A. Shutemov 2008-09-16 20:42 ` [devel] Пострадавшие от новых glibc-kernheaders (874) Motsyo Gennadi aka Drool 2008-09-16 20:46 ` Andrey Rahmatullin 2008-09-16 21:16 ` Motsyo Gennadi aka Drool
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=20080916080317.GG5223@altlinux.org \ --to=at@altlinux.ru \ --cc=devel@lists.altlinux.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
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git