File: debconf-get-selections

package info (click to toggle)
debconf 1.5.92
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,176 kB
  • sloc: perl: 8,500; sh: 262; python: 182; makefile: 147
file content (82 lines) | stat: -rwxr-xr-x 1,759 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/perl

=head1 NAME

debconf-get-selections - output contents of debconf database

=head1 SYNOPSIS

debconf-get-selections [--installer]

=head1 DESCRIPTION

Output the current debconf database in a format understandable by
debconf-set-selections.

To dump the debconf database of the debian-installer, from
/var/log/installer/cdebconf, use the --installer
parameter.

=cut

use strict;
use warnings;
use Debconf::Db;
use Debconf::Template;
use Debconf::Question;

Debconf::Db->load(readonly => "true");

my $defaultowner="unknown";

if (@ARGV && $ARGV[0] eq '--installer') {
	# A bit of a hack..
	my $di_path;
	if (-d "/var/log/installer") {
		$di_path="/var/log/installer/cdebconf";
	} else {
		$di_path="/var/log/debian-installer/cdebconf";
	}
	$Debconf::Db::config=Debconf::Db->makedriver(
		driver => "File",
		name => "di_questions",
		filename => "$di_path/questions.dat",
		readonly => "true",
	);
	$Debconf::Db::templates=Debconf::Db->makedriver(
		driver => "File",
		name => "di_templates",
		filename => "$di_path/templates.dat",
		readonly => "true",
	);
	$defaultowner="d-i";
}

my $qi = Debconf::Question->iterator;
my @qs;

while (my $q = $qi->iterate) {
	push @qs, $q;
}
for my $q (sort { $a->name cmp $b->name } @qs) {
	my ($name, $type, $value) = ($q->name, $q->type, $q->value);
	next if (! length $type || $type eq 'text' || $type eq 'title');
	print "# ".$q->description."\n";
	if ($q->type eq 'select' || $q->type eq 'multiselect') {
		print "# Choices: ".join(", ", $q->choices)."\n";
	}
	if ($q->owners) {
		foreach my $owner (split ", ", $q->owners) {
			print "$owner\t$name\t$type\t$value\n";
		}
	}
	else {
		print "$defaultowner\t$name\t$type\t$value\n";
	}
}

=head1 AUTHOR

Petter Reinholdtsen <pere@hungry.com>

=cut