Remove dead code in sort_deps and improve log messages

The dependency tree created by parsing the output of "apt-cache depends" always
generates an array of array. The old representation of a simple dependency as
an hash is gone in favor of an OR with a single entry (so the hash is the only
element within the array).

So all the code in add_missing() that was dealing with the case of the hash
was never triggered.

I tweaked the OR case so that the generated log messages actually
mention "OR" only if it's a true OR dependency (i.e. with multiple
entries in the array).
This commit is contained in:
Raphaël Hertzog 2022-08-09 19:38:06 +02:00
parent ca9ac8deac
commit e77ade6033
2 changed files with 90 additions and 145 deletions

1
debian/changelog vendored
View File

@ -19,6 +19,7 @@ debian-cd (3.1.36) UNRELEASED; urgency=medium
* Fix install_firmwares_initrd to not fail when the firmware is not found.
* Implement recursive lookup of Recommends and Suggests in sort_deps.
Closes: #601203
* Remove dead code in sort_deps and improve generated log messages
[ Wolfgang Schweer ]
* data/bookworm: Use Debian Edu 12 installer logo and syslinux splash image

View File

@ -978,11 +978,16 @@ sub add_missing {
# Check all dependencies
foreach my $thisdep (@{$new}) {
my $textout = "";
my $type_rel = "simple";
if ("ARRAY" ne ref($thisdep)) {
die "add_missing: $thisdep should be an array!\n";
}
# Print out status
if ("ARRAY" eq ref($thisdep)) {
if (scalar(@{$thisdep} > 1)) {
$textout = "(OR ";
$type_rel = "OR";
}
foreach my $orpkg (@{$thisdep}) {
$textout .= dump_depend($orpkg) . " ";
@ -990,11 +995,6 @@ sub add_missing {
if (scalar(@{$thisdep} > 1)) {
$textout .= ")";
}
} elsif ("HASH" eq ref($thisdep)) {
$textout = dump_depend($thisdep);
} else {
die "add_missing: $thisdep should be an array or hash!\n";
}
msg(3, " $pkgname Dep: $textout soft_depend $soft_depend\n");
# Bail out early if we can!
@ -1003,8 +1003,6 @@ sub add_missing {
}
# Still work to do...
# If it's an OR
if ("ARRAY" eq ref($thisdep)) {
my $or_ok = 0;
# First check all the OR packages up-front with no
@ -1022,7 +1020,7 @@ sub add_missing {
# Already installed?
if (dep_satisfied($pkg, $check_backports, $need_udeb)) {
msg(3, " OR relationship already installed: " . dump_depend($pkg) . "\n");
msg(3, " $type_rel relationship already installed: " . dump_depend($pkg) . "\n");
$or_ok = 1;
last;
}
@ -1031,7 +1029,7 @@ sub add_missing {
# depth-first search? (yes, we have to cope with
# circular dependencies here...)
if (is_in_dep_list($pkg, $list, $soft_depend)) {
msg(3, " OR relationship already satisfied by current list " . dump_depend($pkg) . "\n");
msg(3, " $type_rel relationship already satisfied by current list " . dump_depend($pkg) . "\n");
$or_ok = 1;
last;
}
@ -1048,7 +1046,7 @@ sub add_missing {
# available should be good enough for all cases we care
# about.
if (not $or_ok) {
msg(3, " OR relationship not already satisfied, looking at alternatives in order, check_backports $check_backports\n");
msg(3, " $type_rel relationship not already satisfied, looking at alternatives in order, check_backports $check_backports\n");
foreach my $pkg (@{$thisdep}) {
my %t = %$pkg;
@ -1061,12 +1059,7 @@ sub add_missing {
next;
}
}
# Check we don't already have the package
if (is_in_dep_list($pkg, $list, $soft_depend)) {
$or_ok = 1;
last;
# Otherwise try to add it
} else {
# Stop after the first
# package that is
# added successfully
@ -1088,65 +1081,16 @@ sub add_missing {
}
}
}
}
$ok &&= $or_ok;
if (not $ok) {
$pkgname = $pkgin{"Package"};
if ($soft_depend) {
msg(1, " $pkgname failed, couldn't satisfy OR dep (but it's a soft dep, so ignoring...)\n");
msg(1, " $pkgname failed, couldn't satisfy $type_rel dep (but it's a soft dep, so ignoring...)\n");
$ok = 1;
} else {
msg(1, " $pkgname failed, couldn't satisfy OR dep\n");
msg(1, " $pkgname failed, couldn't satisfy $type_rel dep\n");
}
}
# Else it's a simple dependency
} else {
my %t = %{$thisdep};
my $pt = dump_depend(\%t);
msg(1, " Looking at adding $pt to satisfy dep\n");
if (not exists $packages{lc $t{"Package"}}) {
msg(1, " $pt doesn't exist...\n");
if ($soft_depend) {
msg(1, " soft dep: $pkgname ok, despite missing dep on $pt\n");
$ok = 1;
} else {
msg(1, " $pkgname failed, couldn't satisfy dep on $pt\n");
$ok = 0;
last;
}
}
if (dep_satisfied(\%t, $check_backports, $need_udeb)) {
msg(1, " $pt already included\n");
next; # Already included, don't worry
}
if (is_in_dep_list(\%t, $list, $soft_depend)) {
msg(1, " $pt already in dep list\n");
next;
}
push @{$list}, \%t;
if (not add_missing ($list, $packages{$t{"Package"}}{"Depends"}, \%t, $soft_depend, $check_backports)) {
my $pkgname = $pkgin{"Package"};
msg(1, "couldn't add $pt ...\n");
if ($soft_depend) {
msg(1, "soft dep: $pkgname ok, despite missing dep on $pt\n");
$ok = 1;
} else {
msg(1, "$pkgname failed, couldn't satisfy dep on $pt\n");
pop @{$list};
$ok = 0;
}
} else {
if ($add_rec) {
add_missing ($list, $packages{$t{"Package"}}{"Recommends"}, \%t, 1, $check_backports);
}
if ($add_sug) {
add_missing ($list, $packages{$t{"Package"}}{"Suggests"}, \%t, 1, $check_backports);
}
}
remove_entry(\%t, $list);
push @{$list}, \%t;
}
}
# If a problem has come up, then restore the original list
if (not $ok) {