Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 9a7a7f2f37f6fafee6cb4e3763c4173c > files > 3

ghc-rpm-macros-0.10.61-1.fc14.src.rpm

#!/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
#   %define __find_requires /usr/lib/rpm/ghc-deps.sh --requires %{buildroot}%{ghclibdir}

[ $# -ne 2 ] && echo "Usage: `basename $0` --requires %{buildroot}%{ghclibdir}" && exit 1

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
			# ignore internal packages
			base-3*) ;;
			bin-package-db-*) ;;
			ghc-binary-*) ;;
			ghc-prim-*) ;;
			integer-gmp-*) ;;
			*-*) echo $i | sed -e "s/\(.*\)-\(.*\)-.*/$DEP = \2/" ;;
			*) ;;
		    esac
		done
	    fi
	fi
    fi
done

echo $files | tr [:blank:] '\n' | /usr/lib/rpm/rpmdeps $MODE