[BUGFIX] Fix extension installation process

The download queue is build recursively, but if an
extension is marked for download, it is added
to the queue before its dependencies have been
resolved, which leads to a wrong download and
installation order of extensions.

We also need to add dependency resolving when
marking an extension for installation to fix
the exact same problem when extensions already
reside in the system.

Lastly we must take care of flushed class loader
caches and trigger a rebuild to avoid fatals.
This is done by introducing a signal and registering
a method in package manager as slot that set the
packages for the class loader to trigger a rebuild
of the caches.

The parts of this patch that fix dependency handling
should be backported to older 6.x branches.

Resolves: #57199
Releases: 6.2
Change-Id: Iab343c544bfe2e3e19cbf4c05090eb4994df57b1
Reviewed-on: https://review.typo3.org/28660
Reviewed-by: Sebastian Fischer
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Christian Kuhn
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Reviewed-by: Markus Klein
Tested-by: Markus Klein