Extract pkgconfig and libtool dependencies automatically.

Ported from rpm5.org work of Jeff Johnson.
This commit is contained in:
Panu Matilainen 2007-07-31 12:06:34 +03:00
parent 345d1189ae
commit 6c4b0fc9e4
6 changed files with 127 additions and 4 deletions

View File

@ -463,6 +463,9 @@ static struct rpmfcTokens_s rpmfcTokens[] = {
/* XXX "python 2.3 byte-compiled" */
{ "python ", RPMFC_PYTHON|RPMFC_INCLUDE },
{ "libtool library ", RPMFC_LIBTOOL|RPMFC_INCLUDE },
{ "pkgconfig ", RPMFC_PKGCONFIG|RPMFC_INCLUDE },
/* XXX .NET executables and libraries. file(1) cannot differ from win32
* executables unfortunately :( */
{ "PE executable", RPMFC_MONO|RPMFC_INCLUDE },
@ -739,7 +742,21 @@ static int rpmfcSCRIPT(rpmfc fc)
if (is_executable)
#endif
xx = rpmfcHelper(fc, 'R', "python");
}
} else
if (fc->fcolor->vals[fc->ix] & RPMFC_LIBTOOL) {
xx = rpmfcHelper(fc, 'P', "libtool");
#ifdef NOTYET
if (is_executable)
#endif
xx = rpmfcHelper(fc, 'R', "libtool");
} else
if (fc->fcolor->vals[fc->ix] & RPMFC_PKGCONFIG) {
xx = rpmfcHelper(fc, 'P', "pkgconfig");
#ifdef NOTYET
if (is_executable)
#endif
xx = rpmfcHelper(fc, 'R', "pkgconfig");
} else
if (fc->fcolor->vals[fc->ix] & RPMFC_MONO) {
xx = rpmfcHelper(fc, 'P', "mono");
if (is_executable)
@ -1093,6 +1110,8 @@ static struct rpmfcApplyTbl_s rpmfcApplyTable[] = {
{ rpmfcELF, RPMFC_ELF },
{ rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PERL) },
{ rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PYTHON) },
{ rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PKGCONFIG) },
{ rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_LIBTOOL) },
{ rpmfcSCRIPT, RPMFC_MONO },
{ NULL, 0 }
};
@ -1258,10 +1277,21 @@ assert(s != NULL);
case S_IFLNK:
case S_IFREG:
default:
#define _suffix(_s, _x) \
(slen >= sizeof(_x) && !strcmp((_s)+slen-(sizeof(_x)-1), (_x)))
/* XXX all files with extension ".pm" are perl modules for now. */
/*@-branchstate@*/
if (slen >= sizeof(".pm") && !strcmp(s+slen-(sizeof(".pm")-1), ".pm"))
if (_suffix(s, ".pm"))
ftype = "Perl5 module source text";
/* XXX all files with extension ".la" are libtool for now. */
else if (_suffix(s, ".la"))
ftype = "libtoo library file";
/* XXX all files with extension ".pc" are pkgconfig for now. */
else if (_suffix(s, ".pc"))
ftype = "pkgconfig file";
/* XXX skip all files in /dev/ which are (or should be) %dev dummies. */
else if (slen >= fc->brlen+sizeof("/dev/") && !strncmp(s+fc->brlen, "/dev/", sizeof("/dev/")-1))
ftype = "";

View File

@ -53,6 +53,8 @@ enum FCOLOR_e {
RPMFC_ELF64 = (1 << 1),
#define RPMFC_ELF (RPMFC_ELF32|RPMFC_ELF64)
RPMFC_PKGCONFIG = (1 << 5),
RPMFC_LIBTOOL = (1 << 6),
RPMFC_MODULE = (1 << 7),
RPMFC_EXECUTABLE = (1 << 8),
RPMFC_SCRIPT = (1 << 9),

View File

@ -441,6 +441,12 @@ print (t)\
%__mono_provides @RPMCONFIGDIR@/mono-find-provides %{_builddir}/%{?buildsubdir} %{buildroot} %{_libdir}
%__mono_requires @RPMCONFIGDIR@/mono-find-requires %{_builddir}/%{?buildsubdir} %{buildroot} %{_libdir}
%__libtool_provides @RPMCONFIGDIR@/libtooldeps.sh --provides %{buildroot} %{name}
%__libtool_requires @RPMCONFIGDIR@/libtooldeps.sh --requires %{buildroot} %{name}
%__pkgconfig_provides @RPMCONFIGDIR@/pkgconfigdeps.sh --provides
%__pkgconfig_requires @RPMCONFIGDIR@/pkgconfigdeps.sh --requires
#
# fixowner, fixgroup, and fixperms are run at the end of hardcoded setup
# These macros are necessary only for legacy compatibility, and have moved

View File

@ -23,7 +23,8 @@ EXTRA_DIST = \
macros.perl.in macros.python.in \
macros.php.in find-requires.php find-provides.php \
find-php-provides find-php-requires \
mono-find-requires mono-find-provides
mono-find-requires mono-find-provides \
pkgconfigdeps.sh libtooldeps.sh
installprefix = $(DESTDIR)

42
scripts/libtooldeps.sh Normal file
View File

@ -0,0 +1,42 @@
#!/bin/sh
[ $# -ge 2 ] || {
cat > /dev/null
exit 0
}
case $1 in
-P|--provides)
shift
RPM_BUILD_ROOT="$1"
while read possible
do
case "$possible" in
*.la)
if grep -iq '^# Generated by ltmain.sh' "$possible" 2> /dev/null ; then
possible="`echo ${possible} | sed -e s,${RPM_BUILD_ROOT}/,/,`"
echo "libtool($possible)"
fi
;;
esac
done
;;
-R|--requires)
while read possible ; do
case "$possible" in
*.la)
for dep in `grep '^dependency_libs='"$possible" 2> /dev/null | \
sed -e "s,^dependency_libs='\(.*\)',\1,g"`
do
case "$dep" in
/*.la)
echo "libtool($dep)"
;;
esac
done
;;
esac
done
;;
esac
exit 0

42
scripts/pkgconfigdeps.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
pkgconfig=/usr/bin/pkg-config
test -x $pkgconfig || {
cat > /dev/null
exit 0
}
[ $# -ge 1 ] || {
cat > /dev/null
exit 0
}
case $1 in
-P|--provides)
while read filename ; do
case "${filename}" in
*.pc)
# Query the dependencies of the package.
$pkgconfig --print-provides "$filename" 2> /dev/null | while read n r v ; do
# We have a dependency. Make a note that we need the pkgconfig
# tool for this package.
echo "pkgconfig($n)" "$r" "$v"
done
;;
esac
done
;;
-R|--requires)
while read filename ; do
case "${filename}" in
*.pc)
$pkgconfig --print-requires "$filename" 2> /dev/null | while read n r v ; do
i="`expr $i + 1`"
[ $i -eq 1 ] && echo "pkgconfig"
echo "pkgconfig($n)" "$r" "$v"
done
esac
done
;;
esac
exit 0