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