#!/usr/bin/perl
# $Id: db2html.in,v 1.22 2004/04/19 10:03:53 cjwatson Exp $
# usage: db2html [-diff] [-stampfile=] [-lastrun=]
#load the necessary libraries/configuration
$config_path = '/etc/debbugs';
$lib_path = '/usr/lib/debbugs';
require("$config_path/config");
require("$config_path/text");
require("$lib_path/errorlib");
$ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
use POSIX qw(strftime tzset);
$ENV{"TZ"} = 'UTC';
tzset();
#set current working directory
chdir("$gSpoolDir") || die "chdir spool: $!\n";
#setup variables
$diff = 0;
$stampfile = 'stamp.html';
$tail_html = $gHTMLTail;
$expirynote_html = '';
$expirynote_html = $gHTMLExpireNote if $gRemoveAge;
$shorthead = ' Ref * Package Keywords/Subject Submitter';
$shortindex = '';
$amonths = -1;
$indexunmatched = '';
%displayshowpendings = ('pending','outstanding',
'done','resolved',
'forwarded','forwarded to upstream software authors');
#set timestamp for html files
$dtime = strftime "%a, %e %b %Y %T UTC", localtime;
$tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
#check for commandline switches
while (@ARGV && $ARGV[0] =~ m/^-/)
{ if ($ARGV[0] eq '-diff') { $diff=1; }
elsif ($ARGV[0] =~ m/^-lastrun\=([0-9.]+)$/) { $lastrun= $1; undef $stampfile; }
elsif ($ARGV[0] =~ m/^-full$/) { undef $lastrun; undef $stampfile; }
elsif ($ARGV[0] =~ m/^-stampfile\=(\S+)$/) { $stampfile= $1; }
else { die "bad usage"; }
shift;
}
#check for remaing argument, only one...
@ARGV==1 or die;
$wwwbase= shift(@ARGV);
#get starting time
defined($startdate= time) || die "failed to get time: $!";
$|=1;
#if stamp file was given,
if (defined($stampfile))
{ if (open(X,"< $stampfile"))
{ $lastrun= -M X;
close(X);
printf "progress last run %.7f days\n",$lastrun;
} else { print "progress stamp file $stampfile: $! - full\n"; }
}
#only process file if greater than last run...
if (defined($lastrun) && -M "db-h" > $lastrun)
{ $_= $gHTMLStamp;
s/SUBSTITUTE_DTIME/$dtime/o;
s/\<\!\-\-updateupdate\-\-\>.*\<\!\-\-\/updateupdate\-\-\>/check/;
&file('ix/zstamp.html','non',$_."