Codebase list debconf / HEAD debconf-communicate
HEAD

Tree @HEAD (Download .tar.gz)

debconf-communicate @HEADraw · history · blame

#!/usr/bin/perl -w

=head1 NAME

debconf-communicate - communicate with debconf

=cut

=head1 SYNOPSIS

 echo commands | debconf-communicate [options] [package]

=head1 DESCRIPTION

B<debconf-communicate> allows you to communicate with debconf on the fly,
from the command line. The package argument is the name of the package
which you are pretending to be as you communicate with debconf, and it may
be omitted if you are lazy. It reads commands in the form used by the debconf
protocol from stdin. For documentation on the available commands and their
usage, see the debconf specification.

The commands are executed in sequence. The textual return code of each is
printed out to standard output.

The return value of this program is the numeric return code of the last
executed command.

=head1 EXAMPLE

 echo get debconf/frontend | debconf-communicate

Print out the value of the debconf/frontend question.

=head1 WARNING

This program should never be used from a maintainer script of a package
that uses debconf! It may however, be useful in debugging.

=head1 SEE ALSO

L<debconf-loadtemplate(1)>

=cut

use strict;
use Debconf::Db;
use Debconf::AutoSelect qw(:all);
use Debconf::Config;
use Debconf::Gettext;

Debconf::Db->load;

Debconf::Config->getopt(gettext("Usage: debconf-communicate [options] [package]"));

my $frontend=make_frontend();
my $confmodule=make_confmodule();
$confmodule->owner(shift) if @ARGV;
my $code=127;
autoflush STDOUT 1;

while (<>) {
	chomp;
	my $ret=$confmodule->process_command($_);
	($code, undef)=split(/ /, $ret, 2);
	print "$ret\n";
}

$frontend->shutdown;
$confmodule->finish;
Debconf::Db->save;
exit $code;

=head1 AUTHOR

Joey Hess <joeyh@debian.org>

=cut