ghc/pkg-deps.sh

55 lines
1.9 KiB
Bash
Raw Normal View History

#!/bin/sh
# script to generate dependency graph for fedora haskell libraries
# requires ghc, ghc-*-devel and graphviz to be installed
set -e +x
mkdir -p .pkg-deps
cd .pkg-deps
# remove the closing line
ghc-pkg dot --global | sed '$d' > pkgs.dot
2010-06-28 05:52:48 +00:00
# check for binary deps too
# (exclude binlib for now since covered by libs): cpphs, darcs, hlint, hscolour, xmonad
for i in alex cabal-install ghc happy gtk2hs-buildtools haskell-platform hedgewars-server xmobar; do
PKG_THERE=yes
PKG=`rpm -q --qf "%{name}-%{version}" $i` || { PKG_THERE=no ; echo "missing: $i" ; }
if [ "$PKG_THERE" = "yes" ]; then
2010-06-28 05:52:48 +00:00
echo \"$PKG\" >> pkgs.dot
case $i in
haskell-platform)
rpm -q --requires $i | grep -v rpmlib | grep -v ghc | sed -e "s/^/\"$PKG\" -> \"/g" -e "s/ = \(.*\)/-\1\"/" >> pkgs.dot
;;
*)
2010-11-30 09:22:17 +00:00
rpm -q --requires $i | grep -- -ghc | sed -e "s/libHS/\"$PKG\" -> \"/g" -e "s/-ghc.*/\"/" >> pkgs.dot
;;
esac
fi
done
2010-06-28 05:52:48 +00:00
# make sure all libs there
rpm -qa --qf "\"%{name}-%{version}\"\n" ghc-\* | egrep -v -- "(ghc-libs|-prof|-devel|-doc|rpm-macros)-" | sed -e s/^\"ghc-/\"/g >> pkgs.dot
2010-06-28 05:52:48 +00:00
# and add it back
echo "}" >> pkgs.dot
cp -p pkgs.dot pkgs.dot.orig
# ignore library packages provided by ghc (except ghc-6.12)
GHC_PKGS="array base-4 base-3 bin-package-db $(ghc-pkg --simple-output list bytestring) Cabal containers directory dph extensible-exceptions filepath ffi ghc-binary ghc-prim haskell98 hpc integer-gmp old-locale old-time pretty process random rts syb-0.1 template-haskell time unix Win32"
for i in $GHC_PKGS; do sed -i -e /$i/d pkgs.dot; done
2010-09-30 07:57:22 +00:00
which tred &>/dev/null || { echo "graphviz is needed to generate graph" ; exit 1 ; }
cat pkgs.dot | tred | dot -Nfontsize=8 -Tsvg >pkgs.svg
2010-06-03 07:25:14 +00:00
if [ -n "$DISPLAY" ]; then
2010-06-03 07:22:29 +00:00
xdg-open pkgs.svg
2010-06-28 05:52:48 +00:00
else
echo open ".pkg-deps/pkgs.svg" to display pkg graph
2010-06-03 07:22:29 +00:00
fi
echo https://fedoraproject.org/wiki/Haskell_package_interdependencies