Merge pull request #37 from ledgersmb/master

sync over master branch
Factor duplicated code into shared code.
Resolve copy/pasto after moving code to Database.pm.
Merge pull request #170 from ehuelsmann/master

Factor out duplicated code from setup.pm and patch-release-upgrade.pl