<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!
use strict;
use Debconf::Db;
use Debconf::Question;
use Debconf::Template;

my $dir = shift || '/var/lib/debconf';

Debconf::Db-&gt;load;

our %questions;
our %templates;

foreach my $thing (qw(templates debconf)) {
	if (-e "$dir/$thing.db") {
		eval qq{require "$dir/$thing.db"};
		print STDERR $@ if $@;
	}
	else {
		print STDERR "Skipping $dir/$thing.db: DNE\n";
	}
}

foreach my $t (keys %templates) {
	$templates{$t}-&gt;{_name}=$t;
}

my $skipped=0;

foreach my $item (keys %questions) {
	my @owners=grep { $_ ne '' } keys %{$questions{$item}-&gt;{owners}};
	delete $questions{$item}, next unless @owners;

	next unless defined $questions{$item}-&gt;{template}-&gt;{_name};

	my $tname=$questions{$item}-&gt;{template}-&gt;{_name};
	$skipped++, next unless defined $tname;
	my $type=$templates{$tname}-&gt;{type};
	my $question=Debconf::Question-&gt;new($item, pop(@owners), $type);
	$question-&gt;addowner($_, '') foreach @owners;
}

my %seen_templates;
foreach my $item (keys %questions) {
	my $question=Debconf::Question-&gt;get($item);
	my $tname=$questions{$item}-&gt;{template}-&gt;{_name};
	$skipped++, next unless defined $tname;
	my $template=Debconf::Template-&gt;get($tname);
	unless (defined $template) {
		$template=Debconf::Template-&gt;new($tname, $item, $templates{$tname}-&gt;{type});
	}
	unless ($seen_templates{$template}) {
		$template-&gt;clearall;
		foreach my $field (keys %{$templates{$tname}}) {
			next if $field=~/^_name/; # except this one we added above.
			$template-&gt;$field($templates{$tname}-&gt;{$field});
		}
	}
	

	if (exists $questions{$item}-&gt;{flag_isdefault}) {
		if ($questions{$item}-&gt;{flag_isdefault} eq 'false') {
		    	$question-&gt;flag('seen', 'true');
		}
		delete $questions{$item}-&gt;{flag_isdefault};
	}
	foreach my $flag (grep /^flag_/, keys %{$questions{$item}}) {
		if ($questions{$item}-&gt;{$flag} eq 'true') {
			$flag=~s/^flag_//;
			$question-&gt;flag($flag, 'true');
		}
	}
	foreach my $var (keys %{$questions{$item}-&gt;{variables}}) {
		$question-&gt;variable($var,
			$questions{$item}-&gt;{variables}-&gt;{$var});
	}
	if (exists $questions{$item}-&gt;{value} 
		and defined $questions{$item}-&gt;{value}) {
		$question-&gt;value($questions{$item}-&gt;{value});
	}

	$question-&gt;template($questions{$item}-&gt;{template}-&gt;{_name});
}

Debconf::Db-&gt;save;

if ($skipped) {
	print STDERR "While upgrading the debconf database, $skipped corrupt items were skipped.\n";
}
</pre></body></html>