Sort dependencies better: if A dep B then we should NOT list A before

B. Closes: #518145.
This commit is contained in:
Steve McIntyre 2009-04-02 12:19:03 +00:00
parent 4ae970d0de
commit 564d89c966
2 changed files with 27 additions and 2 deletions

2
debian/changelog vendored
View File

@ -12,6 +12,8 @@ debian-cd (3.1.2) UNRELEASED; urgency=low
Closes: #516353
* Add wpasupplicant to tasks/*/forcd1 . Closes: #517298. It's a small
package that should fit easily.
* tools/sort_deps: Sort dependencies better: if A dep B then we should
NOT list A before B. Closes: #518145.
-- Frans Pop <fjp@debian.org> Sun, 15 Feb 2009 23:41:25 +0100

View File

@ -509,12 +509,14 @@ sub add_recommends {
sub get_missing {
my $p = shift;
my @list = ($p);
my @list = ();
if (not add_missing (\@list, $packages{$p}{"Depends"}, $p)) {
return ();
}
remove_entry($p, \@list);
push @list, $p;
return (@list);
}
@ -567,6 +569,8 @@ sub add_missing {
push (@{$list}, $pkg);
if (add_missing ($list, $packages{$pkg}{"Depends"}, $pkg)) {
$or_ok = 1;
remove_entry($pkg, $list);
push @{$list}, $pkg;
last;
} else {
pop @{$list};
@ -579,6 +583,7 @@ sub add_missing {
}
# Else it's a simple dependency
} else {
msg(1, " Looking at adding $_ to satisfy dep\n");
if (not exists $packages{lc $_}) {
msg(1, " $_ doesn't exist...\n");
msg(1, " $pkgin failed, couldn't satisfy dep on $_\n");
@ -594,12 +599,17 @@ sub add_missing {
pop @{$list};
$ok = 0;
}
remove_entry(lc $_, $list);
push @{$list}, lc $_;
}
}
# If a problem has come up, then restore the original list
if (not $ok) {
@{$list} = @backup;
}
if (not is_in(lc $pkgin, $list)) {
push @{$list}, lc $pkgin;
}
return $ok;
}
@ -613,6 +623,19 @@ sub is_in {
return 0;
}
# Remove an antry from @{$array}
sub remove_entry {
my $value = shift;
my $array = shift;
my $i;
foreach $i (0 .. $#$array) {
if (@{$array}[$i] eq $value) {
splice(@{$array}, $i, 1);
}
}
}
# The size of a group of packages
sub get_size {
my $arrayref = shift;