Fix autoinstall failures for kernel upgrades.

The module dependency logic has a faulty assumption that fails if the dependee
is built before the dependent during separate `dkms autoinstall` invocations.

For example, if zfs-dkms is built after spl-dkms, and if `dkms autoinstall` is
run separately for each, then it no-ops like the BUILD_DEPENDS is unsatisfied.

Generate the installed_modules list early and move the dependency reduction
logic to the top of the installation loop.
PPA 2.2.0.3-1ubuntu3.1+zfs5~precise1 release.