1 arta 1.6 #!/home/jsoc/bin/linux_x86_64/perl -w
|
2 arta 1.1
3 use strict;
4 use warnings;
5 use Data::Dumper;
6
|
7 arta 1.6 use constant kNContext => 5;
8
|
9 jsoc 1.3 my($TESTERR) = "no";
|
10 arta 1.1 my($JSOC_DEV) = "jsoc_dev\@sun.stanford.edu";
|
11 jsoc 1.3 #my($JSOC_DEV) = "arta\@sun.stanford.edu"; # for testing purposes
|
12 arta 1.2 my($ROOTDIR) = "/tmp/jsoc";
13 my($MAKELOG) = "make.log";
|
14 jsoc 1.3 my($ret);
|
15 jsoc 1.5 my($MAXERRLINES) = 8;
|
16 arta 1.1
|
17 jsoc 1.3 $ENV{'CVSROOT'} = ':ext:sunroom.stanford.edu:/home/cvsuser/cvsroot';
18 $ENV{'CVS_RSH'} = 'ssh';
|
19 arta 1.1 $ENV{'PATH'} .= ':/usr/local/bin';
20
|
21 jsoc 1.3 if ($TESTERR eq "no")
22 {
23 if (-e "$ROOTDIR/JSOC")
24 {
25 `rm -rf "$ROOTDIR/JSOC" 2>&1 1>>/dev/null`;
26 }
|
27 arta 1.1
|
28 jsoc 1.3 `mkdir -p "$ROOTDIR/JSOC" 2>&1 1>>/dev/null`;
|
29 arta 1.1
|
30 arta 1.7 my $cmd = "cd $ROOTDIR; /home/jsoc/dlsource.pl; cd JSOC; ./configure";
|
31 jsoc 1.3 $cmd = join("; ", map {
32 $_." 2>&1 1>>$ROOTDIR/JSOC/cmd.log";
33 } split("; ", $cmd));
|
34 arta 1.1
|
35 jsoc 1.3 $ret = `$cmd; make universe -k >& $ROOTDIR/JSOC/$MAKELOG`;
36 }
37 else
38 {
39 `cd $ROOTDIR/JSOC; make universe -k >& $MAKELOG`;
40 }
|
41 arta 1.1
|
42 arta 1.6 open(FH, "<$ROOTDIR/JSOC/$MAKELOG") || die "Can't open log file: $!\n";
43
44 my(@lines) = <FH>;
45 my($linenum);
46 my($firstidx);
47 my(@errslice);
|
48 arta 1.1 my($errmsg) = "";
|
49 jsoc 1.5 my($date);
|
50 arta 1.6 my($chomped);
|
51 arta 1.1
|
52 arta 1.6 close(FH);
|
53 jsoc 1.5
|
54 arta 1.6 if ($#lines >= 0)
55 {
56 # There was a build error.
57 # Go through each line, looking for recognized error strings
58 $linenum = 0;
59 $firstidx = 0;
60 foreach my $aline (@lines)
61 {
62 $chomped = $aline;
63 chomp($chomped);
64
65 if (RecognizedError($chomped))
66 {
67 # Collect kNContext lines before error
68 if ($linenum - kNContext >= 0)
69 {
70 $firstidx = $linenum - kNContext;
71 }
72
73 @errslice = @lines[$firstidx..$linenum];
74
75 arta 1.6 last;
76 }
77
78 $linenum++;
79 }
80
81 if ($#errslice >= 0)
82 {
83 # We have lines that may indicate an error - look at last few lines to be sure.
84 # make isn't consistent so the last line doesn't always have an error code - it
85 # may appear in earlier lines.
86 my($iline);
87 my($goterror);
88
89 $goterror = 0;
90 $iline = $#lines;
91 while ($iline >= 0 && $#lines - $iline < 4)
92 {
93 if ($lines[$iline] =~ /\*\*\*\s+\[.+\]\s+Error/i)
94 {
95 $goterror = 1;
96 arta 1.6 last;
97 }
98
99 $iline--;
100 }
101
102 if ($goterror)
103 {
104 $linenum = @errslice;
105 $date = `date`;
106 chomp($date);
107 $errmsg = "${errmsg}JSOC Build Failed on ${date}:\n";
108 $linenum++;
109 $errmsg = join('', $errmsg, @errslice);
110
111 if ($linenum >= $MAXERRLINES)
112 {
113 $errmsg = "${errmsg}...\n";
114 }
115 }
116 }
117 arta 1.6
118 if (length($errmsg) > 0)
119 {
120 open FH, "| /usr/bin/Mail -s \"JSOC build problem\" $JSOC_DEV";
121 print FH $errmsg;
122 close FH;
123 }
124 }
125 else
126 {
|
127 arta 1.2 my $cmd = "$ROOTDIR/JSOC/doc/doxygen/gendox.csh";
|
128 arta 1.1 `chmod +x $cmd`;
|
129 arta 1.2 `$cmd >& $ROOTDIR/JSOC/doxygen.log`;
|
130 arta 1.1 create_sl();
131 }
132
|
133 arta 1.6 sub RecognizedError
134 {
135 my($line) = $_[0];
136 my($rv) = 0;
137
138 if ($line =~ /:\s+undefined reference to\s+/ || $line =~ /:\s\S*\serror:\s/i || $line =~ /icc: error/ || $line =~ /:\serror:/)
139 {
140 $rv = 1;
141 }
142
143 return $rv;
144 }
145
|
146 arta 1.1 sub create_sl {
147 my $dir = '/web/jsoc/htdocs/doxygen_html';
148 opendir DH, $dir;
149
150 my $file;
151 while (defined($file = readdir(DH))) {
152 if ($file =~ /-example/) {
153 my $file2 = $file;
154 $file2 =~ s/-example/-source/;
155 my $cmd = "ln -s $dir/$file $dir/$file2";
156 # print $cmd, "\n";
157 `$cmd`;
158 }
159 }
160
161 closedir DH;
162 }
|