]> git.donarmstrong.com Git - wannabuild.git/blob - bin/edos-builddebcheck
edos-builddebcheck
[wannabuild.git] / bin / 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";
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,"python /usr/share/edos-distcheck/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             print;
87             if (/depends on ([^\s]*) .*\{.*\}/) {
88                 push(@binqueue,$1);
89             }
90         } else {
91             $explanation .= $_;
92         }
93     } else {
94         if ($binpackage ne ""){
95             $binfailures{$binpackage} = $explanation;
96             $binpackage="";
97         }
98         if (/^$sourceprefix.*: FAILED/o) {
99             s/^$sourceprefix//o;
100             print;
101             
102             $_=<RESULT>;
103             print;
104             
105             $sourcestanza=1;
106         } elsif (/^([^\s]*) .*: FAILED/) {
107             $binpackage=$1;
108             $explanation=$_;
109             $explanation.=<RESULT>;
110             $sourcestanza=0;
111         } else {
112             # we have someting strange here
113             $sourcestanza=0;
114         }
115     }
116 }
117
118 close RESULT;
119
120 if ($binexplain) {
121     while (@binqueue) {
122         $p=pop(@binqueue);
123         $v=$binfailures{$p};
124         next unless defined $v;
125         $binfailures{$p}="";
126         print "$v" if $v ne "";
127         if ($v=~/depends on ([^\s]*) .*\{.*\}/) {
128             push(@binqueue,$1);
129         }
130     }
131 }
132