diff --git a/ghc-deps.sh b/ghc-deps.sh index a475c3d..37263a6 100755 --- a/ghc-deps.sh +++ b/ghc-deps.sh @@ -18,14 +18,18 @@ case $MODE in *) echo "`basename $0`: Need --provides or --requires" ; exit 1 esac +GHCVERSION=$(ghc --numeric-version) + files=$(cat) #set -x -if [ -d "$PKGCONFDIR" ]; then - for i in $files; do - LIB_FILE=$(echo $i | grep /libHS | egrep -v "$PKGBASEDIR/libHS") - if [ -n "$LIB_FILE" ]; then +for i in $files; do + 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 ;; @@ -48,7 +52,15 @@ if [ -d "$PKGCONFDIR" ]; then fi fi fi - done -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 + fi +done echo $files | tr [:blank:] '\n' | /usr/lib/rpm/rpmdeps $MODE diff --git a/ghc-rpm-macros.ghc b/ghc-rpm-macros.ghc index 6b2b45e..16d060a 100644 --- a/ghc-rpm-macros.ghc +++ b/ghc-rpm-macros.ghc @@ -1,5 +1,6 @@ # "cabal" -%cabal ./Setup +%cabal [ -x Setup ] || ghc --make -dynamic Setup\ +./Setup # configure %cabal_configure\ @@ -130,8 +131,8 @@ This package provides the shared library.\ %define pkgnamever %{pkgname}-%{pkgver}\ %define basepkg ghc-%{pkgname}\ %global _use_internal_dependency_generator 0\ -%global __find_provides /usr/lib/rpm/ghc-deps.sh --provides %{buildroot}%{ghclibdir}\ -%global __find_requires /usr/lib/rpm/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\ +%global __find_provides %{_rpmconfigdir}/ghc-deps.sh --provides %{buildroot}%{ghclibdir}\ +%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\ %package -n %{basepkg}-devel\ Summary: %{?common_summary}%{!?common_summary:Haskell %{pkgname} library} development files\ Group: Development/Libraries\ @@ -197,14 +198,12 @@ find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \ # ghc_bin_build %ghc_bin_build\ -ghc --make -dynamic Setup\ %cabal_configure\ %cabal build # ghc_lib_build [name] [version] %ghc_lib_build()\ %{?1:cd %1-%2}\ -ghc --make -dynamic Setup\ %cabal_configure %{!?without_prof:-p} %{?1:--docdir=%{_docdir}/ghc-%1-%2 --htmldir=%{ghclibdocdir}/%1-%2}\ %cabal build\ %{!?without_haddock:%cabal haddock %{!?without_hscolour:--hyperlink-source}}\ @@ -213,6 +212,8 @@ ghc --make -dynamic Setup\ # install bin package %ghc_bin_install\ +%global _use_internal_dependency_generator 0\ +%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\ %cabal_install\ %ghc_strip_dynlinked diff --git a/ghc-rpm-macros.spec b/ghc-rpm-macros.spec index a332bc0..76cd853 100644 --- a/ghc-rpm-macros.spec +++ b/ghc-rpm-macros.spec @@ -1,5 +1,5 @@ Name: ghc-rpm-macros -Version: 0.11.4 +Version: 0.11.5 Release: 1%{?dist} Summary: Macros for building packages for GHC @@ -47,6 +47,11 @@ install -p %{SOURCE3} ${RPM_BUILD_ROOT}/%{_prefix}/lib/rpm %changelog +* Sun Jan 23 2011 Jens Petersen - 0.11.5-1 +- add rpm hash requires for dynamic executables in ghc-deps.sh +- compile Setup in cabal macro +- use _rpmconfigdir + * Sat Jan 22 2011 Jens Petersen - 0.11.4-1 - drop deprecated ghcdocdir and ghcpkgdir - new ghclibdocdir