refactor create*deps commands

Move common writedeps function into Build.pm. Make use of query
in createrpmdeps. Much cleanup done as well.