[FIX] modules.loading: extra loop when installing/upgrading modules to help solve missing deps

In some rare cases the dependencies have changed, and modules that depend on an uninstalled module
will not be processed on the first pass.
[MERGE] modules.loading: extra loop when installing/upgrading modules to help solve missing deps

In some rare cases the dependencies have changed, and modules that newly depend
on a module that is not installed cannot be loaded on the first pass.

For technical reasons all installed/to upgrade/to remove modules have to be
processed before starting to consider new installations, so this requires
two passes.

In trunk the inner loop inside `load_marked_modules()` will be dropped
because it should be unnecessary.