From 1c29cba96423e638457dffe47717773191eca9d4 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sun, 6 Mar 2016 17:35:53 +0000 Subject: [PATCH] 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. --- builder | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/builder b/builder index e788d99..a29e524 100755 --- a/builder +++ b/builder @@ -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;