fec42b2c88
backport some updates from rawhide 0.95.5: - new cabal-tweak-dep-ver script to tweak depends version bounds in .cabal - ghc-dep.sh: only use buildroot package.conf.d if it exists - ghc-deps.sh: look in buildroot package.conf.d for program deps - add a meta-package option to ghc_devel_package and use in ghc_devel_requires - allow ghc_description, ghc_devel_description, ghc_devel_post_postun to take args - support meta packages like haskell-platform without base lib files - add shell variable cabal_configure_extra_options to cabal_configure for local configuration - do not provide prof when without_prof set
85 lines
2.4 KiB
Bash
Executable File
85 lines
2.4 KiB
Bash
Executable File
#!/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}
|
|
# %define __find_provides /usr/lib/rpm/ghc-deps.sh --provides %{buildroot}%{ghclibdir}
|
|
|
|
[ $# -ne 2 ] && echo "Usage: `basename $0` [--provides|--requires] %{buildroot}%{ghclibdir}" && exit 1
|
|
|
|
MODE=$1
|
|
PKGBASEDIR=$2
|
|
PKGCONFDIR=$PKGBASEDIR/package.conf.d
|
|
GHC_VER=$(basename $PKGBASEDIR | sed -e s/ghc-//)
|
|
|
|
if [ ! -x "/usr/bin/ghc-pkg-${GHC_VER}" -a -x "$PKGBASEDIR/ghc-pkg" ]; then
|
|
GHC_PKG="$PKGBASEDIR/ghc-pkg --global-conf=$PKGCONFDIR"
|
|
else
|
|
GHC_PKG="/usr/bin/ghc-pkg"
|
|
fi
|
|
|
|
case $MODE in
|
|
--provides) FIELD=id ;;
|
|
--requires) FIELD=depends ;;
|
|
*) echo "`basename $0`: Need --provides or --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
|
|
META=""
|
|
SELF=""
|
|
case $LIB_FILE in
|
|
*.so) META=ghc ;;
|
|
*_p.a) META=ghc-prof SELF=ghc-devel ;;
|
|
*.a) META=ghc-devel
|
|
if [ "$SHARED" ]; then
|
|
SELF=ghc
|
|
fi
|
|
;;
|
|
esac
|
|
if [ "$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 "$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%")
|
|
if [ -d "$PKGCONFDIR" ]; then
|
|
PACKAGE_CONF_OPT="--package-conf=$PKGCONFDIR"
|
|
fi
|
|
for p in ${BIN_DEPS}; do
|
|
HASH=$(${GHC_PKG} --global $PACKAGE_CONF_OPT field $p id | sed -e "s/^id: \+//")
|
|
echo $HASH | sed -e "s/\(.*\)-\(.*\)/ghc(\1) = \2/"
|
|
done
|
|
fi
|
|
fi
|
|
done
|
|
|
|
echo $files | tr [:blank:] '\n' | /usr/lib/rpm/rpmdeps $MODE
|