Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c05cdce52 | |||
| a55856cb97 | |||
| 967cd9708a |
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
|
use v5.10;
|
||||||
|
|
||||||
my $profile = $ENV{BUILDER_PROFILE} // 3;
|
my $profile = $ENV{BUILDER_PROFILE} // 3;
|
||||||
my $jobs = $ENV{BUILDER_JOBS} // 1;
|
my $jobs = $ENV{BUILDER_JOBS} // 1;
|
||||||
@@ -42,9 +43,30 @@ sub package_deps {
|
|||||||
my $package = shift;
|
my $package = shift;
|
||||||
my $depth = shift // 1; # defaults to 1 level of depthness of the tree
|
my $depth = shift // 1; # defaults to 1 level of depthness of the tree
|
||||||
my $atom = shift // 0;
|
my $atom = shift // 0;
|
||||||
return
|
|
||||||
map { $_ =~ s/\[.*\]|\s//g; &atom($_) if $atom; $_ }
|
# Since we expect this sub to be called multiple times with the same arguments, cache the results
|
||||||
qx/equery -C -q g --depth=$depth $package/; #depth=0 it's all
|
state %cache;
|
||||||
|
$cache_key = "${package}:${depth}:${atom}";
|
||||||
|
|
||||||
|
if ( ! exists $cache{$cache_key} ) {
|
||||||
|
@dependencies = qx/equery -C -q g --depth=$depth $package/; #depth=0 it's all
|
||||||
|
chomp @dependencies;
|
||||||
|
|
||||||
|
# If an unversioned atom is given, equery returns results for all versions in the portage tree
|
||||||
|
# leading to duplicates. The sanest thing to do is dedup the list. This gives the superset of all
|
||||||
|
# possible dependencies, which isn't perfectly accurate but should be good enough. For completely
|
||||||
|
# accurate results, pass in a versioned atom.
|
||||||
|
@dependencies =
|
||||||
|
uniq
|
||||||
|
sort
|
||||||
|
grep { $_ }
|
||||||
|
map { $_ =~ s/\[.*\]|\s//g; &atom($_) if $atom; $_ }
|
||||||
|
@dependencies;
|
||||||
|
|
||||||
|
$cache{$cache_key} = \@dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
return @{ $cache{$cache_key} };
|
||||||
}
|
}
|
||||||
|
|
||||||
#Input: nothing
|
#Input: nothing
|
||||||
@@ -71,18 +93,17 @@ sub calculate_missing {
|
|||||||
say "[$package] Getting the package dependencies and the installed packages";
|
say "[$package] Getting the package dependencies and the installed packages";
|
||||||
my @dependencies = package_deps( $package, $depth, 1 );
|
my @dependencies = package_deps( $package, $depth, 1 );
|
||||||
|
|
||||||
# XXX: Endless loop as for now.
|
my %install_dependencies = map { $_ => 1 } @dependencies;
|
||||||
# my %install_dependencies = map { $_ => 1 } @dependencies;
|
# Look for any virtuals and remove its immediate dependencies to avoid
|
||||||
# # Look for any virtuals and remove its immediate dependencies to avoid
|
# installing multiple conflicting packages one by one
|
||||||
# # installing multiple conflicting packages one by one
|
my @virtual_deps;
|
||||||
# my @virtual_deps;
|
for my $dep (@dependencies) {
|
||||||
# for my $dep (@dependencies) {
|
push(@virtual_deps, package_deps( $dep, 1, 1 )) if ( $dep =~ /^virtual\// );
|
||||||
# push(@virtual_deps, package_deps( $dep, 1, 1 )) if ( $dep =~ /^virtual\// );
|
}
|
||||||
# }
|
for my $dep (@virtual_deps) {
|
||||||
# for my $dep (@virtual_deps) {
|
$install_dependencies{$dep} = 0 if ( $dep !~ /^virtual\// );
|
||||||
# $install_dependencies{$dep} = 0 if ( $dep !~ /^virtual\// );
|
}
|
||||||
# }
|
@dependencies = grep { $install_dependencies{$_} } @dependencies;
|
||||||
# @dependencies = grep { $install_dependencies{$_} } @dependencies;
|
|
||||||
|
|
||||||
#taking only the 4th column of output as key of the hashmap
|
#taking only the 4th column of output as key of the hashmap
|
||||||
my %installed_packs =
|
my %installed_packs =
|
||||||
@@ -93,7 +114,7 @@ sub calculate_missing {
|
|||||||
my @to_install = grep( defined $available_packs{$_},
|
my @to_install = grep( defined $available_packs{$_},
|
||||||
uniq( grep( !defined $installed_packs{$_}, @dependencies ) ) );
|
uniq( grep( !defined $installed_packs{$_}, @dependencies ) ) );
|
||||||
@to_install=grep { length } @to_install;
|
@to_install=grep { length } @to_install;
|
||||||
# say "[$package] packages that will be installed with equo: @to_install" if @to_install>0;
|
say "[$package] packages that will be installed with equo: @to_install" if @to_install>0;
|
||||||
|
|
||||||
return @to_install;
|
return @to_install;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user