Split the cabal_macros.h generation into a helper and wrapper

Makes it easier to reuse this code in other contexts, for example if we
want to build without a .cabal file using all the packages in the
environment.
Add a list command to the HcPkg module

Only useful for getting the source package ids. Does not get the
installed package ids or any other details. Most use cases should
still use dump.
Merge pull request #1399 from dcoutts/cabal_macros.h-util

Split the cabal_macros.h generation into a helper and wrapper
Merge pull request #1400 from dcoutts/hc-pkg-list

Add a list command to the HcPkg module
Merge remote-tracking branch 'upstream/master'
minor cleanup