2007-04-04 18:31:29 -07:00
|
|
|
##
|
|
|
|
# TinderLogParse - A tinderbox log parser
|
|
|
|
##
|
|
|
|
|
|
|
|
package MozBuild::TinderLogParse;
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $class = shift;
|
|
|
|
my %args = @_;
|
|
|
|
|
|
|
|
my $logFile = $args{'logFile'};
|
|
|
|
if (! defined($logFile)) {
|
|
|
|
die("ASSERT: TinderLogParse::new logFile is a required argument");
|
|
|
|
}
|
|
|
|
|
|
|
|
my $this = { logFile => $logFile };
|
|
|
|
bless($this, $class);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
##
|
|
|
|
# GetBuildID - attempts to find build ID in a tinderbox log file
|
|
|
|
#
|
|
|
|
# Searches for a string of the form:
|
|
|
|
# Got Build ID: 2007030311
|
|
|
|
# Only the buildID, '2007030311', is to be returned.
|
|
|
|
#
|
|
|
|
##
|
|
|
|
|
|
|
|
sub GetBuildID {
|
|
|
|
my $this = shift;
|
|
|
|
my %args = @_;
|
|
|
|
|
|
|
|
my $log = $this->GetLogFileName();
|
|
|
|
|
|
|
|
my $buildID = undef;
|
|
|
|
my $searchString = "Got build ID ";
|
|
|
|
|
|
|
|
open (FILE, "< $log") or die("Cannot open file $log: $!");
|
|
|
|
while (<FILE>) {
|
|
|
|
if ($_ =~ /$searchString/) {
|
|
|
|
$buildID = $_;
|
|
|
|
|
|
|
|
# remove search string
|
|
|
|
$buildID =~ s/$searchString//;
|
|
|
|
|
|
|
|
# remove trailing slash
|
2007-08-14 16:53:34 -07:00
|
|
|
$buildID =~ s/\.$//;
|
2007-04-04 18:31:29 -07:00
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close FILE or die("Cannot close file $log: $!");
|
|
|
|
|
2007-08-14 16:53:34 -07:00
|
|
|
if (! defined($buildID)) {
|
|
|
|
return undef;
|
|
|
|
}
|
|
|
|
if (! $buildID =~ /^\d+$/) {
|
|
|
|
die("ASSERT: Build: build ID is not numerical: $buildID")
|
|
|
|
}
|
|
|
|
|
|
|
|
chomp($buildID);
|
2007-04-04 18:31:29 -07:00
|
|
|
return $buildID;
|
|
|
|
}
|
|
|
|
|
2007-04-24 14:25:05 -07:00
|
|
|
##
|
|
|
|
# GetPushDir - attempts to find the directory Tinderbox pushed to build to
|
|
|
|
#
|
|
|
|
# Searches for a string of the form:
|
|
|
|
# Linux Firefox Build available at:
|
|
|
|
# localhost/2007-04-07-18-firefox2.0.0.4/
|
|
|
|
# Matches on "Build available at:" and returns the next line.
|
|
|
|
##
|
|
|
|
|
|
|
|
sub GetPushDir {
|
|
|
|
my $this = shift;
|
|
|
|
my %args = @_;
|
|
|
|
|
|
|
|
my $log = $this->GetLogFileName();
|
|
|
|
|
|
|
|
my $found = 0;
|
|
|
|
my $pushDir = undef;
|
|
|
|
my $searchString = "Build available at:";
|
|
|
|
|
|
|
|
open (FILE, "< $log") or die("Cannot open file $log: $!");
|
|
|
|
while (<FILE>) {
|
|
|
|
if ($found) {
|
|
|
|
$pushDir = $_;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
if ($_ =~ /$searchString/) {
|
|
|
|
$found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close FILE or die("Cannot close file $log: $!");
|
2007-08-14 16:53:34 -07:00
|
|
|
|
|
|
|
if (! defined($pushDir)) {
|
|
|
|
return undef;
|
|
|
|
}
|
2007-04-24 14:25:05 -07:00
|
|
|
|
2007-07-12 10:47:39 -07:00
|
|
|
chomp($pushDir);
|
2007-08-14 16:53:34 -07:00
|
|
|
# remove empty space at end of URL
|
|
|
|
$pushDir =~ s/\s+$//;
|
2007-07-12 10:47:39 -07:00
|
|
|
|
2007-04-24 14:25:05 -07:00
|
|
|
return $pushDir;
|
|
|
|
}
|
|
|
|
|
2007-04-04 18:31:29 -07:00
|
|
|
sub GetLogFileName {
|
|
|
|
my $this = shift;
|
|
|
|
my %args = @_;
|
|
|
|
|
2007-04-24 14:25:05 -07:00
|
|
|
return $this->{'logFile'};
|
2007-04-04 18:31:29 -07:00
|
|
|
}
|
2007-04-24 14:25:05 -07:00
|
|
|
|
|
|
|
1;
|