Rewrite of Prefix shebang check for bug #313731.
authorFabian Groffen <grobian@gentoo.org>
Sat, 24 Apr 2010 13:54:07 +0000 (15:54 +0200)
committerFabian Groffen <grobian@gentoo.org>
Sat, 24 Apr 2010 13:54:07 +0000 (15:54 +0200)
commita114f4c4a0b4c95a2ee720ee46748b8acf50a46f
tree0677976869cec924746933e00bcc25e97618beef
parent24d31a3468ea7b16a6222a9b0e2cb80bb8077728
Rewrite of Prefix shebang check for bug #313731.

The shebang check was basically working too well, or just being overly
aggressive.  This caused files from e.g. gnuconfig, automake, autoconf,
libtool to install template files with prefixed bin/sh in them.  This
causes no problems for a user, but makes autotools useless for
distribution.

Hence the approach has now been changed to be less aggressive:
1) For each script that has a shebang starting with $EPREFIX, check if
   the target exists, or will exist after installation of the package.
   If this fails, die with an appropriate error message: the shebang was
   generated someway, and hence explicitly set that way to a
   non-existing target, which is wrong.
2) For scripts having a non-prefixed shebang, check if they reside in
   $PATH.  If they do, check if the shebang can be prefixed, and if so,
   prefix the shebang.  If the shebang doesn't exist in the offset, die
   with an appropriate error message: the script would otherwise rely on
   a host-provided tool which indicates a missing dependency (and will
   cause random problems because of a non-Prefix-aware host-tool being
   used).
3) Scripts that do not match 1) and 2), e.g. they don't have a shebang
   starting with $EPREFIX and do not reside in $PATH, we ignore invalid
   shebangs, unless FEATURES=stricter is set, in which case we warn.
   This allows packages like autoconf, automake, etc. to install without
   warning of their template files with /bin/sh as shebang.
bin/misc-functions.sh