}
sub resolve_deps {
+ my($trial) = @_;
my $tries = 100;
my $changes = 'INIT';
my $fail = undef;
my($depmod, $depvers) = ($1,$2);
next unless $todo{$depmod} && ver_in_range($todo{$depmod}, $depvers);
# if there are changes this round, maybe the conflict won't come up after they are resolved.
- $fail ||= "Cannot install: module $mod ($ver) conflicts with versions $depmod version $todo{depmod}";
+ $fail ||= "Cannot install: module $mod ($ver) conflicts with $depmod version $todo{$depmod}";
}
}
}
+ if ($trial) {
+ return !($changes || $fail);
+ }
if ($changes) {
print "Infinite dependency loop:$changes\n";
exit 1;
$todo{$mod} = $ver;
}
} elsif ($action eq 'upgrade') {
- for my $mod (keys %installed) {
+ my @installed = sort keys %installed;
+ for my $mod (@installed) {
next unless $mod =~ /^m_/;
+ my %saved = %todo;
$todo{$mod} = find_mod_in_range($mod);
+ if (!resolve_deps(1)) {
+ %todo = %saved;
+ }
}
} else {
die "Unknown action $action"
}
-resolve_deps();
+resolve_deps(0);
$| = 1; # immediate print of lines without \n