[devel] shebang.req (Sisyphus-20080916 i586 beehive_status)
Alexey Tourbin
=?iso-8859-1?q?at_=CE=C1_altlinux=2Eru?=
Вт Сен 16 12:03:17 MSD 2008
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
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя : =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Тип : application/pgp-signature
Размер : 197 байтов
Описание: =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Url : <http://lists.altlinux.org/pipermail/devel/attachments/20080916/1ae69b98/attachment-0002.bin>
Подробная информация о списке рассылки Devel