rpm-build/scripts/shell.req.in
Alexey Tourbin e69e87503e scripts/shell.req.in: fixed sed filter
See my previous commit.  It goes like this:

$ /usr/lib/rpm/shell.req -v /usr/bin/buildreq
shell.req: /usr/bin/buildreq: cat -> /bin/cat -> coreutils (via rpmdb)
shell.req: /usr/bin/buildreq: cmp -> /usr/bin/cmp -> diffutils (via rpmdb)
shell.req: /usr/bin/buildreq: function(Info) not found (skip)
shell.req: /usr/bin/buildreq: function(show_help) not found (skip)
shell.req: /usr/bin/buildreq: function(show_usage) not found (skip)
shell.req: /usr/bin/buildreq: rm -> /bin/rm -> coreutils (via rpmdb)
shell.req: /usr/bin/buildreq: sed -> /bin/sed -> sed (via rpmdb)
coreutils
diffutils
sed
$

I argue that this behaviour, i.e. function(Info) processing, is erroneous.
There are two reasons: 1) it is impossible to resolve function(Info) neither
via FindPackage nor via .provides.sh (the latter has just plain function names);
2) the fact that Info has been detected as function means that Info() function
is defined in the very same file, i.e. /usr/bin/buildreq.  This means that
function(Info) is self-provided dependency and thus should not be processed
at all.
2007-03-11 15:00:27 +03:00

83 lines
2.3 KiB
Bash
Executable File

#!/bin/sh -efu
#
# Copyright (C) 2000,2003 Dmitry V. Levin <ldv@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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
. @RPMCONFIGDIR@/functions
[ $# -eq 1 ] && [ -n "$1" -a -z "${1##/*}" ] ||
{ ArgvFileAction "$0" "$@"; exit; }
file="$1"
fname="${file##${RPM_BUILD_ROOT-}}"
dname="${fname%/*}"
#extra=
t="$(file -b "$file")" || exit 1
case "$(file -b "$file")" in
*"Bourne-Again shell script text"*)
FIND_REQ='/bin/bash --rpm-requires' ;;
*" bash script text"*)
FIND_REQ='/bin/bash --rpm-requires' ;;
*)
FIND_REQ='/bin/sh --rpm-requires' ;;
esac
# Make sure that this shell supports the rpm-requires feature.
$FIND_REQ </dev/null >/dev/null
if ! reqs="$($FIND_REQ "$file" 2>/dev/null)"; then
if egrep -vs '^(#|$)' "$file" 2>/dev/null |head -1 |grep -qs '^[ ]*exec '; then
reqs="$(printf %s\\n "$reqs" |head -1)"
#extra="$(printf %s\\n "$reqs" |sed -e 's/^\(executable\)(\(.*\))$/\2/g')"
else
reqs="$($FIND_REQ "$file")"
fi
fi
reqs="$(printf %s\\n "$reqs" |sed -n 's/^\(sh\|bash\|executable\)(\(.*\))$/\2/p' |LC_COLLATE=C sort -u)"
[ -n "$reqs" ] || exit 0
. @RPMCONFIGDIR@/find-package
FindReqs()
{
for r in "$@"; do
if [ -z "${r/*\$*}" ]; then
continue
fi
case "$(type -t -- "$r")" in
alias|keyword|function|builtin)
continue ;;
esac
if grep -qs -Fx "$r" "${RPM_BUILD_ROOT-}$dname/.provides.sh"; then
printf %s\\n "$dname($r)"
elif grep -qs -Fx "$r" "$dname/.provides.sh"; then
printf %s\\n "$dname($r)"
else
FindPackage "$file" "$r"
fi
done
}
# Find requires
found="$(FindReqs $reqs)"
# And print them.
printf %s "$found" |LC_COLLATE=C sort -u
# TODO: more analysis based on $extra