2001-11-02 08:22:00 +03:00
|
|
|
#! /usr/bonsaitools/bin/perl
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public License
|
|
|
|
# Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
# compliance with the License. You may obtain a copy of the License at
|
|
|
|
# http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS IS"
|
|
|
|
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing rights and limitations
|
|
|
|
# under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is Tinderbox
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are Copyright (C) 1999
|
|
|
|
# Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Chris McAfee <mcafee@netscape.com>
|
|
|
|
|
|
|
|
#
|
|
|
|
# scrape.pl - Process log-scraped data into scrape.dat
|
|
|
|
# Write data to $tree/scrape.dat in the following format,
|
|
|
|
#
|
|
|
|
# <logfilename>|blurb1|blurb2|blurb3 ...
|
|
|
|
#
|
|
|
|
|
|
|
|
sub usage {
|
|
|
|
warn "./scrape.pl <tree> <logfile>";
|
|
|
|
}
|
|
|
|
|
|
|
|
use FileHandle;
|
|
|
|
|
|
|
|
# This is for gunzip (Should add a configure script to handle this).
|
|
|
|
$ENV{PATH} .= ":/usr/local/bin";
|
|
|
|
|
|
|
|
unless ($#ARGV == 1) {
|
|
|
|
&usage;
|
|
|
|
die "Error: Wrong number of arguments\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
($tree, $logfile) = @ARGV;
|
|
|
|
|
|
|
|
die "Error: No tree named $tree" unless -r "$tree/treedata.pl";
|
|
|
|
require "$tree/treedata.pl";
|
|
|
|
|
|
|
|
# Seach the build log for the scrape data
|
|
|
|
#
|
2001-11-02 12:37:35 +03:00
|
|
|
$fh = new FileHandle "gunzip -c $tree/$logfile |"
|
2001-11-02 08:22:00 +03:00
|
|
|
or die "Unable to open $tree/$logfile\n";
|
|
|
|
@scrape_data = find_scrape_data($fh);
|
2001-11-02 12:37:35 +03:00
|
|
|
|
2001-11-02 08:22:00 +03:00
|
|
|
$fh->close;
|
|
|
|
|
|
|
|
die "No scrape data found in log.\n" unless @scrape_data;
|
|
|
|
|
|
|
|
# Save the scrape data to 'scrape.dat'
|
|
|
|
#
|
|
|
|
open SCRAPE, ">>$tree/scrape.dat" or die "Unable to open $tree/scrape.dat";
|
|
|
|
print SCRAPE "$logfile|".join('|', @scrape_data)."\n";
|
|
|
|
close SCRAPE;
|
|
|
|
|
2001-11-02 12:37:35 +03:00
|
|
|
#print "scrape_data = ";
|
|
|
|
#my $i;
|
|
|
|
#foreach $i (@scrape_data) {
|
|
|
|
# print "$i ";
|
|
|
|
#}
|
|
|
|
#print "\n";
|
|
|
|
|
2001-11-02 08:22:00 +03:00
|
|
|
|
|
|
|
# end of main
|
|
|
|
#============================================================
|
|
|
|
|
|
|
|
sub find_scrape_data {
|
|
|
|
my ($fh) = $_[0];
|
|
|
|
local $_;
|
2001-11-02 12:37:35 +03:00
|
|
|
my @rv;
|
|
|
|
my @line;
|
2001-11-02 08:22:00 +03:00
|
|
|
while (<$fh>) {
|
2001-11-03 01:41:40 +03:00
|
|
|
if (/TinderboxPrint:/) {
|
2001-11-02 08:22:00 +03:00
|
|
|
# Line format:
|
2001-11-03 01:41:40 +03:00
|
|
|
# TinderboxPrint:aaa,bbb,ccc,ddd
|
|
|
|
|
|
|
|
# Strip off the TinderboxPrint: part of the line
|
2001-11-02 08:22:00 +03:00
|
|
|
chomp;
|
2001-11-03 01:41:40 +03:00
|
|
|
s/.*TinderboxPrint://;
|
2001-11-02 12:37:35 +03:00
|
|
|
@line = split(',', $_);
|
|
|
|
push(@rv, @line);
|
2001-11-02 08:22:00 +03:00
|
|
|
}
|
|
|
|
}
|
2001-11-02 12:37:35 +03:00
|
|
|
return @rv;
|
2001-11-02 08:22:00 +03:00
|
|
|
}
|