203 lines
4.7 KiB
Bash
Executable File
203 lines
4.7 KiB
Bash
Executable File
#!/bin/sh -efu
|
|
#
|
|
# Copyright (C) 2000-2006 Dmitry V. Levin <ldv@altlinux.org>
|
|
# Copyright (C) 2007 Alexey Tourbin <at@altlinux.org>
|
|
#
|
|
# find-requires - generate list of linux-specific package requires.
|
|
# Inspired by tool with same name from RPM distribution.
|
|
#
|
|
# 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
|
|
ValidateBuildRoot
|
|
|
|
workdir=
|
|
exit_handler()
|
|
{
|
|
local rc=$?
|
|
trap - EXIT
|
|
[ -z "$workdir" ] || rm -rf "$workdir"
|
|
cat >/dev/null
|
|
exit $rc
|
|
}
|
|
|
|
trap exit_handler EXIT HUP INT QUIT PIPE TERM
|
|
|
|
methods=$(SetupMethods req "$RPM_FINDREQ_METHOD")
|
|
if [ -z "$methods" ]; then
|
|
Info "AutoReq disabled, nothing to do"
|
|
exit 0
|
|
fi
|
|
|
|
workdir=$(mktemp -dt "$PROG".XXXXXXXX)
|
|
|
|
# filter file list through TOPDIR and SKIPLIST patterns
|
|
while IFS= read -r f; do
|
|
fname="${f#$RPM_BUILD_ROOT}"
|
|
if [ -n "${RPM_FINDREQ_TOPDIR-}" ] && [ -z "${fname%%$RPM_FINDREQ_TOPDIR/*}" ]; then
|
|
Debug "skip $f due to RPM_FINDREQ_TOPDIR=$RPM_FINDREQ_TOPDIR"
|
|
continue
|
|
fi
|
|
if [ -n "${RPM_FINDREQ_SKIPLIST-}" ]; then
|
|
for skip in $RPM_FINDREQ_SKIPLIST; do
|
|
if [ -z "${fname##$skip}" ]; then
|
|
Debug "skip $f due to RPM_FINDREQ_SKIPLIST pattern $skip"
|
|
continue 2
|
|
fi
|
|
done
|
|
fi
|
|
echo "$f"
|
|
done >"$workdir"/files
|
|
|
|
if ! [ -s "$workdir"/files ]; then
|
|
Info "empty file list, nothing to do"
|
|
exit 0
|
|
fi
|
|
|
|
# filter file list through file(1) to append types
|
|
if ! file -NF$'\t' -f "$workdir"/files >"$workdir"/files+types; then
|
|
sed -n '/\t *ERROR:/p' "$workdir"/files+types >&2
|
|
exit 1
|
|
fi
|
|
|
|
found=
|
|
RunMethod()
|
|
{
|
|
local exe="$1"; shift
|
|
local filter="$exe".files
|
|
if ! [ -x "$filter" ]; then
|
|
# XXX should be Fatal
|
|
Info "$filter not available"
|
|
return
|
|
fi
|
|
local filelist="$workdir/${exe##*/}".files
|
|
local deplist="$workdir/${exe##*/}".deps
|
|
Debug "running $filter"
|
|
"$filter" <"$workdir"/files+types >"$filelist"
|
|
Verbose "$filter: $(wc -l <"$filelist") files"
|
|
[ -s "$filelist" ] || return 0
|
|
# XXX validate $filelist
|
|
Debug "running $exe"
|
|
"$exe" <"$filelist" >"$deplist"
|
|
Verbose "$exe: $(wc -l <"$deplist") dependencies"
|
|
[ -s "$deplist" ] || return 0
|
|
found=1
|
|
}
|
|
|
|
Info "running scripts ($methods)"
|
|
RunMethods req "$methods" RunMethod
|
|
[ -z "$found" ] || (set +f; LC_COLLATE=C sort -u "$workdir"/*.deps) || exit 1
|
|
|
|
exit 0
|
|
|
|
FIND_FILES=
|
|
FIND_JAVA=
|
|
FIND_MONO=
|
|
|
|
ParseMethod()
|
|
{
|
|
local t
|
|
for t in "$@"; do
|
|
case "${t/%,}" in
|
|
no|none|off|false)
|
|
FIND_FILES=
|
|
FIND_JAVA=
|
|
FIND_MONO=
|
|
;;
|
|
java)
|
|
FIND_JAVA=1
|
|
;;
|
|
nojava)
|
|
FIND_JAVA=
|
|
;;
|
|
mono)
|
|
FIND_MONO=1
|
|
;;
|
|
nomono)
|
|
FIND_MONO=
|
|
;;
|
|
all)
|
|
FIND_MONO=1
|
|
FIND_JAVA=1
|
|
;;
|
|
default|yes|true)
|
|
ParseMethod $RPM_FINDREQ_DEFAULT_METHOD
|
|
;;
|
|
*)
|
|
Fatal "Unrecognized find-requires method: $t"
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
ParseMethod $RPM_FINDREQ_METHOD
|
|
|
|
if [ -z "$FIND_JAVA" -a \
|
|
-z "$FIND_MONO" -a \
|
|
-z "$FIND_SCRIPT" ]; then
|
|
# Nothing to do
|
|
exit
|
|
fi
|
|
|
|
if [ -n "$*" ]; then
|
|
# We do not handle arguments yet...
|
|
exit
|
|
fi
|
|
|
|
. @RPMCONFIGDIR@/find-package
|
|
|
|
FOUND_REQS=
|
|
LIST_JAVA=
|
|
LIST_MONO=
|
|
|
|
FindJavaReqs()
|
|
{
|
|
[ -n "$FIND_JAVA" -a -n "$LIST_JAVA" -a -x "@RPMCONFIGDIR@/java.req" ] || return 0
|
|
|
|
local r
|
|
r="$(printf %s\\n "$LIST_JAVA" |
|
|
@RPMCONFIGDIR@/java.req "$RPM_BUILD_DIR" "$RPM_BUILD_ROOT" "$RPM_LIBDIR")" || return 1
|
|
[ -z "$FOUND_REQS" ] && FOUND_REQS="$r" || FOUND_REQS="$FOUND_REQS
|
|
$r"
|
|
}
|
|
|
|
FindMonoReqs()
|
|
{
|
|
[ -n "$FIND_MONO" -a -n "$LIST_MONO" -a -x "@RPMCONFIGDIR@/mono.req" ] || return 0
|
|
|
|
local r
|
|
r="$(printf %s\\n "$LIST_MONO" |
|
|
@RPMCONFIGDIR@/mono.req "$RPM_BUILD_DIR" "$RPM_BUILD_ROOT" "$RPM_LIBDIR")" || return 1
|
|
[ -z "$FOUND_REQS" ] && FOUND_REQS="$r" || FOUND_REQS="$FOUND_REQS
|
|
$r"
|
|
}
|
|
|
|
while IFS= read -r f; do
|
|
if [ -z "${t##*Mono/.Net assembly*}" -o -z "${t##*MS Windows PE*}" ]; then
|
|
[ -z "$LIST_MONO" ] && LIST_MONO="$f" || LIST_MONO="$LIST_MONO
|
|
$f"
|
|
elif [ -z "${t##*Zip archive data*}" -a -z "${f##*.jar}" ] ||
|
|
[ -z "${t##*compiled Java class data*}" ]; then
|
|
[ -z "$LIST_JAVA" ] && LIST_JAVA="$f" || LIST_JAVA="$LIST_JAVA
|
|
$f"
|
|
fi
|
|
done
|
|
|
|
# Find requires in listed Java files, if any
|
|
FindJavaReqs
|
|
|
|
# Find requires in listed .Net files, if any
|
|
FindMonoReqs
|