2 # debbugsconfig: copies debbugs configuration files from templates, and
3 # creates documentation in HTML and text
5 use POSIX qw(strftime);
11 debbugsconfig will copy basic debbugs configuration files from templates
14 It will also create BTS user documentation in HTML and text.
20 $gConfigDir = "/etc/debbugs" if (!defined($gConfigDir));
22 require "$gConfigDir/config";
23 unshift @INC, $gConfigDir;
28 &template("nextnumber");
30 # stuff used when testing (comment out the above)
32 #require "../scripts/config.in";
33 #require "../scripts/text.in";
34 #$gWebDir = "gWebDir";
35 #$gDocDir = "gWebDir";
37 my $dtime = strftime "%a, %e %b %Y %T UTC", localtime;
38 $gHTMLTail =~ s/SUBSTITUTE_DTIME/$dtime/;
40 print "Creating files in $gWebDir:\n";
41 require('html/index.html.in');
42 &writefiles ('index', '', $gIndexHtml );
43 require('html/Access.html.in');
44 &writefiles ('Access', 'bug-log-access', $gAccessHtml );
45 require('html/Developer.html.in');
46 &writefiles ('Developer', 'bug-maint-info', $gDeveloperHtml );
47 require('html/Reporting.html.in');
48 &writefiles ('Reporting', 'bug-reporting', $gReportingHtml );
49 require('html/server-control.html.in');
50 &writefiles ('server-control', 'bug-maint-mailcontrol', $gControlHtml );
51 require('html/server-refcard.html.in');
52 &writefiles ('server-refcard', 'bug-mailserver-refcard', $gRefcardHtml );
53 require('html/server-request.html.in');
54 &writefiles ('server-request', 'bug-log-mailserver', $gRequestHtml );
59 # -------------------------------------------------------------------------- #
63 if (! -f "$gConfigDir/$name") {
64 system("cp /usr/share/doc/debbugs/examples/$name $gConfigDir/$name") == 0 ||
66 print "created $gConfigDir/$name from template.";
71 local ($html, $text, $name) = @_;
73 unlink("$gWebDir/$html.html");
74 open(DEST, ">$gWebDir/$html.html") || die "\n$gWebDir/$html.html: $!";
79 return if ($text eq ""); # for index.html
80 # This should be done with pipes instead of a temporary files, but lynx
81 # doesn't read HTML from stdin :/
82 open(DEST, ">$gDocDir/$text.html") || die "\n$gDocDir/$text.html: $!";
83 $name =~ s,\nOther pages:\n.*?<hr>,,si;
86 unlink("$gDocDir/$text.txt");
87 $ENV{'HOME'} = "/tmp";
88 $ENV{'TERM'} = "linux";
89 if (-x "/usr/bin/links") {
90 system ("rm -rf /tmp/.links/") == 0 || die;
91 system ("links -dump $gDocDir/$text.html > $gDocDir/$text.txt") == 0 ||
92 die "\nunable to write $gDocDir/$text.txt\n";
93 system ("rm -rf /tmp/.links/");
94 } elsif (-x "/usr/bin/lynx") {
95 system ("lynx -nolist -dump -cfg=$gConfigDir/html/lynx-cfg $gDocDir/$text.html > $gDocDir/$text.txt") == 0 ||
96 die "\nunable to write $gDocDir/$text.txt\n";
98 print "unable to write text versions of the HTMLs!";
99 print "if you need them, install links or lynx and run debbugsconfig again";
102 unlink("$gDocDir/$text.html") || die "\ncan't remove temporary file $gDocDir/$text.html: $!";