2 package Debbugs::Config;
6 Debbugs::Config -- Configuration information for debbugs
12 # to get the compatiblity interface
14 use Debbugs::Config qw(:globals);
18 This module provides configuration variables for all of debbugs.
20 =head1 CONFIGURATION FILES
22 The default configuration file location is /etc/debbugs/config; this
23 configuration file location can be set by modifying the
24 DEBBUGS_CONFIG_FILE env variable to point at a different location.
30 use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT $USING_GLOBALS %config);
31 use base qw(Exporter);
34 # set the version for version checking
36 $DEBUG = 0 unless defined $DEBUG;
40 %EXPORT_TAGS = (globals => [qw($gEmailDomain $gListDomain $gWebHost $gWebHostBugDir),
41 qw($gWebDomain $gHTMLSuffix $gCGIDomain $gMirrors),
42 qw($gPackagePages $gSubscriptionDomain $gProject $gProjectTitle),
43 qw($gMaintainer $gMaintainerWebpage $gMaintainerEmail $gUnknownMaintainerEmail),
44 qw($gSubmitList $gMaintList $gQuietList $gForwardList),
45 qw($gDoneList $gRequestList $gSubmitterList $gControlList),
46 qw($gSummaryList $gMirrorList $gMailer $gBug),
47 qw($gBugs $gRemoveAge $gSaveOldBugs $gDefaultSeverity),
48 qw($gShowSeverities $gBounceFroms $gConfigDir $gSpoolDir),
49 qw($gIncomingDir $gWebDir $gDocDir $gMaintainerFile),
50 qw($gMaintainerFileOverride $gPseudoDescFile $gPackageSource),
51 qw($gVersionPackagesDir $gVersionIndex $gBinarySourceMap $gSourceBinaryMap),
52 qw(%gSeverityDisplay @gTags @gSeverityList @gStrongSeverities),
55 text => [qw($gBadEmailPrefix $gHTMLTail $gHTMLExpireNote),
57 config => [qw(%config)],
60 Exporter::export_ok_tags(qw(globals text config));
61 $EXPORT_TAGS{all} = [@EXPORT_OK];
64 use File::Basename qw(dirname);
68 =head1 CONFIGURATION VARIABLES
70 =head2 General Configuration
78 read_config(exists $ENV{DEBBUGS_CONFIG_FILE}?$ENV{DEBBUGS_CONFIG_FILE}:'/etc/debbugs/config');
82 The email domain of the bts
86 set_default(\%config,'email_domain','bugs.something');
90 The list domain of the bts, defaults to the email domain
94 set_default(\%config,'list_domain',$config{email_domain});
98 The web host of the bts; defaults to the email domain
102 set_default(\%config,'web_host',$config{email_domain});
104 =item web_host_bug_dir
106 The directory of the web host on which bugs are kept, defaults to C<''>
110 set_default(\%config,'web_host_bug_dir','');
114 Full path of the web domain where bugs are kept, defaults to the
115 concatenation of L</web_host> and L</web_host_bug_dir>
119 set_default(\%config,'web_domain',$config{web_host}.'/'.$config{web_host_bug_dir});
123 Suffix of html pages, defaults to .html
127 set_default(\%config,'html_suffix','.html');
131 Full path of the web domain where cgi scripts are kept. Defaults to
132 the concatentation of L</web_host> and cgi.
136 set_default(\%config,'cgi_domain',$config{web_domain}.($config{web_domain}=~m{/$}?'':'/').'cgi');
140 List of mirrors [What these mirrors are used for, no one knows.]
145 set_default(\%config,'mirrors',[]);
149 Domain where the package pages are kept; links should work in a
150 package_pages/foopackage manner. Defaults to undef, which means that
151 package links will not be made.
156 set_default(\%config,'package_pages',undef);
158 =item subscription_domain
160 Domain where subscriptions to package lists happen
165 set_default(\%config,'subscription_domain',undef);
172 =head2 Project Identification
182 set_default(\%config,'project','Something');
186 Name of this install of Debbugs, defaults to "L</project> Debbugs Install"
190 set_default(\%config,'project_title',"$config{project} Debbugs Install");
194 Name of the maintainer of this debbugs install
198 set_default(\%config,'maintainer','Local DebBugs Owner');
200 =item maintainer_webpage
202 Webpage of the maintainer of this install of debbugs
206 set_default(\%config,'maintainer_webpage',"$config{web_domain}/~owner");
208 =item maintainer_email
210 Email address of the maintainer of this Debbugs install
214 set_default(\%config,'maintainer_email','root@'.$config{email_domain});
216 =item unknown_maintainer_email
218 Email address where packages with an unknown maintainer will be sent
222 set_default(\%config,'unknown_maintainer_email',$config{maintainer_email});
224 =head2 BTS Mailing Lists
251 set_default(\%config, 'submit_list', 'bug-submit-list');
252 set_default(\%config, 'maint_list', 'bug-maint-list');
253 set_default(\%config, 'quiet_list', 'bug-quiet-list');
254 set_default(\%config, 'forward_list', 'bug-forward-list');
255 set_default(\%config, 'done_list', 'bug-done-list');
256 set_default(\%config, 'request_list', 'bug-request-list');
257 set_default(\%config,'submitter_list','bug-submitter-list');
258 set_default(\%config, 'control_list', 'bug-control-list');
259 set_default(\%config, 'summary_list', 'bug-summary-list');
260 set_default(\%config, 'mirror_list', 'bug-mirror-list');
268 set_default(\%config,'mailer','exim');
269 set_default(\%config,'bug','bug');
270 set_default(\%config,'bugs','bugs');
274 Age at which bugs are archived/removed
280 set_default(\%config,'remove_age',28);
284 Whether old bugs are saved or deleted
290 set_default(\%config,'save_old_bugs',1);
292 =item removal_distribution_tags
294 Tags which specifiy distributions to check
296 Default: qw(experimental unstable testing stable oldstable);
300 set_default(\%config,'removal_distribution_tags',
301 [qw(experimental unstable testing stable oldstable)]);
303 =item removal_default_distribution_tags
305 For removal/archival purposes, all bugs are assumed to have these tags
308 Default: qw(unstable testing);
312 set_default(\%config,'removal_default_distribution_tags',
313 [qw(unstable testing)]
317 set_default(\%config,'default_severity','normal');
318 set_default(\%config,'show_severities','critical, grave, normal, minor, wishlist');
319 set_default(\%config,'strong_severities',[qw(critical grave)]);
320 set_default(\%config,'severity_list',[qw(critical grave normal wishlist)]);
321 set_default(\%config,'severity_display',{critical => "Critical $config{bugs}",
322 grave => "Grave $config{bugs}",
323 normal => "Normal $config{bugs}",
324 wishlist => "Wishlist $config{bugs}",
327 set_default(\%config,'tags',[qw(patch wontfix moreinfo unreproducible fixed stable)]);
329 set_default(\%config,'bounce_froms','^mailer|^da?emon|^post.*mast|^root|^wpuser|^mmdf|^smt.*|'.
330 '^mrgate|^vmmail|^mail.*system|^uucp|-maiser-|^mal\@|'.
331 '^mail.*agent|^tcpmail|^bitmail|^mailman');
333 set_default(\%config,'config_dir',dirname(exists $ENV{DEBBUGS_CONFIG_FILE}?$ENV{DEBBUGS_CONFIG_FILE}:'/etc/debbugs/config'));
334 set_default(\%config,'spool_dir','/var/lib/debbugs/spool');
335 set_default(\%config,'incoming_dir','incoming');
336 set_default(\%config,'web_dir','/var/lib/debbugs/www');
337 set_default(\%config,'doc_dir','/var/lib/debbugs/www/txt');
339 set_default(\%config,'maintainer_file',$config{config_dir}.'/Maintainers');
340 set_default(\%config,'maintainer_file_override',$config{config_dir}.'/Maintainers.override');
341 set_default(\%config,'pseduo_desc_file',$config{config_dir}.'/pseudo-packages.description');
342 set_default(\%config,'package_source',$config{config_dir}.'/indices/sources');
344 set_default(\%config,'version_packages_dir',$config{spool_dir}.'/../versions/pkg');
345 #set_default(\%config,'version_packages_dir',$config{spool_dir}'/../versions/pkg');
352 The following are the only text fields in general use in the scripts;
353 a few additional text fields are defined in text.in, but are only used
354 in db2html and a few other specialty scripts.
356 Earlier versions of debbugs defined these values in /etc/debbugs/text,
357 but now they are required to be in the configuration file. [Eventually
358 the longer ones will move out into a fully fledged template system.]
364 =item bad_email_prefix
366 This prefixes the text of all lines in a bad e-mail message ack.
370 set_default(\%config,'bad_email_prefix','');
374 This shows up at the end of (most) html pages
378 set_default(\%config,'html_tail',<<END);
379 <ADDRESS>$config{maintainer} <<A HREF=\"mailto:$config{maintainer_email}\">$config{maintainer_email}</A>>.
385 <A HREF=\"http://$config{web_domain}/\">Debian $config{bug} tracking system</A><BR>
386 Copyright (C) 1999 Darren O. Benham,
387 1997,2003 nCipher Corporation Ltd,
393 =item html_expire_note
395 This message explains what happens to archive/remove-able bugs
399 set_default(\%config,'html_expire_note',
400 "(Closed $config{bugs} are archived $config{remove_age} days after the last related message is received.)");
408 my ($conf_file) = @_;
409 # first, figure out what type of file we're reading in.
410 my $fh = new IO::File $conf_file,'r'
411 or die "Unable to open configuration file $conf_file for reading: $!";
412 # A new version configuration file must have a comment as its first line
413 my $first_line = <$fh>;
414 my ($version) = $first_line =~ /VERSION:\s*(\d+)/i;
415 if (defined $version) {
418 die "Version 1 configuration files not implemented yet";
421 die "Version $version configuration files are not supported";
425 # Ugh. Old configuration file
426 # What we do here is we create a new Safe compartment
427 # so fucked up crap in the config file doesn't sink us.
428 my $cpt = new Safe or die "Unable to create safe compartment";
429 # perldoc Opcode; for details
430 $cpt->permit('require',':filesys_read','entereval','caller','pack','unpack','dofile');
431 $cpt->reval(q($gMaintainerFile = 'FOOOO'));
432 $cpt->reval(qq(require '$conf_file';));
433 die "Error in configuration file: $@" if $@;
434 # Now what we do is check out the contents of %EXPORT_TAGS to see exactly which variables
435 # we want to glob in from the configuration file
436 for my $variable (@{$EXPORT_TAGS{globals}}) {
437 my ($hash_name,$glob_name,$glob_type) = __convert_name($variable);
438 my $var_glob = $cpt->varglob($glob_name);
439 my $value; #= $cpt->reval("return $variable");
440 #print STDERR $value,qq(\n);
441 if (defined $var_glob) {{
443 if ($glob_type eq '%') {
444 $value = {%{*{$var_glob}}};
446 elsif ($glob_type eq '@') {
447 $value = [@{*{$var_glob}}];
450 $value = ${*{$var_glob}};
452 # We punt here, because we can't tell if the value was
453 # defined intentionally, or if it was just left alone;
454 # this tries to set sane defaults.
455 set_default(\%config,$hash_name,$value) if defined $value;
463 my $hash_name = $variable;
464 $hash_name =~ s/^([\$\%\@])g//;
466 my $glob_name = 'g'.$hash_name;
467 $hash_name =~ s/(HTML|CGI)/ucfirst(lc($1))/ge;
468 $hash_name =~ s/^([A-Z]+)/lc($1)/e;
469 $hash_name =~ s/([A-Z]+)/'_'.lc($1)/ge;
470 return $hash_name unless wantarray;
471 return ($hash_name,$glob_name,$glob_type);
476 # sets the configuration hash to the default value if it's not set,
477 # otherwise doesn't do anything
478 # If $USING_GLOBALS, then sets an appropriate global.
481 my ($config,$option,$value) = @_;
483 if ($USING_GLOBALS) {
484 # fix up the variable name
485 $varname = 'g'.join('',map {ucfirst $_} split /_/, $option);
486 # Fix stupid HTML names
487 $varname =~ s/(Html|Cgi)/uc($1)/ge;
489 # update the configuration value
490 if (not $USING_GLOBALS and not exists $config{$option}) {
491 $config{$option} = $value;
493 elsif ($USING_GLOBALS) {{
495 # Need to check if a value has already been set in a global
496 if (defined *{"Debbugs::Config::${varname}"}) {
497 $config{$option} = *{"Debbugs::Config::${varname}"};
500 if ($USING_GLOBALS) {{
502 *{"Debbugs::Config::${varname}"} = $config{$option};
509 # All we care about here is whether we've been called with the globals or text option;
510 # if so, then we need to export some symbols back up.
511 # In any event, we call exporter.
514 if (grep /^:(?:text|globals)$/, @_) {
516 for my $variable (map {@$_} @EXPORT_TAGS{map{(/^:(text|globals)$/?($1):())} @_}) {
519 # Yes, I don't care if these are only used once
521 # No, it doesn't bother me that I'm assigning an undefined value to a typeglob
523 my ($hash_name,$glob_name,$glob_type) = __convert_name($variable);
524 $tmp =~ s/^[\%\$\@]//;
525 *{"Debbugs::Config::${tmp}"} = ref($config{$hash_name})?$config{$hash_name}:\$config{$hash_name};
528 Debbugs::Config->export_to_level(1,@_);