File: html-control

package info (click to toggle)
debbugs 2.6.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,800 kB
  • sloc: perl: 19,270; makefile: 81; sh: 75
file content (101 lines) | stat: -rwxr-xr-x 3,245 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/perl
# $Id: html-control.in,v 1.12 2004/10/26 14:00:05 cjwatson Exp $

use POSIX qw(strftime tzset ENOENT);
$ENV{"TZ"} = 'UTC';
tzset();

$config_path = '/etc/debbugs';
$lib_path = '/usr/lib/debbugs';

require("$config_path/config");
require("$lib_path/errorlib");
$ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};

chdir("$gSpoolDir") || die "chdir spool: $!\n";
#push(@INC,"$lib_path");

&filelock("html.fcntl-lock");

unlink("html-data.gz") || $!==&ENOENT or die "remove html-data.gz: $!";

sub nonawful ($) {
    rename("stamp.html.run","stamp.html") or warn "warning: put back stamp.html: $!";
    die $_[0];
}

if (open(US,'updateseqs') && -f 'stamp.html') {
    chop($lastmain=<US>);
    chop($lastsub=<US>);
    close(US);

    $lastsub++;
    $args= "-diff -stampfile=stamp.html.run";
    rename("stamp.html","stamp.html.run") or die "rename stamp.html: $!";
} else {
    $lastsub=0;
    $lastmain = strftime "%Y%m%d%H%M%S", localtime;
    $args= '-full';
    unlink('stamp.html') || $!==&ENOENT or die "excise stale stamp.html: $!";
}

open(X,">stamp.html.new") or die "stamp.html.new: $!";
close(X) or die "close stamp.html.new: $!";

open(US,'>updateseqs.new') || die "create updateseqs.new: $!";
print(US "$lastmain\n$lastsub\n") || die "write updateseqs.new: $!";
close(US) || die "close updateseqs.new: $!";
rename('updateseqs.new','updateseqs') or nonawful("install updateseqs: $!");

sub runshell ($&) {
    my ($cmd,$errhref) = @_;
    print "xx $cmd\n";
    system $cmd;
    !$? && !length($stderr) or &$errhref("$cmd failed - gave $? / $stderr");
}

$sequences="$lastmain $lastsub";
$seqmid= $sequences; $seqmid =~ y/ /-/;
open(MM,">html-data.mail") or nonawful("open html-data.mail: $!");
if ( length( $gListDomain ) > 0 && length( $gMirrorList ) > 0 ) {
print(MM <<END
From: $gMaintainerEmail ($gProject $gBug Tracking System)
To: $gMirrorList\@$gListDomain
Subject: $gProject $gBugs autoupdate 259012
Message-ID: <handle.htmlup.$seqmid\@$gEmailDomain>
X-$gProject-PR: update $sequences

END
      ) or nonawful("write html-data.mail header: $!");
} else {
print(MM <<END
From: $gMaintainerEmail ($gProject $gBug Tracking System)
To: $gMaintainerEmail
Subject: $gProject $gBugs autoupdate 259012
Message-ID: <handle.htmlup.$seqmid\@$gEmailDomain>
X-$gProject-PR: update $sequences

END
      ) or nonawful("write html-data.mail header: $!");
}
close(MM) or nonawful("close html-data.mail: $!");

runshell("$lib_path/db2html $args 2>&1 >html-data $gWebDir/db",
         sub { &nonawful; });
runshell("$lib_path/html-install $gWebDir/db <html-data 2>&1",sub { &quit; });
#runshell("gzip -9 html-data 2>&1",sub { &quit; });
#runshell("btoa 2>&1 <html-data.gz >>html-data.mail",sub { &quit; });
#runshell('2>&1 '.join(' ',('/usr/lib/sendmail','-f'."$gMaintainerEmail")).' -oem -oi -t <html-data.mail',
#         sub { &quit; });

rename("stamp.html.new","stamp.html") or die "install new stamp.html: $!";

unlink("html-data") or warn "remove html-data: $!";
#unlink("html-data.gz") or warn "remove html-data.gz: $!";
#unlink("html-data.mail") or warn "remove html-data.mail: $!";
unlink("stamp.html.run") || $!==&ENOENT or warn "remove stamp.html.run: $!";

print "sequences $lastmain $lastsub\n";

&unfilelock();
exit(0);