Fix zfs 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-1.1ubuntu2+zfs5~raring1 release.