| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
debconf-communicate - communicate with debconf |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
=head1 SYNOPSIS |
| 10 |
|
| 11 |
echo commands | debconf-communicate [options] [package] |
| 12 |
|
| 13 |
=head1 DESCRIPTION |
| 14 |
|
| 15 |
B<debconf-communicate> allows you to communicate with debconf on the fly, |
| 16 |
from the command line. The package argument is the name of the package |
| 17 |
which you are pretending to be as you communicate with debconf, and it may |
| 18 |
be omitted if you are lazy. It reads commands in the form used by the debconf |
| 19 |
protocol from stdin. For documentation on the available commands and their |
| 20 |
usage, see the debconf specification. |
| 21 |
|
| 22 |
The commands are executed in sequence. The textual return code of each is |
| 23 |
printed out to standard output. |
| 24 |
|
| 25 |
The return value of this program is the numeric return code of the last |
| 26 |
executed command. |
| 27 |
|
| 28 |
=head1 EXAMPLE |
| 29 |
|
| 30 |
echo get debconf/frontend | debconf-communicate |
| 31 |
|
| 32 |
Print out the value of the debconf/frontend question. |
| 33 |
|
| 34 |
=head1 WARNING |
| 35 |
|
| 36 |
This program should never be used from a maintainer script of a package |
| 37 |
that uses debconf! It may however, be useful in debugging. |
| 38 |
|
| 39 |
=head1 SEE ALSO |
| 40 |
|
| 41 |
L<debconf-loadtemplate(1)> |
| 42 |
|
| 43 |
=cut |
| 44 |
|
| 45 |
use warnings; |
| 46 |
use strict; |
| 47 |
use Debconf::Db; |
| 48 |
use Debconf::AutoSelect qw(:all); |
| 49 |
use Debconf::Config; |
| 50 |
use Debconf::Gettext; |
| 51 |
|
| 52 |
Debconf::Db->load; |
| 53 |
|
| 54 |
Debconf::Config->getopt(gettext("Usage: debconf-communicate [options] [package]")); |
| 55 |
|
| 56 |
my $frontend=make_frontend(); |
| 57 |
my $confmodule=make_confmodule(); |
| 58 |
$confmodule->owner(shift) if @ARGV; |
| 59 |
my $code=127; |
| 60 |
autoflush STDOUT 1; |
| 61 |
|
| 62 |
while (<STDIN>) { |
| 63 |
chomp; |
| 64 |
my $ret=$confmodule->process_command($_); |
| 65 |
($code, undef)=split(/ /, $ret, 2); |
| 66 |
print "$ret\n"; |
| 67 |
} |
| 68 |
|
| 69 |
$frontend->shutdown; |
| 70 |
$confmodule->finish; |
| 71 |
Debconf::Db->save; |
| 72 |
exit $code; |
| 73 |
|
| 74 |
=head1 AUTHOR |
| 75 |
|
| 76 |
Joey Hess <[email protected]> |
| 77 |
|
| 78 |
=cut |