2002-03-25 23:37:46 +03:00
#!/bin/sh -e
#
2003-04-22 18:24:35 +04:00
# $Id$
# Copyright (C) 2000,2003 Dmitry V. Levin <ldv@altlinux.org>
2002-03-25 23:37:46 +03:00
#
# 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@/find-package
FIND_REQ="/bin/sh --rpm-requires"
2003-04-22 18:24:35 +04:00
# Make sure that this shell has the rpm-requires feature
$FIND_REQ </dev/null >/dev/null 2>&1
2002-03-25 23:37:46 +03:00
file="$1"
2003-04-25 20:51:52 +04:00
fname="${file##$RPM_BUILD_ROOT}"
dname="${fname%/*}"
2003-11-07 20:56:45 +03:00
#extra=
2002-03-25 23:37:46 +03:00
if ! reqs="$($FIND_REQ "$file" 2>/dev/null)"; then
if egrep -vs '^(#|$)' "$file" 2>/dev/null |head -1 |grep -qs '^[ ]*exec '; then
2003-11-07 20:56:45 +03:00
reqs="$(printf %s\\n "$reqs" |head -1)"
#extra="$(printf %s\\n "$reqs" |sed -e 's/^\(executable\)(\(.*\))$/\2/g')"
2002-03-25 23:37:46 +03:00
else
reqs="$($FIND_REQ "$file")"
fi
fi
2003-11-07 20:56:45 +03:00
reqs="$(printf %s\\n "$reqs" |sed -e 's/^\(sh\|bash\|executable\)(\(.*\))$/\2/g' |LC_COLLATE=C sort -u)"
2002-03-25 23:37:46 +03:00
[ -n "$reqs" ] || exit 0
FindReqs()
{
for r in "$@"; do
if [ -z "${r/*\$*}" ]; then
continue
fi
2003-04-22 18:24:35 +04:00
case "$(type -t -- "$r")" in
alias|keyword|function|builtin)
continue ;;
esac
2003-04-25 20:51:52 +04:00
if ! grep -qs "^$r\$" "$RPM_BUILD_ROOT/$dname/.provides.sh"; then
local f
if f=`grep -qs "^$r\$" "/$dname/.provides.sh"`; then
2003-11-07 20:56:45 +03:00
printf %s\\n "$dname($r)"
2003-04-25 20:51:52 +04:00
else
FindPackage "$file" "$r"
fi
fi
2002-03-25 23:37:46 +03:00
done
}
# Find requires
found="$(FindReqs $reqs)"
# And print them.
2003-11-07 20:56:45 +03:00
printf %s "$found" |LC_COLLATE=C sort -u
2002-03-25 23:37:46 +03:00
# TODO: more analysis based on $extra