autodeps/linux.{req,prov}.in: implemented method dispatcher
find-requires is now a dispatcher for /usr/lib/rpm/*.req scripts (methods). find-provides is now a dispatcher for /usr/lib/rpm/*.prov scripts (methods). The algorithm is basically as follows: 1) Filter input file list through TOPDIR and SKIPLIST patterns. 2) Run the resulting file list through file(1), which output is (per line) <input-file-name><tab><optional-single-space><file-magic-type> 3) For each req/prov methods, there must be corresponding *.files filter (e.g. /usr/lib/rpm/perl.req.files for /usr/lib/rpm/perl.req). We feed file(1) output to this filter; the filter must print the list of <input-files-name>s (per line) which will be processed with the corresponding req/prov method. 4) Each req/prov method is invoked with corresponding file list on its standard input. The method must output valid rpm dependencies (per line) or exit with non-zero code. Notes: Unlike find-requires, find-provides runs file(1) with -L option. RPM_FINDREQ_DEFAULT_METHOD and RPM_FINDPROV_DEFAULT go away. All available methods are run by default. The old code has been kept. I am going to remove it gradually as I factor particular req/prov scripts.
This commit is contained in:
parent
844f420037
commit
9717c12847
@ -1,6 +1,7 @@
|
||||
#!/bin/sh -ef
|
||||
#!/bin/sh -efu
|
||||
#
|
||||
# Copyright (C) 2000-2006 Dmitry V. Levin <ldv@altlinux.org>
|
||||
# Copyright (C) 2007 Alexey Tourbin <at@altlinux.org>
|
||||
#
|
||||
# find-provides - generate list of linux-specific package provides.
|
||||
# Inspired by tool with same name from RPM distribution.
|
||||
@ -23,6 +24,90 @@
|
||||
. @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 prov "$RPM_FINDPROV_METHOD")
|
||||
if [ -z "$methods" ]; then
|
||||
Info "AutoProv 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_FINDPROV_TOPDIR-}" ] && [ -z "${fname%%$RPM_FINDPROV_TOPDIR/*}" ]; then
|
||||
Debug "skip $f due to RPM_FINDPROV_TOPDIR=$RPM_FINDPROV_TOPDIR"
|
||||
continue
|
||||
fi
|
||||
if [ -n "${RPM_FINDPROV_SKIPLIST-}" ]; then
|
||||
for skip in $RPM_FINDPROV_SKIPLIST; do
|
||||
if [ -z "${fname##$skip}" ]; then
|
||||
Debug "skip $f due to RPM_FINDPROV_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 (dereference symlinks)
|
||||
if ! file -L -NF$'\t' -f "$workdir"/files >"$workdir"/files+types; then
|
||||
sed -n '/\t *ERROR:/p' "$workdir"/files+types >&2
|
||||
sed -i '/\t *ERROR:/d' "$workdir"/files+types
|
||||
fi
|
||||
|
||||
if ! [ -s "$workdir"/files+types ]; then
|
||||
Info "empty file list, nothing to do"
|
||||
exit 0
|
||||
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 prov "$methods" RunMethod
|
||||
[ -z "$found" ] || (set +f; LC_COLLATE=C sort -u "$workdir"/*.deps) || exit 1
|
||||
|
||||
exit 0
|
||||
|
||||
# Normalize buildroot.
|
||||
real_buildroot="$(cd "$RPM_BUILD_ROOT" && /bin/pwd)" || exit 1
|
||||
|
||||
@ -343,24 +428,7 @@ FindLibProvs()
|
||||
fi
|
||||
}
|
||||
|
||||
: ${RPM_FINDPROV_TOPDIR:=}
|
||||
: ${RPM_FINDPROV_SKIPLIST:=}
|
||||
|
||||
while IFS= read -r f; do
|
||||
fname="${f#$RPM_BUILD_ROOT}"
|
||||
fname="${fname#.}"
|
||||
|
||||
if [ -n "$RPM_FINDPROV_TOPDIR" ] && [ -z "${fname%%$RPM_FINDPROV_TOPDIR/*}" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -n "$RPM_FINDPROV_SKIPLIST" ]; then
|
||||
for skip in $RPM_FINDPROV_SKIPLIST; do
|
||||
if [ -z "${fname##$skip}" ]; then
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Find out file type (dereference symlinks).
|
||||
if t="$(file -bL "$f")"; then
|
||||
if [ -z "${fname##/usr/share/pkgconfig/*.pc}" -o -z "${fname##$RPM_LIBDIR/pkgconfig/*.pc}" ]; then
|
||||
[ -n "$FIND_PKGCONFIG" ] || continue
|
||||
@ -399,6 +467,3 @@ FindPythonProvs
|
||||
|
||||
# Find provides in listed tcl index files, if any
|
||||
FindTclProvs
|
||||
|
||||
# Finally sort and print them.
|
||||
printf %s "$FOUND_PROVS" |LC_COLLATE=C sort -u
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/bin/sh -ef
|
||||
#!/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.
|
||||
@ -23,15 +24,84 @@
|
||||
. @RPMCONFIGDIR@/functions
|
||||
ValidateBuildRoot
|
||||
|
||||
workdir=
|
||||
exit_handler()
|
||||
{
|
||||
local rc=$?
|
||||
trap - EXIT
|
||||
cat >/dev/null 2>&1
|
||||
[ -z "$workdir" ] || rm -rf "$workdir"
|
||||
cat >/dev/null
|
||||
exit $rc
|
||||
}
|
||||
|
||||
trap exit_handler EXIT
|
||||
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=
|
||||
@ -398,23 +468,7 @@ if [ -n "$RPM_SUBPACKAGE_NAME" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
: ${RPM_FINDREQ_TOPDIR:=}
|
||||
: ${RPM_FINDREQ_SKIPLIST:=}
|
||||
|
||||
while IFS= read -r f; do
|
||||
fname="${f#$RPM_BUILD_ROOT}"
|
||||
fname="${fname#.}"
|
||||
|
||||
if [ -n "$RPM_FINDREQ_TOPDIR" ] && [ -z "${fname%%$RPM_FINDREQ_TOPDIR/*}" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -n "$RPM_FINDREQ_SKIPLIST" ]; then
|
||||
for skip in $RPM_FINDREQ_SKIPLIST; do
|
||||
if [ -z "${fname##$skip}" ]; then
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ -n "$FIND_FILES" ]; then
|
||||
for p in $(grep '^[^#]' @RPMCONFIGDIR@/files.req.list); do
|
||||
if [ -z "${fname%%$p/*}" ]; then
|
||||
@ -424,7 +478,6 @@ $p"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
t="$(file -b "$f")"
|
||||
if [ -z "${fname##/usr/share/pkgconfig/*.pc}" -o -z "${fname##$RPM_LIBDIR/pkgconfig/*.pc}" ]; then
|
||||
[ -n "$FIND_PKGCONFIG" ] || continue
|
||||
r="$(@RPMCONFIGDIR@/pkgconfig.req "$f")"
|
||||
@ -466,6 +519,3 @@ FindPythonReqs
|
||||
|
||||
# Find requires in listed tcl scripts, if any
|
||||
FindTclReqs
|
||||
|
||||
# Finally sort and print them.
|
||||
printf %s "$FOUND_REQS" |LC_COLLATE=C sort -u
|
||||
|
@ -210,8 +210,6 @@
|
||||
@alt@ %{?_verify_elf_method:export RPM_VERIFY_ELF_METHOD=\"%_verify_elf_method\"}\
|
||||
@alt@ %{?_findreq_method:export RPM_FINDREQ_METHOD=\"%_findreq_method\"}\
|
||||
@alt@ %{?_findprov_method:export RPM_FINDPROV_METHOD=\"%_findprov_method\"}\
|
||||
@alt@ %{?_findreq_default_method:export RPM_FINDREQ_DEFAULT_METHOD=\"%_findreq_default_method\"}\
|
||||
@alt@ %{?_findprov_default_method:export RPM_FINDPROV_DEFAULT_METHOD=\"%_findprov_default_method\"}\
|
||||
@alt@ %{?_cleanup_topdir:export RPM_CLEANUP_TOPDIR=\"%_cleanup_topdir\"}\
|
||||
@alt@ %{?_compress_topdir:export RPM_COMPRESS_TOPDIR=\"%_compress_topdir\"}\
|
||||
@alt@ %{?_fixup_topdir:export RPM_FIXUP_TOPDIR=\"%_fixup_topdir\"}\
|
||||
@ -454,8 +452,6 @@
|
||||
@alt@%_tcl_req_skip ""
|
||||
@alt@%_fixup_method binconfig pkgconfig libtool
|
||||
@alt@%_strip_method %{?_enable_debug:none}%{!?_enable_debug:executable shared}
|
||||
@alt@%_findreq_default_method files java lib mono pam perl pkgconfig python shell tcl
|
||||
@alt@%_findprov_default_method java lib mono pam perl pkgconfig python shell tcl
|
||||
@alt@
|
||||
@alt@%_cleanup_topdir %nil
|
||||
@alt@%_compress_topdir %_usr
|
||||
|
Loading…
Reference in New Issue
Block a user