]> git.donarmstrong.com Git - wannabuild.git/blob - bin/wb-edos-builddebcheck
List BD-Uninstallable in wanna-build-statistics
[wannabuild.git] / bin / wb-edos-builddebcheck
1 #!/usr/bin/perl -w
2
3 # Copyright (C) 2008 Ralf Treinen <treinen@debian.org>
4 # This program is free software: you can redistribute it and/or modify it under
5 # the terms of the GNU General Public License as published by the Free Software
6 # Foundation, version 2 of the License.
7
8 $debug=0;
9
10 # the prefix used to encode source packages
11 $sourceprefix="source---";
12
13 $architecture="";
14 $binexplain=0;
15 $edosoptions = "-failures -explain -quiet";
16 while ( $arg = shift @ARGV ) {
17     if ( $arg eq '-a' || $arg eq '--architecture' ) {
18         if ($#ARGV == -1) {
19             die "-a option needs a value";
20         } else {
21             $architecture = shift @ARGV;
22         }
23     } elsif ( $arg =~ "--binexplain" || $arg =~ "-be" ) {
24         $binexplain = 1;
25     } elsif ( $arg =~ /^-.*/ ) {
26         die "unrecognized option: $arg";
27     } else {
28         last;
29     }
30 }
31
32 if ($#ARGV != 0) {
33     die "Usage: edos-debbuildcheck [options] Packages Sources"
34 } else {
35     $packagefile = $arg;
36     $sourcesfile = shift(@ARGV);
37 }
38
39 if ($debug) {
40     print "Arch: $architecture\n";
41     print "Packages: $packagefile\n";
42     print "Sources:  $sourcesfile\n";
43     print "Edos options: $edosoptions\n";
44 }
45
46 $packagearch="";
47 open(P,$packagefile);
48 while (<P>) {
49     next unless /^Architecture/;
50     next if /^Architecture:\s*all/;
51     /Architecture:\s*([^\s]*)/;
52     if ($packagearch eq "") {
53         $packagearch = $1;
54     } elsif ( $packagearch ne $1) {
55         die "Package file contains different architectures: $packagearch, $1";
56     }
57 }
58 close P;
59
60 if ( $architecture eq "" ) {
61     if ( $packagearch eq "" ) {
62         die "No architecture option given, " .
63             "and no non-all architecture found in the Packages file";
64     } else {
65         $architecture = $packagearch;
66     }
67 } else {
68     if ( $packagearch ne "" & $architecture ne $packagearch) {
69         die "Architecture option is $architecture ".
70             "but the package file contains architecture $packagearch";
71     }
72 }
73
74 open(RESULT,"add-sources.py ".
75      "--prefix \"$sourceprefix\" < $packagefile $sourcesfile $architecture ".
76      "| edos-debcheck $edosoptions|");
77
78 $sourcestanza=0;
79 $explanation="";
80 $binpackage="";
81
82 while (<RESULT>) {
83     if (/^\s+/) {
84         if ($sourcestanza) {
85             s/^(\s*)$sourceprefix(.*)(depends on|conflicts with)/$1$2build-$3/o;
86             s/&gt;/>/;
87             s/&lt;/</;
88             print;
89             if (/depends on ([^\s]*) .*\{.*\}/) {
90                 push(@binqueue,$1);
91             }
92         } else {
93             $explanation .= $_;
94         }
95     } else {
96         if ($sourcestanza) {
97             print "\n";
98             $sourcestanza=0;
99         }
100         if ($binpackage ne ""){
101             $binfailures{$binpackage} = $explanation;
102             $binpackage="";
103         }
104         if (/^$sourceprefix(.*) \(.*\): FAILED/o) {
105             print "Package: $1\n";
106             print "Failed-Why:\n";
107             $sourcestanza=1;
108         } elsif (/^([^\s]*) .*: FAILED/) {
109             $binpackage=$1;
110             $explanation=$_;
111             $explanation.=<RESULT>;
112             $sourcestanza=0;
113         } else {
114             # we have someting strange here
115             $sourcestanza=0;
116         }
117     }
118 }
119
120 close RESULT;
121
122 if ($binexplain) {
123     while (@binqueue) {
124         $p=pop(@binqueue);
125         $v=$binfailures{$p};
126         next unless defined $v;
127         $binfailures{$p}="";
128         print "$v" if $v ne "";
129         if ($v=~/depends on ([^\s]*) .*\{.*\}/) {
130             push(@binqueue,$1);
131         }
132     }
133 }
134