rpm-build/scripts/shell.req.in

65 lines
1.7 KiB
Bash
Executable File

#!/bin/sh -e
#
# shell.req
# Copyright (C) 2000 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
#
# If using normal root, avoid changing anything.
[ -n "$(echo "$RPM_BUILD_ROOT" |tr -d ' /.')" ]
. @RPMCONFIGDIR@/find-package
FIND_REQ="/bin/sh --rpm-requires"
# Make sure that this sh has the rpm-requires feature
$FIND_REQ </dev/null &>/dev/null
file="$1"
extra=
if ! reqs="$($FIND_REQ "$file" 2>/dev/null)"; then
if egrep -vs '^(#|$)' "$file" 2>/dev/null |head -1 |grep -qs '^[ ]*exec '; then
reqs="$(echo "$reqs" |head -1)"
extra="$(echo "$reqs" |sed -e 's/^\(executable\)(\(.*\))$/\2/g')"
else
reqs="$($FIND_REQ "$file")"
fi
fi
reqs="$(echo "$reqs" |sed -e 's/^\(sh\|bash\|executable\)(\(.*\))$/\2/g' |sort -u)"
[ -n "$reqs" ] || exit 0
FindReqs()
{
for r in "$@"; do
if [ -z "${r/*\$*}" ]; then
continue
fi
if [ "$(type -t -- "$r")" = "function" ]; then
continue
fi
FindPackage "$file" "$r"
done
}
# Find requires
found="$(FindReqs $reqs)"
# And print them.
echo "$found" |sort -u
# TODO: more analysis based on $extra