]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - modulemanager
Tidy up some of the internals a bit, making things a bit more extensible and future...
[user/henk/code/inspircd.git] / modulemanager
index 18a169f9be72922ea70e09c973daae1a5326016d..4d9cba45694a2057fc9ce725b5d00cb1b28bcebb 100755 (executable)
@@ -137,6 +137,7 @@ sub find_mod_in_range {
 }
 
 sub resolve_deps {
+       my($trial) = @_;
        my $tries = 100;
        my $changes = 'INIT';
        my $fail = undef;
@@ -166,10 +167,13 @@ sub resolve_deps {
                                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;
@@ -198,15 +202,20 @@ if ($action eq 'install') {
                $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