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("Maintainers");
29 &template("pseudo-packages.description");
30 &template("nextnumber");
32 # stuff used when testing (comment out the above)
34 #require "../scripts/config.in";
35 #require "../scripts/text.in";
36 #$gWebDir = "gWebDir";
37 #$gDocDir = "gWebDir";
39 my $dtime = strftime "%a, %e %b %Y %T UTC", localtime;
40 $gHTMLTail =~ s/SUBSTITUTE_DTIME/$dtime/;
42 print "Creating files in $gWebDir:\n";
43 require('html/index.html.in');
44 &writefiles ('index', '', $gIndexHtml );
45 require('html/Access.html.in');
46 &writefiles ('Access', 'bug-log-access', $gAccessHtml );
47 require('html/Developer.html.in');
48 &writefiles ('Developer', 'bug-maint-info', $gDeveloperHtml );
49 require('html/Reporting.html.in');
50 &writefiles ('Reporting', 'bug-reporting', $gReportingHtml );
51 require('html/server-control.html.in');
52 &writefiles ('server-control', 'bug-maint-mailcontrol', $gControlHtml );
53 require('html/server-refcard.html.in');
54 &writefiles ('server-refcard', 'bug-mailserver-refcard', $gRefcardHtml );
55 require('html/server-request.html.in');
56 &writefiles ('server-request', 'bug-log-mailserver', $gRequestHtml );
61 # -------------------------------------------------------------------------- #
65 if (! -f "$gConfigDir/$name") {
66 system("cp /usr/share/doc/debbugs/examples/$name $gConfigDir/$name") == 0 ||
68 print "created $gConfigDir/$name from template.\n";
73 local ($html, $text, $name) = @_;
75 unlink("$gWebDir/$html.html");
76 open(DEST, ">$gWebDir/$html.html") || die "\n$gWebDir/$html.html: $!";
81 return if ($text eq ""); # for index.html
82 # This should be done with pipes instead of a temporary files, but lynx
83 # doesn't read HTML from stdin :/
84 open(DEST, ">$gDocDir/$text.html") || die "\n$gDocDir/$text.html: $!";
85 $name =~ s,\nOther pages:\n.*?<hr>,,si;
88 unlink("$gDocDir/$text.txt");
89 $ENV{'HOME'} = "/tmp";
90 $ENV{'TERM'} = "linux";
91 if (-x "/usr/bin/links") {
92 system ("rm -rf /tmp/.links/") == 0 || die;
93 system ("links -dump $gDocDir/$text.html > $gDocDir/$text.txt") == 0 ||
94 die "\nunable to write $gDocDir/$text.txt\n";
95 system ("rm -rf /tmp/.links/");
96 } elsif (-x "/usr/bin/lynx") {
97 system ("lynx -nolist -dump -cfg=$gConfigDir/html/lynx-cfg $gDocDir/$text.html > $gDocDir/$text.txt") == 0 ||
98 die "\nunable to write $gDocDir/$text.txt\n";
100 print "unable to write text versions of the HTMLs!";
101 print "if you need them, install links or lynx and run debbugsconfig again";
104 unlink("$gDocDir/$text.html") || die "\ncan't remove temporary file $gDocDir/$text.html: $!";