|
|
@@ -29,8 +29,12 @@ require 5;
|
|
|
$|=1; # autoflush
|
|
|
|
|
|
use strict;
|
|
|
-use vars qw/$opt_R $opt_r $opt_f $opt_u $opt_U $opt_a $opt_A $opt_z $opt_Z $opt_P $opt_N $opt_E $opt_i $opt_D $opt_p $opt_q $opt_s $opt_S $opt_X $opt_M/;
|
|
|
-my $getopts = 'R:r:f:uUaAzZP:N:E:iD:p:qsSXM';
|
|
|
+use vars qw/
|
|
|
+ $opt_R $opt_r $opt_f $opt_u $opt_U $opt_a $opt_A
|
|
|
+ $opt_z $opt_Z $opt_P $opt_N $opt_E $opt_i $opt_D
|
|
|
+ $opt_p $opt_q $opt_s $opt_S $opt_X $opt_M $opt_L
|
|
|
+ $opt_W/;
|
|
|
+my $getopts = 'R:r:f:uUaAzZP:N:E:iD:p:qsSXMLW';
|
|
|
getopts($getopts);
|
|
|
|
|
|
##########################################################################
|
|
|
@@ -116,7 +120,7 @@ sub conditional ($$) {
|
|
|
my($cond,$with) = @_;
|
|
|
my(@s,$res);
|
|
|
|
|
|
- return 1 if $cond eq '';
|
|
|
+ return 1 if $cond eq '' || !defined $with;
|
|
|
|
|
|
foreach (split(/\s+/,$cond)) {
|
|
|
if ($_ eq '+') {
|
|
|
@@ -449,9 +453,8 @@ sub get_installed () {
|
|
|
# compute reverse dependency map
|
|
|
#
|
|
|
#
|
|
|
-sub get_revdep ($) {
|
|
|
- my($env) = @_;
|
|
|
- my($i) = $env->{'installed'};
|
|
|
+sub get_revdep ($$) {
|
|
|
+ my($env, $i) = @_;
|
|
|
my($r) = $env->{'repository'};
|
|
|
my($pkg, %dep, %dlist, %rev);
|
|
|
my(@vers,$t);
|
|
|
@@ -481,8 +484,10 @@ sub get_revdep ($) {
|
|
|
next unless $i->{$t->{name}};
|
|
|
next unless $t->{depends};
|
|
|
foreach (depends2pkglist($t->{depends})) {
|
|
|
- $dep{$_}{$t->{name}} = 1;
|
|
|
- push @{$dlist{$_}}, $t;
|
|
|
+ unless ($dep{$_}{$t->{name}}) {
|
|
|
+ $dep{$_}{$t->{name}} = 1;
|
|
|
+ push @{$dlist{$_}}, $t;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1389,7 +1394,7 @@ sub make_dep ($$$$$$$) {
|
|
|
$target->{REBUILD}) {
|
|
|
|
|
|
unless ($env->{revdep}) {
|
|
|
- $env->{revdep} = get_revdep($env);
|
|
|
+ $env->{revdep} = get_revdep($env, $env->{intalled});
|
|
|
}
|
|
|
|
|
|
foreach $t (@{$env->{revdep}->{$target->{name}}}) {
|
|
|
@@ -1407,15 +1412,11 @@ sub make_dep ($$$$$$$) {
|
|
|
}
|
|
|
|
|
|
#
|
|
|
-# generate build lists for targets matched by pattern
|
|
|
+# grep environment for packages that match a pattern
|
|
|
#
|
|
|
-# all input and output is passed in 'env' hash
|
|
|
-#
|
|
|
-sub build_list ($$) {
|
|
|
+sub search_pattern ($$) {
|
|
|
my($pattern, $env) = @_;
|
|
|
- my(@goals,@targets,@keeps,@conflicts,@bonly,$t);
|
|
|
- my($name,$r,$i,@vers);
|
|
|
- my(@todo,%keep);
|
|
|
+ my(@todo);
|
|
|
|
|
|
#
|
|
|
# handle various patterns
|
|
|
@@ -1446,10 +1447,26 @@ sub build_list ($$) {
|
|
|
} keys %{$env->{repository}};
|
|
|
}
|
|
|
|
|
|
+ return \@todo;
|
|
|
+}
|
|
|
+
|
|
|
+#
|
|
|
+# generate build lists for targets matched by pattern
|
|
|
+#
|
|
|
+# all input and output is passed in 'env' hash
|
|
|
+#
|
|
|
+sub build_list ($$) {
|
|
|
+ my($pattern, $env) = @_;
|
|
|
+ my(@goals,@targets,@keeps,@conflicts,@bonly,$t);
|
|
|
+ my($name,$r,$i,@vers);
|
|
|
+ my($todo,%keep);
|
|
|
+
|
|
|
+ $todo = search_pattern($pattern, $env);
|
|
|
+
|
|
|
#
|
|
|
# chose sources for goals from repository
|
|
|
#
|
|
|
- foreach $name (@todo) {
|
|
|
+ foreach $name (@$todo) {
|
|
|
$t = undef;
|
|
|
|
|
|
#
|
|
|
@@ -1502,6 +1519,21 @@ sub build_list ($$) {
|
|
|
return (\@targets, \@bonly, \@conflicts);
|
|
|
}
|
|
|
|
|
|
+sub build_deps ($$) {
|
|
|
+ my($pattern, $env) = @_;
|
|
|
+ my($todo);
|
|
|
+
|
|
|
+ $todo = search_pattern($pattern, $env);
|
|
|
+
|
|
|
+ $env->{revdep} = get_revdep($env, $env->{repository});
|
|
|
+
|
|
|
+ return [ map {
|
|
|
+ $env->{revdep}->{$_}
|
|
|
+ ? ( @{$env->{revdep}->{$_}} )
|
|
|
+ : ( )
|
|
|
+ } @$todo ];
|
|
|
+}
|
|
|
+
|
|
|
#######################################################################
|
|
|
|
|
|
#
|
|
|
@@ -1765,6 +1797,17 @@ sub print_map ($$$$$) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#
|
|
|
+# print dependency list
|
|
|
+#
|
|
|
+sub print_deps ($) {
|
|
|
+ my($list) = @_;
|
|
|
+
|
|
|
+ foreach (@$list) {
|
|
|
+ print vsn($_),"\n";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#######################################################################
|
|
|
|
|
|
my($config,$url,$repository,$installed,$env,$list,$bonly,$clist);
|
|
|
@@ -1809,7 +1852,11 @@ if (defined $opt_f && !defined $opt_r) {
|
|
|
}
|
|
|
|
|
|
$installed = $opt_Z ? {} : get_installed();
|
|
|
-$repository = get_index($url.'00INDEX.rdf',$opt_f,\%with,$opt_X);
|
|
|
+$repository = get_index(
|
|
|
+ $url.'00INDEX.rdf',
|
|
|
+ $opt_f,
|
|
|
+ ($opt_W ? undef : \%with),
|
|
|
+ $opt_X);
|
|
|
|
|
|
$env = {
|
|
|
config => $config,
|
|
|
@@ -1831,23 +1878,28 @@ $env = {
|
|
|
scalar(%with) > 0 )
|
|
|
};
|
|
|
|
|
|
-($list,$bonly,$clist) = build_list($pattern, $env);
|
|
|
-die "FATAL: cannot find package\n" unless defined $list;
|
|
|
-
|
|
|
-if ($opt_M) {
|
|
|
- print_map($installed,$repository,$list,$bonly,$clist);
|
|
|
-} elsif ($opt_S) {
|
|
|
- print_status($installed,$repository,$list,$bonly,$clist);
|
|
|
-} elsif ($opt_s) {
|
|
|
- print_status($installed,{},$list,$bonly,$clist);
|
|
|
+if ($opt_L) {
|
|
|
+ ($list) = build_deps($pattern, $env);
|
|
|
+ print_deps($list);
|
|
|
} else {
|
|
|
- if (@{$env->{fatal}}) {
|
|
|
- die "FATAL errors occured while building:\n",
|
|
|
- join (',', @{$env->{fatal}}),
|
|
|
- "\n";
|
|
|
- }
|
|
|
+ ($list,$bonly,$clist) = build_list($pattern, $env);
|
|
|
+ die "FATAL: cannot find package\n" unless defined $list;
|
|
|
+
|
|
|
+ if ($opt_M) {
|
|
|
+ print_map($installed,$repository,$list,$bonly,$clist);
|
|
|
+ } elsif ($opt_S) {
|
|
|
+ print_status($installed,$repository,$list,$bonly,$clist);
|
|
|
+ } elsif ($opt_s) {
|
|
|
+ print_status($installed,{},$list,$bonly,$clist);
|
|
|
+ } else {
|
|
|
+ if (@{$env->{fatal}}) {
|
|
|
+ die "FATAL errors occured while building:\n",
|
|
|
+ join (',', @{$env->{fatal}}),
|
|
|
+ "\n";
|
|
|
+ }
|
|
|
|
|
|
- print_list1($list,$config,$opt_a || $opt_u || $opt_U,\%with,$opt_i);
|
|
|
- print_list2($bonly,$config);
|
|
|
+ print_list1($list,$config,$opt_a || $opt_u || $opt_U,\%with,$opt_i);
|
|
|
+ print_list2($bonly,$config);
|
|
|
+ }
|
|
|
}
|
|
|
|