Re a dependency diagram: Graphviz is brilliant for generating these types of diagrams. And you can look at the code in /acs-admin/www/apm/build-repository.tcl for code that scans all packages including contrib/packages and reads there .info files.
/Lars