compareByPreference: handle the integer-gmp vs -simple case
compareByPreference: handle the integer-gmp vs -simple case

Currently, it assumes the package names are identical and this
breaks in the case where integer-gmp is in one package db and
integer-simple in another. This became a problem with
the commit: fc2ff6dd7496a33bf68165b28f37f40b7d647418.

Instead of following the precedence information, leading to
the right choice, the current code would compare the
integer-gmp and integer-simple versions and pick integer-gmp
because it happened to have a greater version, despite having
a lower precedence. See
https://github.com/snowleopard/hadrian/issues/702 for
a comprehensive report about the problem.

This effectively un-breaks integer-simple builds with hadrian.

Test Plan: hadrian/build.sh --integer-simple

Reviewers: snowleopard, bgamari

Reviewed By: bgamari

Subscribers: snowleopard, rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5266

sdiehl/ghc,sdiehl/ghc,sdiehl/ghc,sdiehl/ghc,sdiehl/ghc,sdiehl/ghc,sdiehl/ghc