<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
# This file was preprocessed, do not edit!
use warnings;
use strict;
use Debconf::Db;
use Debconf::Log q{warn};

Debconf::Db-&gt;load;

if (! @ARGV || $ARGV[0] ne 'end') {
	my $fix=0;
	my $ok;
	my $counter=0;
	do {
		$ok=1;

		my %templates=();
		my $ti=$Debconf::Db::templates-&gt;iterator;
		while (my $t=$ti-&gt;iterate) {
			$templates{$t}=Debconf::Template-&gt;get($t);
		}

		my %questions=();
		my $qi=Debconf::Question-&gt;iterator;
		while (my $q=$qi-&gt;iterate) {
			if (! defined $q-&gt;template) {
				warn "question \"".$q-&gt;name."\" has no template field; removing it.";
				$q-&gt;addowner("killme",""); # make sure it has one owner at least, so removal is triggered
				foreach my $owner (split(/, /, $q-&gt;owners)) {
					$q-&gt;removeowner($owner);
				}
				$ok=0;
				$fix=1;
			}
			elsif (! exists $templates{$q-&gt;template-&gt;template}) {
				warn "question \"".$q-&gt;name."\" uses nonexistent template ".$q-&gt;template-&gt;template."; removing it.";
				foreach my $owner (split(/, /, $q-&gt;owners)) {
					$q-&gt;removeowner($owner);
				}
				$ok=0;
				$fix=1;
			}
			else {
				$questions{$q-&gt;name}=$q;
			}
		}

		foreach my $t (keys %templates) {
			my @owners=$Debconf::Db::templates-&gt;owners($t);
			if (! @owners) {
				warn "template \"$t\" has no owners; removing it.";
				$Debconf::Db::templates-&gt;addowner($t, "killme","");
				$Debconf::Db::templates-&gt;removeowner($t, "killme");
				$fix=1;
			}
			foreach my $q (@owners) {
				if (! exists $questions{$q}) {
					warn "template \"$t\" claims to be used by nonexistent question \"$q\"; removing that.";
					$Debconf::Db::templates-&gt;removeowner($t, $q);
					$ok=0;
					$fix=1;
				}
			}
		}
		$counter++;
	} until ($ok || $counter &gt; 20);

	if ($fix) {
		Debconf::Db-&gt;save;
		exec($0, "end");
		die "exec of self failed";
	}
}

foreach my $templatefile (glob("/var/lib/dpkg/info/*.templates")) {
	my ($package) = $templatefile =~ m:/var/lib/dpkg/info/(.*?).templates:;
        Debconf::Template-&gt;load($templatefile, $package);
}

Debconf::Db-&gt;save;
</pre></body></html>