2010-05-25 04:13:45 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-05-25 10:02:47 +00:00
|
|
|
# script to generate dependency graph for fedora haskell libraries
|
|
|
|
# requires ghc, ghc-*-devel and graphviz to be installed
|
|
|
|
|
2010-06-03 12:38:38 +00:00
|
|
|
set -e +x
|
2010-05-25 04:13:45 +00:00
|
|
|
|
|
|
|
mkdir -p .pkg-deps
|
|
|
|
|
|
|
|
cd .pkg-deps
|
|
|
|
|
2010-06-02 08:31:03 +00:00
|
|
|
# remove the closing line
|
|
|
|
ghc-pkg dot --global | sed '$d' > pkgs.dot
|
2010-05-25 04:13:45 +00:00
|
|
|
|
2010-06-28 05:52:48 +00:00
|
|
|
# check for binary deps too
|
2010-09-24 02:44:42 +00:00
|
|
|
# (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 xmobar; do
|
2010-06-03 12:38:38 +00:00
|
|
|
PKG_THERE=yes
|
2010-09-24 02:23:10 +00:00
|
|
|
PKG=`rpm -q --qf "%{name}-%{version}" $i` || { PKG_THERE=no ; echo "missing $i" ; }
|
2010-06-03 12:38:38 +00:00
|
|
|
if [ "$PKG_THERE" = "yes" ]; then
|
2010-06-28 05:52:48 +00:00
|
|
|
echo \"$PKG\" >> pkgs.dot
|
2010-06-03 12:38:38 +00:00
|
|
|
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
|
2010-06-03 12:38:38 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2010-06-02 08:31:03 +00:00
|
|
|
done
|
|
|
|
|
2010-06-28 05:52:48 +00:00
|
|
|
# make sure all libs there
|
2010-09-13 03:40:56 +00:00
|
|
|
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
|
|
|
|
2010-06-02 08:31:03 +00:00
|
|
|
# and add it back
|
|
|
|
echo "}" >> pkgs.dot
|
2010-05-25 04:13:45 +00:00
|
|
|
|
2010-06-02 08:31:03 +00:00
|
|
|
cp -p pkgs.dot pkgs.dot.orig
|
2010-05-25 04:13:45 +00:00
|
|
|
|
2010-06-03 12:38:38 +00:00
|
|
|
# ignore library packages provided by ghc (except ghc-6.12)
|
2010-12-06 01:00:27 +00:00
|
|
|
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 template-haskell time unix Win32"
|
2010-05-25 04:13:45 +00:00
|
|
|
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 ; }
|
2010-05-25 04:13:45 +00:00
|
|
|
cat pkgs.dot | tred | dot -Nfontsize=8 -Tsvg >pkgs.svg
|
2010-05-25 10:02:47 +00:00
|
|
|
|
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
|