2010-09-30 02:21:16 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# find rpm provides and requires for Haskell GHC libraries
|
|
|
|
|
|
|
|
# To use add the following lines to spec file:
|
|
|
|
# %define _use_internal_dependency_generator 0
|
2010-11-23 05:01:27 +00:00
|
|
|
# %define __find_requires /usr/lib/rpm/ghc-deps.sh --requires %{buildroot}%{ghcpkgbasedir}
|
|
|
|
# %define __find_provides /usr/lib/rpm/ghc-deps.sh --provides %{buildroot}%{ghcpkgbasedir}
|
2010-09-30 02:21:16 +00:00
|
|
|
|
2010-11-23 05:01:27 +00:00
|
|
|
[ $# -ne 2 ] && echo "Usage: `basename $0` [--provides|--requires] %{buildroot}" && exit 1
|
2010-09-30 02:21:16 +00:00
|
|
|
|
|
|
|
MODE=$1
|
2010-11-23 05:01:27 +00:00
|
|
|
PKGBASEDIR=$2
|
|
|
|
PKGCONFDIR=$PKGBASEDIR/package.conf.d
|
2010-09-30 02:21:16 +00:00
|
|
|
|
2010-11-23 13:48:16 +00:00
|
|
|
case $MODE in
|
|
|
|
--provides) FIELD=id ;;
|
|
|
|
--requires) FIELD=depends ;;
|
|
|
|
*) echo "`basename $0`: Need --provides or --requires" ; exit 1
|
|
|
|
esac
|
|
|
|
|
2011-02-10 12:11:02 +00:00
|
|
|
SHARED=$(find $PKGBASEDIR -type f -name '*.so')
|
|
|
|
|
2011-01-23 05:05:38 +00:00
|
|
|
GHCVERSION=$(ghc --numeric-version)
|
|
|
|
|
2010-09-30 02:21:16 +00:00
|
|
|
files=$(cat)
|
|
|
|
|
2010-11-23 05:01:27 +00:00
|
|
|
#set -x
|
2010-09-30 02:21:16 +00:00
|
|
|
|
2011-01-23 05:05:38 +00:00
|
|
|
for i in $files; do
|
2011-02-10 12:11:02 +00:00
|
|
|
LIB_FILE=$(echo $i | grep /libHS | egrep -v "$PKGBASEDIR/libHS")
|
|
|
|
if [ -n "$LIB_FILE" ]; then
|
|
|
|
if [ -d "$PKGCONFDIR" ]; then
|
|
|
|
META=""
|
|
|
|
SELF=""
|
|
|
|
case $LIB_FILE in
|
|
|
|
*.so) META=ghc ;;
|
|
|
|
*_p.a) META=ghc-prof SELF=ghc-devel ;;
|
|
|
|
*.a) META=ghc-devel
|
|
|
|
if [ -n "$SHARED" ]; then
|
|
|
|
SELF=ghc
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if [ -n "$META" ]; then
|
|
|
|
PKGVER=$(echo $LIB_FILE | sed -e "s%$PKGBASEDIR/\([^/]\+\)/libHS.*%\1%")
|
|
|
|
HASHS=$(ghc-pkg -f $PKGCONFDIR field $PKGVER $FIELD | sed -e "s/^$FIELD: \+//")
|
|
|
|
for i in $HASHS; do
|
|
|
|
case $i in
|
|
|
|
*-*) echo $i | sed -e "s/\(.*\)-\(.*\)/$META(\1) = \2/" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
if [ "$MODE" = "--requires" -a -n "$SELF" ]; then
|
|
|
|
HASHS=$(ghc-pkg -f $PKGCONFDIR field $PKGVER id | sed -e "s/^id: \+//")
|
|
|
|
for i in $HASHS; do
|
|
|
|
echo $i | sed -e "s/\(.*\)-\(.*\)/$SELF(\1) = \2/"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
elif [ "$MODE" = "--requires" ]; then
|
|
|
|
if file $i | grep -q 'executable, .* dynamically linked'; then
|
|
|
|
BIN_DEPS=$(ldd $i | grep libHS | grep -v libHSrts | sed -e "s%^\\tlibHS\(.*\)-ghc${GHCVERSION}.so =.*%\1%")
|
|
|
|
for p in ${BIN_DEPS}; do
|
|
|
|
HASH=$(ghc-pkg --global field $p id | sed -e "s/^id: \+//")
|
|
|
|
echo $HASH | sed -e "s/\(.*\)-\(.*\)/ghc(\1) = \2/"
|
|
|
|
done
|
|
|
|
fi
|
2010-11-23 05:01:27 +00:00
|
|
|
fi
|
2011-01-23 05:05:38 +00:00
|
|
|
done
|
2010-09-30 02:21:16 +00:00
|
|
|
|
|
|
|
echo $files | tr [:blank:] '\n' | /usr/lib/rpm/rpmdeps $MODE
|