| 1 |
package AllPkg; |
| 2 |
use warnings; |
| 3 |
use strict; |
| 4 |
use integer; |
| 5 |
use DebSrcBin; |
| 6 |
use AllProv; |
| 7 |
use AllSrc; |
| 8 |
use AllBin; |
| 9 |
|
| 10 |
# Warning threshold: |
| 11 |
# 100 to disable the stdout progress messages entirely; |
| 12 |
# 50 for typical use; |
| 13 |
# 0 for pedantic messages or debugging. |
| 14 |
our $wth = 50; |
| 15 |
|
| 16 |
our %relationship_string = ( |
| 17 |
'xPre-Depends' => 'pre-depends on', |
| 18 |
'xDepends' => 'depends on', |
| 19 |
'xRecommends' => 'recommends', |
| 20 |
'xSuggests' => 'suggests', |
| 21 |
'renh' => 'is enhanced by', |
| 22 |
'xBuild-Depends' => 'build-depends on', |
| 23 |
'xBuild-Depends-Indep' => 'build-depends for indep on', |
| 24 |
'xConflicts' => 'conflicts against', |
| 25 |
'xReplaces' => 'replaces', |
| 26 |
'xBuild-Conflicts' => 'build-conflicts against', |
| 27 |
'xBuild-Conflicts-Indep'=> 'build-conflicts for indep against', |
| 28 |
); |
| 29 |
|
| 30 |
# Verbosity: |
| 31 |
# 60 - Print even trivial pnames. |
| 32 |
# 50 - Omit trivial pnames. |
| 33 |
# 30 - Omit all pnames. |
| 34 |
our $verbosity = 50; |
| 35 |
|
| 36 |
# Instantiate and initialize. |
| 37 |
sub new { |
| 38 |
|
| 39 |
# Instantiate. |
| 40 |
my $class = shift; |
| 41 |
my( $src_filename, $bin_filename ) = @_; |
| 42 |
warn "reading files:\n" if $wth <= 70; |
| 43 |
warn " Sources...\n" if $wth <= 60; |
| 44 |
my $src = AllSrc->new( $src_filename ); |
| 45 |
warn " Packages...\n" if $wth <= 60; |
| 46 |
my $bin = AllBin->new( $bin_filename ); |
| 47 |
my $self = { src => $src, bin => $bin }; |
| 48 |
bless $self, $class; |
| 49 |
|
| 50 |
# Build out. |
| 51 |
warn "building the data structures out:\n" if $wth <= 70; |
| 52 |
warn " referencing build-deps by binary...\n" if $wth <= 50; |
| 53 |
$bin->add_build_dep( $src ); |
| 54 |
warn " referring sources to their binaries...\n" if $wth <= 50; |
| 55 |
$src->refer_to_bin ( $bin ); |
| 56 |
warn " hashing package provisions...\n" if $wth <= 60; |
| 57 |
my $prov = AllProv->new( $bin ); |
| 58 |
$self->{prov} = $prov; |
| 59 |
warn " reversing package enhancements...\n" if $wth <= 50; |
| 60 |
$bin->reverse_enhance(); |
| 61 |
warn "done initializing\n" if $wth <= 65; |
| 62 |
|
| 63 |
return $self; |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
sub check { |
| 68 |
my( $self, $levels, $sel ) = @_; |
| 69 |
$self->{bin}->are_selections_consistent( $levels, $sel ); |
| 70 |
} |
| 71 |
|
| 72 |
# Transform error hashes into outputtable error strings. |
| 73 |
sub errstr { |
| 74 |
|
| 75 |
my $self = shift; |
| 76 |
my $sel = shift; |
| 77 |
map { |
| 78 |
|
| 79 |
# Here is a single error hash, including the pname whose dependency |
| 80 |
# is not satisfied, the relationship (Recommends, Conflicts, etc) |
| 81 |
# unsatisfied, and the altern which fails the test. |
| 82 |
# |
| 83 |
# The local flags $any_passes and $any_fails refer not to the larger |
| 84 |
# test outside this local loop, but rather to the $$xpname relevance |
| 85 |
# test by &AllProv::pnames_provided within the loop. |
| 86 |
# |
| 87 |
my $any_passes = 0; |
| 88 |
my $any_fails = 0; |
| 89 |
my $pname1 = $_->{pname }; |
| 90 |
my $altern1 = $_->{altern }; |
| 91 |
my $relat1 = $_->{relationship}; |
| 92 |
my $rel_str1 = $relationship_string{$relat1}; |
| 93 |
my $is_cfl = $AllBin::dep_cfl {$relat1}; |
| 94 |
my $test_xpname = $is_cfl; |
| 95 |
my $test_xsel = defined($sel) && $is_cfl; |
| 96 |
my $line = "$pname1 $rel_str1 " . join( |
| 97 |
' | ', map { |
| 98 |
|
| 99 |
# Here is a single alternative from the altern. |
| 100 |
my $xpname = $pname1; |
| 101 |
my $xsel = $sel ; |
| 102 |
my $xpname_ref = $test_xpname ? \$xpname : undef; |
| 103 |
my $xsel_ref = $test_xsel ? \$xsel : undef; |
| 104 |
my $vname_str = |
| 105 |
$_->{vname} |
| 106 |
. ( $_->{ver} ? ( " ($_->{rel} $_->{ver})" ) : '' ) |
| 107 |
. ( |
| 108 |
$verbosity >= 40 |
| 109 |
? $self->{prov}->pnames_provided_str( |
| 110 |
$_->{vname}, $_->{rel}, $_->{ver}, |
| 111 |
$verbosity < 60, $xpname_ref, $xsel_ref |
| 112 |
) |
| 113 |
: '' |
| 114 |
); |
| 115 |
if ( |
| 116 |
( !$test_xpname || defined($xpname) ) && |
| 117 |
( !$test_xsel || defined($xsel ) ) |
| 118 |
) { $any_passes = 1 } |
| 119 |
else { $any_fails = 1 } |
| 120 |
$vname_str; |
| 121 |
|
| 122 |
} @$altern1 |
| 123 |
) . "\n"; |
| 124 |
!$any_passes && $any_fails ? () : ( $line ); |
| 125 |
|
| 126 |
} @_; |
| 127 |
|
| 128 |
} |
| 129 |
|
| 130 |
# Perform a complete analysis. Return a complete discrepancy report. |
| 131 |
sub analyze_and_report { |
| 132 |
my( $self, $levels, $sel ) = @_; |
| 133 |
$self->errstr( |
| 134 |
( defined($sel) ? $sel : $DebSrcBin::select_up_default ), |
| 135 |
$self->check( $levels, $sel ) |
| 136 |
); |
| 137 |
} |
| 138 |
|
| 139 |
sub select_by_pri { |
| 140 |
my $self = shift; |
| 141 |
$self->{bin}->select_by_pri( @_ ); |
| 142 |
} |
| 143 |
|
| 144 |
1; |
| 145 |
|