<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -w
# This file was preprocessed, do not edit!


package Debconf::Config;
use strict;
use Debconf::Question;
use Debconf::Gettext;
use Debconf::Priority qw(priority_valid priority_list);
use Debconf::Log qw(warn);
use Debconf::Db;

use fields qw(config templates frontend frontend_forced priority terse reshow
              admin_email log debug nowarnings smileys sigils
              noninteractive_seen c_values);
our $config=fields::new('Debconf::Config');

our @config_files=("/etc/debconf.conf", "/usr/share/debconf/debconf.conf");
if ($ENV{DEBCONF_SYSTEMRC}) {
	unshift @config_files, $ENV{DEBCONF_SYSTEMRC};
} else {
	unshift @config_files, ((getpwuid($&gt;))[7])."/.debconfrc";
}
	   

sub _hashify ($$) {
	my $text=shift;
	my $hash=shift;

	$text =~ s/\${([^}]+)}/$ENV{$1}/eg;
	
	my %ret;
	my $i;
	foreach my $line (split /\n/, $text) {
		next if $line=~/^\s*#/; # comment
		next if $line=~/^\s*$/; # blank
		$line=~s/^\s+//;
		$line=~s/\s+$//;
		$i++;
		my ($key, $value)=split(/\s*:\s*/, $line, 2);
		$key=~tr/-/_/;
		die "Parse error" unless defined $key and length $key;
		$hash-&gt;{lc($key)}=$value;
	}
	return $i;
}
 
sub _env_to_driver {
	my $value=shift;
	
	my ($name, $options) = $value =~ m/^(\w+)(?:{(.*)})?$/;
	return unless $name;
	
	return $name if Debconf::DbDriver-&gt;driver($name);
	
	my %hash = @_; # defaults from params
	$hash{driver} = $name;
	
	if (defined $options) {
		foreach (split ' ', $options) {
			if (/^(\w+):(.*)/) {
				$hash{$1}=$2;
			}
			else {
				$hash{filename}=$_;
			}
		}
	}
	return Debconf::Db-&gt;makedriver(%hash)-&gt;{name};
}

sub load {
	my $class=shift;
	my $cf=shift;
	my @defaults=@_;
	
	if (! $cf) {
		for my $file (@config_files) {
			$cf=$file, last if -e $file;
		}
	}
	die "No config file found" unless $cf;

	open (DEBCONF_CONFIG, $cf) or die "$cf: $!\n";
	local $/="\n\n"; # read a stanza at a time

	1 until _hashify(&lt;DEBCONF_CONFIG&gt;, $config) || eof DEBCONF_CONFIG;

	if (! exists $config-&gt;{config}) {
		print STDERR "debconf: ".gettext("Config database not specified in config file.")."\n";
		exit(1);
	}
	if (! exists $config-&gt;{templates}) {
		print STDERR "debconf: ".gettext("Template database not specified in config file.")."\n";
		exit(1);
	}

	if (exists $config-&gt;{sigils} || exists $config-&gt;{smileys}) {
		print STDERR "debconf: ".gettext("The Sigils and Smileys options in the config file are no longer used. Please remove them.")."\n";
	}

	while (&lt;DEBCONF_CONFIG&gt;) {
		my %config=(@defaults);
		if (exists $ENV{DEBCONF_DB_REPLACE}) {
			$config{readonly} = "true";
		}
		next unless _hashify($_, \%config);
		eval {
			Debconf::Db-&gt;makedriver(%config);
		};
		if ($@) {
			print STDERR "debconf: ".sprintf(gettext("Problem setting up the database defined by stanza %s of %s."),$., $cf)."\n";
			die $@;
		}
	}
	close DEBCONF_CONFIG;

	if (exists $ENV{DEBCONF_DB_REPLACE}) {
		$config-&gt;{config} = _env_to_driver($ENV{DEBCONF_DB_REPLACE},
			name =&gt; "_ENV_REPLACE");
		Debconf::Db-&gt;makedriver(
			driver =&gt; "Pipe",
			name =&gt; "_ENV_REPLACE_templates",
			infd =&gt; "none",
			outfd =&gt; "none",
		);
		my @template_stack = ("_ENV_REPLACE_templates", $config-&gt;{templates});
		Debconf::Db-&gt;makedriver(
			driver =&gt; "Stack",
			name =&gt; "_ENV_stack_templates",
			stack =&gt; join(", ", @template_stack),
		);
		$config-&gt;{templates} = "_ENV_stack_templates";
	}

	my @finalstack = ($config-&gt;{config});
	if (exists $ENV{DEBCONF_DB_OVERRIDE}) {
		unshift @finalstack, _env_to_driver($ENV{DEBCONF_DB_OVERRIDE},
			name =&gt; "_ENV_OVERRIDE");
	}
	if (exists $ENV{DEBCONF_DB_FALLBACK}) {
		push @finalstack, _env_to_driver($ENV{DEBCONF_DB_FALLBACK},
			name =&gt; "_ENV_FALLBACK",
			readonly =&gt; "true");
	}
	if (@finalstack &gt; 1) {
		Debconf::Db-&gt;makedriver(
			driver =&gt; "Stack",
			name =&gt; "_ENV_stack",
			stack  =&gt; join(", ", @finalstack),
		);
		$config-&gt;{config} = "_ENV_stack";
	}
}


sub getopt {
	my $class=shift;
	my $usage=shift;

	my $showusage=sub { # closure
		print STDERR $usage."\n";
		print STDERR gettext(&lt;&lt;EOF);
  -f,  --frontend		Specify debconf frontend to use.
  -p,  --priority		Specify minimum priority question to show.
       --terse			Enable terse mode.
EOF
		exit 1;
	};

	return unless grep { $_ =~ /^-/ } @ARGV;
	
	require Getopt::Long;
	Getopt::Long::Configure('bundling');
	Getopt::Long::GetOptions(
		'frontend|f=s',	sub { shift; $class-&gt;frontend(shift); $config-&gt;frontend_forced(1) },
		'priority|p=s',	sub { shift; $class-&gt;priority(shift) },
		'terse',	sub { $config-&gt;{terse} = 'true' },
		'help|h',	$showusage,
		@_,
	) || $showusage-&gt;();
}


sub frontend {
	my $class=shift;
	
	return $ENV{DEBIAN_FRONTEND} if exists $ENV{DEBIAN_FRONTEND};
	$config-&gt;{frontend}=shift if @_;
	return $config-&gt;{frontend} if exists $config-&gt;{frontend};
	
	my $ret='dialog';
	my $question=Debconf::Question-&gt;get('debconf/frontend');
	if ($question) {
		$ret=lcfirst($question-&gt;value) || $ret;
	}
	return $ret;
}


sub frontend_forced {
	my ($class, $val) = @_;
	$config-&gt;{frontend_forced} = $val
		if defined $val || exists $ENV{DEBIAN_FRONTEND};
	return $config-&gt;{frontend_forced} ? 1 : 0;
}


sub priority {
	my $class=shift;
	return $ENV{DEBIAN_PRIORITY} if exists $ENV{DEBIAN_PRIORITY};
	if (@_) {
		my $newpri=shift;
		if (! priority_valid($newpri)) {
			warn(sprintf(gettext("Ignoring invalid priority \"%s\""), $newpri));
			warn(sprintf(gettext("Valid priorities are: %s"), join(" ", priority_list())));
		}
		else {
			$config-&gt;{priority}=$newpri;
		}
	}
	return $config-&gt;{priority} if exists $config-&gt;{priority};

	my $ret='high';
	my $question=Debconf::Question-&gt;get('debconf/priority');
	if ($question) {
		$ret=$question-&gt;value || $ret;
	}
	return $ret;
}


sub terse {
	my $class=shift;
	return $ENV{DEBCONF_TERSE} if exists $ENV{DEBCONF_TERSE};
	$config-&gt;{terse}=$_[0] if @_;
	return $config-&gt;{terse} if exists $config-&gt;{terse};
	return 'false';
}


sub nowarnings {
	my $class=shift;
	return $ENV{DEBCONF_NOWARNINGS} if exists $ENV{DEBCONF_NOWARNINGS};
	$config-&gt;{nowarnings}=$_[0] if @_;
	return $config-&gt;{nowarnings} if exists $config-&gt;{nowarnings};
	return 'false';
}


sub debug {
	my $class=shift;
	return $ENV{DEBCONF_DEBUG} if exists $ENV{DEBCONF_DEBUG};
	return $config-&gt;{debug} if exists $config-&gt;{debug};
	return '';
}


sub admin_email {
	my $class=shift;
	return $ENV{DEBCONF_ADMIN_EMAIL} if exists $ENV{DEBCONF_ADMIN_EMAIL};
	return $config-&gt;{admin_email} if exists $config-&gt;{admin_email};
	return 'root';
}


sub noninteractive_seen {
	my $class=shift;
	return $ENV{DEBCONF_NONINTERACTIVE_SEEN} if exists $ENV{DEBCONF_NONINTERACTIVE_SEEN};
	return $config-&gt;{noninteractive_seen} if exists $config-&gt;{noninteractive_seen};
	return 'false';
}


sub c_values {
	my $class=shift;
	return $ENV{DEBCONF_C_VALUES} if exists $ENV{DEBCONF_C_VALUES};
	return $config-&gt;{c_values} if exists $config-&gt;{c_values};
	return 'false';
}


sub AUTOLOAD {
	(my $field = our $AUTOLOAD) =~ s/.*://;
	my $class=shift;
	
	return $config-&gt;{$field}=shift if @_;
	return $config-&gt;{$field} if defined $config-&gt;{$field};
	return '';
}


1
</pre></body></html>