Enable to pull in Recommends recursively

To enable set NORECOMMENDS=0 in the build environment. (Closes: #601203)
This commit is contained in:
Wolfgang Schweer 2019-03-01 11:27:46 +01:00 committed by Holger Levsen
parent 2583350b8d
commit 84878a80ab
1 changed files with 31 additions and 20 deletions

View File

@ -24,7 +24,7 @@ my $extranonfree = read_env('EXTRANONFREE', 0);
my $force_firmware = read_env('FORCE_FIRMWARE', 0);
my $local = read_env('LOCAL', 0);
my $complete = read_env('COMPLETE', 0);
my $norecommends = read_env('NORECOMMENDS', 1);
my $norecommends = (defined $ENV{'NORECOMMENDS'} ? $ENV{'NORECOMMENDS'} : 1);
my $nosuggests = read_env('NOSUGGESTS', 1);
my $verbose = read_env('VERBOSE', 0);
my $max_pkg_size = read_env('MAX_PKG_SIZE', 9999999999999);
@ -87,8 +87,8 @@ msg(1, "Include non-free packages: ");
msg(1, yesno($nonfree)."\n");
msg(1, "Force inclusion of firmware packages: ");
msg(1, yesno($force_firmware)."\n");
msg(1, "Ignore Recommends: ");
msg(1, yesno($norecommends)."\n");
msg(1, "Include Recommends: ");
msg(1, yesno(!$norecommends)."\n");
msg(1, "Ignore Suggests: ");
msg(1, yesno($nosuggests)."\n");
msg(1, "Maximum allowed package size: $max_pkg_size bytes\n");
@ -647,6 +647,7 @@ sub check_versions {
# Check if a specific dependency package is installed already
sub dep_pkg_included {
my $p = shift;
my $add_rec = shift;
my $check_backports = shift;
my %d = %$p;
my $pn = $d{"Package"};
@ -741,16 +742,17 @@ sub fix_backport_depends {
# dependency or any one of an OR array
sub dep_satisfied {
my $p = shift;
my $add_rec = shift;
my $check_backports = shift;
if ("ARRAY" eq ref $p) {
foreach (@{$p}) {
if (dep_pkg_included($_, $check_backports)) {
if (dep_pkg_included($_, $add_rec, $check_backports)) {
return 1;
}
}
} elsif ("HASH" eq ref $p) {
return dep_pkg_included($p, $check_backports);
return dep_pkg_included($p, $add_rec, $check_backports);
} else {
}
return 0;
@ -864,7 +866,7 @@ sub add_package {
}
# Get all dependencies (not yet included) of each package
my (@dep) = (get_missing ($p, $check_backports));
my (@dep) = (get_missing ($p, $add_rec, $check_backports));
# Stop here if apt failed
if (not scalar(@dep)) {
@ -881,7 +883,7 @@ sub add_package {
msg(3, " \@dep before checklist = " . dump_depend(\@dep) . "\n");
# Check if all packages are allowed (fail if one cannot)
($ok, $reasons) = check_list (\@dep, 1, $check_backports);
($ok, $reasons) = check_list (\@dep, 1, $add_rec, $check_backports);
if (not $ok) {
msg(2, "Can't add $p ... one of the packages needed has " .
"been refused. Reasons: $reasons\n");
@ -891,12 +893,11 @@ sub add_package {
msg(3, " \@dep after checklist = " . dump_depend(\@dep) . "\n");
if ($add_rec) {
#TODO: Look for recommends (not yet included !!)
add_recommends (\@dep, $p, $check_backports);
add_recommends (\@dep, $p, $add_rec, $check_backports);
msg(3, " \@dep after add_recommends = " . dump_depend(\@dep) . "\n");
# Check again but doesn't fail if one of the package cannot be
# installed, just ignore it (it will be removed from @dep)
($ok, $reasons) = check_list (\@dep, 0, $check_backports);
($ok, $reasons) = check_list (\@dep, 0, $add_rec, $check_backports);
if (not $ok) {
msg(0, "UNEXPECTED: It shouldn't fail here !\n");
return;
@ -906,11 +907,11 @@ sub add_package {
if ($add_sug) {
#TODO: Look for suggests (not yet included !!)
add_suggests (\@dep, $p, $check_backports);
add_suggests (\@dep, $p, $add_rec, $check_backports);
msg(3, " \@dep after add_suggests = " . dump_depend(\@dep) . "\n");
# Check again but doesn't fail if one of the package cannot be
# installed, just ignore it (it will be removed from @dep)
($ok, $reasons) = check_list (\@dep, 0, $check_backports);
($ok, $reasons) = check_list (\@dep, 0, $add_rec, $check_backports);
if (not $ok) {
msg(0, "UNEXPECTED: It shouldn't fail here !\n");
return;
@ -938,6 +939,7 @@ sub accepted {
sub add_suggests {
my $deps_list = shift;
my $pkg = shift;
my $add_rec = shift;
my $check_backports = shift;
my @parents = ($pkg);
my $p; # = shift;
@ -946,13 +948,14 @@ sub add_suggests {
foreach $p (@copy) {
my %t = %$p;
my $pkgname = $t{"Package"};
add_missing($deps_list, $packages{$pkgname}{"Suggests"}, \%t, 1, \@parents, $check_backports);
add_missing($deps_list, $packages{$pkgname}{"Suggests"}, \%t, 1, \@parents, $add_rec, $check_backports);
}
}
sub add_recommends {
my $deps_list = shift;
my $pkg = shift;
my $add_rec = shift;
my $check_backports = shift;
my @parents = ($pkg);
my $p; # = shift;
@ -961,12 +964,13 @@ sub add_recommends {
foreach $p (@copy) {
my %t = %$p;
my $pkgname = $t{"Package"};
add_missing($deps_list, $packages{$pkgname}{"Recommends"}, \%t, 1, \@parents, $check_backports);
add_missing($deps_list, $packages{$pkgname}{"Recommends"}, \%t, 1, \@parents, $add_rec, $check_backports);
}
}
sub get_missing {
my $p = shift;
my $add_rec = shift;
my $check_backports = shift;
my @deps_list = ();
my @parents = ();
@ -977,7 +981,7 @@ sub get_missing {
$t{"CmpOp"} = "";
$t{"Version"} = "";
if (not add_missing (\@deps_list, $packages{$p}{"Depends"}, \%t, 0, \@parents, $check_backports)) {
if (not add_missing (\@deps_list, $packages{$p}{"Depends"}, \%t, 0, \@parents, $add_rec, $check_backports)) {
return ();
}
@ -998,6 +1002,7 @@ sub add_missing {
my $ok = 1;
my $soft_depend = shift;
my $parents = shift;
my $add_rec = shift;
my $check_backports = shift;
my $pkgname;
my (%pkgin);
@ -1034,7 +1039,7 @@ sub add_missing {
msg(3, " $pkgname Dep: $textout soft_depend $soft_depend\n");
# Bail out early if we can!
if (dep_satisfied ($thisdep, $check_backports)) {
if (dep_satisfied ($thisdep, $add_rec, $check_backports)) {
next;
}
@ -1057,7 +1062,7 @@ sub add_missing {
}
# Already installed?
if (dep_satisfied($pkg, $check_backports)) {
if (dep_satisfied($pkg, $add_rec, $check_backports)) {
msg(3, " OR relationship already installed: " . dump_depend($pkg) . "\n");
$or_ok = 1;
last;
@ -1109,7 +1114,7 @@ sub add_missing {
# added successfully
# FIXME! NEED TO CHECK IF VERSION DEPS ARE SATISFIED, FALL BACK TO BPO VERSION
push (@{$list}, $pkg);
if (add_missing ($list, $packages{$pkgname}{"Depends"}, $pkg, $soft_depend, $parents, $check_backports)) {
if (add_missing ($list, $packages{$pkgname}{"Depends"}, $pkg, $soft_depend, $parents, $add_rec, $check_backports)) {
$or_ok = 1;
remove_entry($pkg, $list);
push @{$list}, $pkg;
@ -1147,7 +1152,7 @@ sub add_missing {
last;
}
}
if (dep_satisfied(\%t, $check_backports)) {
if (dep_satisfied(\%t, $add_rec, $check_backports)) {
msg(1, " $pt already included\n");
next; # Already included, don't worry
}
@ -1156,7 +1161,7 @@ sub add_missing {
next;
}
push @{$list}, \%t;
if (not add_missing ($list, $packages{$t{"Package"}}{"Depends"}, \%t, $soft_depend, $parents, $check_backports)) {
if (not add_missing ($list, $packages{$t{"Package"}}{"Depends"}, \%t, $soft_depend, $parents, $add_rec, $check_backports)) {
my $pkgname = $pkgin{"Package"};
msg(1, "couldn't add $pt ...\n");
if ($soft_depend) {
@ -1167,6 +1172,11 @@ sub add_missing {
pop @{$list};
$ok = 0;
}
} elsif ($add_rec) {
my $reclist = $packages{lc $_}{"Recommends"};
msg(0, "trying to add recommended packages $reclist ...\n");
# depends added successfully, add recommends too
add_missing ($list, $reclist, lc $_, $add_rec);
}
remove_entry(\%t, $list);
push @{$list}, \%t;
@ -1233,6 +1243,7 @@ sub remove_entry {
sub check_list {
my $ref = shift;
my $fail = shift;
my $add_rec = shift;
my $check_backports = shift;
my $ok = 1;
my @to_remove = ();