such a library would be great !
what i did for cean is simple but not powerfull, you can check it with
package/depends function ($HOME/.cean/functions/package/depends)
it's all based on what is declared into .pub files :/
I used to produce output for the .pub files with a simple script that
listed erlang calls for every module, but it does not handle
parameterized calls for example. it's also not able to handle name
collision, ...
accurate package dependency resolving is, like you said, not easy.