Switch InstallPlan over to using IPID-indexed PackageIndex.

Let's try again! Last time, we backed out because #2123 reported a regression. I've since fixed it: it was a bug in the install plan linearization code (which is a gigantic hack in any case). So let's re-CR this and get it back in.

Also, there's a bonus patch improving diagnostic information when we generate an invalid install plan. The exported methods might be useful for other debugging too.