Test if we have permissions to query the database first
Add more error checking while querying/installing/upgrading/autoremoving