Fix malformed database in case pkg update is interrupted

Ignore the malformed failure and rebuild the database from scratch.
Modify get_pragma() for it to be able to not emit errors if emission of
errors is not needed
Let dry_mode auto update the catalogs if -U is not passed

dry_mode will update the catalogs except if -U is not passed to install
or upgrade command or the the user has insufficient access to perform an
update of the database.

Fixes: #559
Only add missing deps if the dependency is not already listed

Reported by:	lme