| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
debconf-get-selections - output contents of debconf database |
| 6 |
|
| 7 |
=head1 SYNOPSIS |
| 8 |
|
| 9 |
debconf-get-selections [--installer] |
| 10 |
|
| 11 |
=head1 DESCRIPTION |
| 12 |
|
| 13 |
Output the current debconf database in a format understandable by |
| 14 |
debconf-set-selections. |
| 15 |
|
| 16 |
To dump the debconf database of the debian-installer, from |
| 17 |
/var/log/installer/cdebconf, use the --installer |
| 18 |
parameter. |
| 19 |
|
| 20 |
=cut |
| 21 |
|
| 22 |
use strict; |
| 23 |
use warnings; |
| 24 |
use Debconf::Db; |
| 25 |
use Debconf::Template; |
| 26 |
use Debconf::Question; |
| 27 |
|
| 28 |
Debconf::Db->load(readonly => "true"); |
| 29 |
|
| 30 |
my $defaultowner="unknown"; |
| 31 |
|
| 32 |
if (@ARGV && $ARGV[0] eq '--installer') { |
| 33 |
# A bit of a hack.. |
| 34 |
my $di_path; |
| 35 |
if (-d "/var/log/installer") { |
| 36 |
$di_path="/var/log/installer/cdebconf"; |
| 37 |
} else { |
| 38 |
$di_path="/var/log/debian-installer/cdebconf"; |
| 39 |
} |
| 40 |
$Debconf::Db::config=Debconf::Db->makedriver( |
| 41 |
driver => "File", |
| 42 |
name => "di_questions", |
| 43 |
filename => "$di_path/questions.dat", |
| 44 |
readonly => "true", |
| 45 |
); |
| 46 |
$Debconf::Db::templates=Debconf::Db->makedriver( |
| 47 |
driver => "File", |
| 48 |
name => "di_templates", |
| 49 |
filename => "$di_path/templates.dat", |
| 50 |
readonly => "true", |
| 51 |
); |
| 52 |
$defaultowner="d-i"; |
| 53 |
} |
| 54 |
|
| 55 |
my $qi = Debconf::Question->iterator; |
| 56 |
my @qs; |
| 57 |
|
| 58 |
while (my $q = $qi->iterate) { |
| 59 |
push @qs, $q; |
| 60 |
} |
| 61 |
for my $q (sort { $a->name cmp $b->name } @qs) { |
| 62 |
my ($name, $type, $value) = ($q->name, $q->type, $q->value); |
| 63 |
next if (! length $type || $type eq 'text' || $type eq 'title'); |
| 64 |
print "# ".$q->description."\n"; |
| 65 |
if ($q->type eq 'select' || $q->type eq 'multiselect') { |
| 66 |
print "# Choices: ".join(", ", $q->choices)."\n"; |
| 67 |
} |
| 68 |
if ($q->owners) { |
| 69 |
foreach my $owner (split ", ", $q->owners) { |
| 70 |
print "$owner\t$name\t$type\t$value\n"; |
| 71 |
} |
| 72 |
} |
| 73 |
else { |
| 74 |
print "$defaultowner\t$name\t$type\t$value\n"; |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
=head1 AUTHOR |
| 79 |
|
| 80 |
Petter Reinholdtsen <[email protected]> |
| 81 |
|
| 82 |
=cut |