2006-12-07 07:59:39 +03:00
|
|
|
#! /usr/bin/perl
|
2001-11-02 08:22:00 +03:00
|
|
|
# -*- 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 ...
|
|
|
|
#
|
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
use strict;
|
|
|
|
|
2001-11-02 08:22:00 +03:00
|
|
|
sub usage {
|
|
|
|
warn "./scrape.pl <tree> <logfile>";
|
|
|
|
}
|
|
|
|
|
2006-08-17 02:07:17 +04:00
|
|
|
use Compress::Zlib;
|
2006-07-17 21:14:35 +04:00
|
|
|
use lib "@TINDERBOX_DIR@";
|
2006-08-17 02:07:17 +04:00
|
|
|
require "tbglobals.pl";
|
2006-10-19 22:13:12 +04:00
|
|
|
my $debug = 0;
|
2001-11-02 08:22:00 +03:00
|
|
|
|
2006-07-17 21:14:35 +04:00
|
|
|
$ENV{PATH} = "@SETUID_PATH@";
|
2001-11-02 08:22:00 +03:00
|
|
|
|
|
|
|
unless ($#ARGV == 1) {
|
|
|
|
&usage;
|
|
|
|
die "Error: Wrong number of arguments\n";
|
|
|
|
}
|
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
my ($tree, $logfile) = @ARGV;
|
2001-11-02 08:22:00 +03:00
|
|
|
|
2006-10-19 22:13:12 +04:00
|
|
|
print "scrape.pl($tree, $logfile)\n" if ($debug);
|
|
|
|
|
2006-08-17 02:07:17 +04:00
|
|
|
$tree = &trick_taint($tree);
|
|
|
|
$logfile = &trick_taint($logfile);
|
|
|
|
|
2007-12-19 23:00:54 +03:00
|
|
|
die "Error: No tree named $tree" unless -r "$::tree_dir/$tree/treedata.pl";
|
|
|
|
require "$::tree_dir/$tree/treedata.pl";
|
2001-11-02 08:22:00 +03:00
|
|
|
|
2006-11-02 23:21:50 +03:00
|
|
|
# Search the build log for the scrape data
|
2001-11-02 08:22:00 +03:00
|
|
|
#
|
2007-12-19 23:00:54 +03:00
|
|
|
my $gz = gzopen("$::tree_dir/$tree/$logfile", "rb")
|
|
|
|
or die "gzopen($::tree_dir/$tree/$logfile): $!\n";
|
2007-01-23 20:49:10 +03:00
|
|
|
my @scrape_data = find_scrape_data($gz);
|
2006-08-17 02:07:17 +04:00
|
|
|
$gz->gzclose();
|
|
|
|
|
|
|
|
if (!defined(@scrape_data)) {
|
2006-10-19 22:56:38 +04:00
|
|
|
print "No scrape data found in log.\n" if ($debug);
|
2006-08-17 02:07:17 +04:00
|
|
|
exit(0);
|
|
|
|
}
|
2001-11-02 08:22:00 +03:00
|
|
|
|
|
|
|
# Save the scrape data to 'scrape.dat'
|
|
|
|
#
|
2007-12-19 23:00:54 +03:00
|
|
|
my $lockfile = "$::tree_dir/$tree/scrape.sem";
|
2006-10-19 22:13:12 +04:00
|
|
|
my $lock = &lock_datafile($lockfile);
|
2007-12-19 23:00:54 +03:00
|
|
|
open(SCRAPE, ">>", "$::tree_dir/$tree/scrape.dat") or die "Unable to open $::tree_dir/$tree/scrape.dat";
|
2001-11-02 08:22:00 +03:00
|
|
|
print SCRAPE "$logfile|".join('|', @scrape_data)."\n";
|
|
|
|
close SCRAPE;
|
2006-10-19 22:13:12 +04:00
|
|
|
&unlock_datafile($lock);
|
|
|
|
unlink($lockfile);
|
2001-11-02 08:22:00 +03:00
|
|
|
|
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 {
|
2006-08-17 02:07:17 +04:00
|
|
|
my ($gz) = $_[0];
|
2001-11-02 08:22:00 +03:00
|
|
|
local $_;
|
2001-11-02 12:37:35 +03:00
|
|
|
my @rv;
|
|
|
|
my @line;
|
2006-08-17 02:07:17 +04:00
|
|
|
my ($bytesread, $gzline);
|
|
|
|
while (defined($gz) && (($bytesread = $gz->gzreadline($gzline)) > 0)) {
|
|
|
|
if ($gzline =~ m/TinderboxPrint:/) {
|
|
|
|
# Line format:
|
|
|
|
# TinderboxPrint:<general html>
|
|
|
|
|
|
|
|
# Strip off the TinderboxPrint: part of the line
|
|
|
|
chomp($gzline);
|
|
|
|
$gzline =~ s/.*TinderboxPrint://;
|
|
|
|
|
|
|
|
# No longer use ; to create separate lines.
|
|
|
|
#@line = split(';', $_);
|
|
|
|
|
2006-10-19 22:13:12 +04:00
|
|
|
push(@rv, $gzline);
|
2006-08-17 02:07:17 +04:00
|
|
|
}
|
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
|
|
|
}
|