2011-05-08 14:29:21 +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
|
2011-05-09 05:03:22 +00:00
|
|
|
# %define __find_requires /usr/lib/rpm/ghc-deps.sh --requires %{buildroot}%{ghclibdir}
|
2011-05-08 14:29:21 +00:00
|
|
|
|
2011-05-09 05:03:22 +00:00
|
|
|
[ $# -ne 2 ] && echo "Usage: `basename $0` --requires %{buildroot}%{ghclibdir}" && exit 1
|
2011-05-08 14:29:21 +00:00
|
|
|
|
|
|
|
MODE=$1
|
|
|
|
PKGBASEDIR=$2
|
|
|
|
PKGCONFDIR=$PKGBASEDIR/package.conf.d
|
|
|
|
|
|
|
|
case $MODE in
|
|
|
|
--requires) FIELD=depends ;;
|
|
|
|
*) echo "`basename $0`: Need --requires" ; exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ -d "$PKGBASEDIR" ]; then
|
|
|
|
SHARED=$(find $PKGBASEDIR -type f -name '*.so')
|
|
|
|
fi
|
|
|
|
|
|
|
|
GHCVERSION=$(ghc --numeric-version)
|
|
|
|
|
|
|
|
files=$(cat)
|
|
|
|
|
|
|
|
#set -x
|
|
|
|
|
|
|
|
for i in $files; do
|
|
|
|
LIB_FILE=$(echo $i | grep /libHS | egrep -v "$PKGBASEDIR/libHS")
|
|
|
|
if [ "$LIB_FILE" ]; then
|
|
|
|
if [ -d "$PKGCONFDIR" ]; then
|
|
|
|
DEP=""
|
|
|
|
case $LIB_FILE in
|
|
|
|
*.so) ;;
|
|
|
|
*_p.a) DEP=ghc-\\1-prof ;;
|
|
|
|
*.a) DEP=ghc-\\1-devel ;;
|
|
|
|
esac
|
|
|
|
if [ "$DEP" ]; 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
|
2011-05-09 05:03:22 +00:00
|
|
|
# ignore internal packages
|
2011-06-22 06:35:34 +00:00
|
|
|
base-3*) ;;
|
2011-05-09 05:03:22 +00:00
|
|
|
bin-package-db-*) ;;
|
|
|
|
ghc-binary-*) ;;
|
|
|
|
ghc-prim-*) ;;
|
|
|
|
integer-gmp-*) ;;
|
2011-05-08 14:29:21 +00:00
|
|
|
*-*) echo $i | sed -e "s/\(.*\)-\(.*\)-.*/$DEP = \2/" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo $files | tr [:blank:] '\n' | /usr/lib/rpm/rpmdeps $MODE
|