Cleanup/refactor new dpkg selections support

This builds on the code merged in c2a304c, correcting some style-related
issues, reducing the number of times that get_selections() needs to be
called within set_selections(), and raising the proper exceptions when
invalid input is specified.
Merge pull request #7054 from terminalmage/dpkg-selections-refactor

Cleanup/refactor new dpkg selections support