(#19875) Refactored dpkg/rpm query handling.

From the pull request comments, refactors the parsing and improves test
coverage.  Dpkg.instance, Dpkg#query both used a Dpkg.dpkgquery_piped to
expose an IO pipe for parsing.  Regex match used in Rpm to ensure we
only consume good query output lines.

NOTE: Once the PR is approved I will squash this into the previous commit and
generate a fresh message (with correct issue # :) before merging.