]> git.donarmstrong.com Git - wannabuild.git/blob - bin/wb-edos-builddebcheck
use ~/.wanna-build.yaml if it exists
[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 # check that all stanzas in the binary package file have the same
47 # architecture.
48 $packagearch="";
49 open(P,$packagefile);
50 while (<P>) {
51     next unless /^Architecture/;
52     next if /^Architecture:\s*all/;
53     /Architecture:\s*([^\s]*)/;
54     if ($packagearch eq "") {
55         $packagearch = $1;
56     } elsif ( $packagearch ne $1) {
57         die "Package file contains different architectures: $packagearch, $1";
58     }
59 }
60 close P;
61
62 if ( $architecture eq "" ) {
63     if ( $packagearch eq "" ) {
64         die "No architecture option given, " .
65             "and no non-all architecture found in the Packages file";
66     } else {
67         $architecture = $packagearch;
68     }
69 } else {
70     if ( $packagearch ne "" & $architecture ne $packagearch) {
71         die "Architecture option is $architecture ".
72             "but the package file contains architecture $packagearch";
73     }
74 }
75
76 open(RESULT,"python /usr/share/edos-distcheck/add-sources.py ".
77      "--prefix \"$sourceprefix\" < $packagefile $sourcesfile $architecture ".
78      "| edos-debcheck $edosoptions|");
79
80 $sourcestanza=0;
81 $explanation="";
82 $binpackage="";
83
84 while (<RESULT>) {
85     if (/^\s+/) {
86         if ($sourcestanza) {
87             s/^(\s*)$sourceprefix(.*)depends on/$1$2build-depends on/o;
88             s/^(\s*)$sourceprefix(.*) and (.*) conflict/$1$2 build-conflicts with $3/o;
89             print;
90             if (/depends on ([^\s]*) .*\{.*\}/) {
91                 push(@binqueue,$1);
92             }
93         } else {
94             $explanation .= $_;
95         }
96     } else {
97         if ($sourcestanza) {
98             print "\n";
99             $sourcestanza=0;
100         }
101         if ($binpackage ne ""){
102             $binfailures{$binpackage} = $explanation;
103             $binpackage="";
104         }
105         if (/^$sourceprefix(.*) \(.*\): FAILED/o) {
106             print "Package: $1\n";
107             print "Failed-Why:\n";
108             $sourcestanza=1;
109         } elsif (/^([^\s]*) .*: FAILED/) {
110             $binpackage=$1;
111             $explanation=$_;
112             $explanation.=<RESULT>;
113             $sourcestanza=0;
114         } else {
115             # we have someting strange here
116             $sourcestanza=0;
117         }
118     }
119 }
120
121 close RESULT;
122
123 if ($binexplain) {
124     while (@binqueue) {
125         $p=pop(@binqueue);
126         $v=$binfailures{$p};
127         next unless defined $v;
128         $binfailures{$p}="";
129         print "$v" if $v ne "";
130         if ($v=~/depends on ([^\s]*) .*\{.*\}/) {
131             push(@binqueue,$1);
132         }
133     }
134 }
135