Don't install dependencies brought in by virtual packages

When calculating the missing dependencies for an ebuild to be installed
by entropy, it's necessary to walk two levels deep minimum to handle meta
packages and split ebuilds. This has a nasty side effect for virtual packages
since all the potential candidates that could satisfy the virtual are
included. This means for anything that has a dependency on virtual/jdk, every
possible jdk is installed side-by-side. For anything that depends on
virtual/mta, every possible mta is installed one by one (because these conflict
and substitute each other, each subsequent install uninstalls the previous
package which is a massive waste of time, bandwidth and effort).

This commit walks through the dependency list looking for any virtual packages.
For each one, the first-level dependencies of the virtual are collected. Only
dependencies of the target package which are not also dependencies of the virtual
are installed. This means only one package that satisfies the virtual will end up
being installed.
This commit is contained in:
Ben Roberts
2016-03-06 17:35:53 +00:00
parent 5895b63ef6
commit 1c29cba964
+14 -2
View File
@@ -67,9 +67,21 @@ sub calculate_missing {
# Getting the package dependencies and the installed packages
say "[$package] Getting the package dependencies and the installed packages";
my @Packages = package_deps( $package, $depth, 1 );
my @dependencies = package_deps( $package, $depth, 1 );
my %install_dependencies = map { $_ => 1 } @dependencies;
say "[$package] Getting the package dependencies and the installed packages";
# Look for any virtuals and remove its immediate dependencies to avoid
# installing multiple conflicting packages one by one
my @virtual_deps = ();
for my $dep (@dependencies) {
push(@virtual_deps, package_deps( $dep, 1, 1 )) if ( $dep =~ /^virtual/ );
}
for my $dep (@virtual_deps) {
$install_dependencies{$dep} = 0;
}
@dependencies = grep { $install_dependencies{$_} } @dependencies;
#taking only the 4th column of output as key of the hashmap
my %installed_packs =
map { $_ => 1 } @Installed_Packages;
@@ -77,7 +89,7 @@ sub calculate_missing {
# removing from packages the one that are already installed and keeping only the available in the entropy repositories
my @to_install = grep( defined $available_packs{$_},
uniq( grep( !defined $installed_packs{$_}, @Packages ) ) );
uniq( grep( !defined $installed_packs{$_}, @dependencies ) ) );
@to_install=grep { length } @to_install;
say "[$package] packages that will be installed with equo: @to_install" if @to_install>0;