1998-06-16 21:43:24 +00:00
|
|
|
#!/usr/bonsaitools/bin/perl --
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Netscape Public License
|
|
|
|
# Version 1.0 (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/NPL/
|
|
|
|
#
|
|
|
|
# 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 the Tinderbox build tool.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are Copyright (C) 1998
|
|
|
|
# Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
|
1998-06-19 15:32:07 +00:00
|
|
|
# Figure out which directory tinderbox is in by looking at argv[0]
|
|
|
|
|
1999-08-25 04:55:58 +00:00
|
|
|
use File::Find;
|
|
|
|
|
1998-06-19 15:32:07 +00:00
|
|
|
$tinderboxdir = $0;
|
|
|
|
$tinderboxdir =~ s:/[^/]*$::; # Remove last word, and slash before it.
|
1999-08-25 04:55:58 +00:00
|
|
|
$tinderboxdir = '.' if $tinderboxdir eq '';
|
|
|
|
$now = time();
|
|
|
|
$expire_time = $now - 7 * 24 * 60 * 60;
|
1998-06-19 15:36:21 +00:00
|
|
|
#print "tinderbox = $tinderboxdir\n";
|
1998-06-19 15:32:07 +00:00
|
|
|
|
1999-08-25 04:55:58 +00:00
|
|
|
chdir $tinderboxdir or die "Couldn't chdir to $tinderboxdir";
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-08-25 04:55:58 +00:00
|
|
|
# Remove files older than 7 days
|
|
|
|
#
|
|
|
|
sub files_to_remove {
|
1999-08-25 05:01:00 +00:00
|
|
|
unlink if /(?:\.gz|\.brief\.html)$/ and int(-M $_) > 7;
|
1999-08-25 04:55:58 +00:00
|
|
|
}
|
|
|
|
&find(\&files_to_remove, $tinderboxdir);
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-08-25 04:55:58 +00:00
|
|
|
# Remove build.dat entries older than 7 days
|
|
|
|
#
|
|
|
|
sub log_files_to_trim {
|
|
|
|
return unless /^(?:notes.txt|build.dat)$/;
|
|
|
|
warn "Cleaning $File::Find::name\n";
|
|
|
|
my $file = $_;
|
|
|
|
my $range_start = 0;
|
|
|
|
my $line = 1;
|
|
|
|
my $ed_cmds = '';
|
|
|
|
open LOG, "$file";
|
|
|
|
while (<LOG>) {
|
|
|
|
$log_time = (split /\|/)[0];
|
|
|
|
if ($range_start == 0 and $log_time < $expire_time) {
|
|
|
|
$range_start = $line;
|
|
|
|
} elsif ($range_start != 0 and $log_time >= $expire_time) {
|
|
|
|
if ($range_start == $line - 1) {
|
1999-08-25 05:07:45 +00:00
|
|
|
$ed_cmds = "${range_start}d\n$ed_cmds";
|
1999-08-25 04:55:58 +00:00
|
|
|
} else {
|
1999-08-25 05:07:45 +00:00
|
|
|
$ed_cmds = "$range_start,".($line - 1)."d\n$ed_cmds";
|
1999-08-25 04:55:58 +00:00
|
|
|
}
|
|
|
|
$range_start = 0;
|
|
|
|
}
|
|
|
|
$line++;
|
|
|
|
}
|
|
|
|
close LOG;
|
1999-08-25 05:07:45 +00:00
|
|
|
next if $ed_cmds eq '';
|
1999-08-25 04:55:58 +00:00
|
|
|
open ED,"| ed $file" or die "died ed'ing: $!\n";
|
|
|
|
print ED "${ed_cmds}w\nq\n";
|
|
|
|
close ED;
|
1998-06-16 21:43:24 +00:00
|
|
|
}
|
1999-08-25 04:55:58 +00:00
|
|
|
&find(\&log_files_to_trim, $tinderboxdir);
|
|
|
|
|