| 1 |
#!/usr/bin/perl -w
|
| 2 |
|
| 3 |
=head1 NAME
|
| 4 |
|
| 5 |
debconf - runs a program under debconf
|
| 6 |
|
| 7 |
=head1 SYNOPSIS
|
| 8 |
|
| 9 |
debconf owner [options] program [params]
|
| 10 |
|
| 11 |
=head1 DESCRIPTION
|
| 12 |
|
| 13 |
This program runs a program that uses debconf, and talkes to it via the
|
| 14 |
debconf protocol, accessing the database and displaying questions as
|
| 15 |
directed.
|
| 16 |
|
| 17 |
=head1 OPTIONS
|
| 18 |
|
| 19 |
=over 4
|
| 20 |
|
| 21 |
=item B<-f>I<type>, B<--frontend=>I<type>
|
| 22 |
|
| 23 |
Specify a debconf frontend to use.
|
| 24 |
|
| 25 |
=item B<-p>I<value>, B<--priority=>I<value>
|
| 26 |
|
| 27 |
Specify the minimum priority of question that will be displayed.
|
| 28 |
|
| 29 |
=item B<--package>=I<package>
|
| 30 |
|
| 31 |
Tell debconf what package the program is a part of. Recommended.
|
| 32 |
|
| 33 |
=item B<-t>I<file>, B<--templates>=I<file>
|
| 34 |
|
| 35 |
Load up the specified file as a templates file first.
|
| 36 |
|
| 37 |
=back
|
| 38 |
|
| 39 |
=head 1 RETURN VALUE
|
| 40 |
|
| 41 |
This program returns the return code of the program it runs.
|
| 42 |
|
| 43 |
=cut
|
| 44 |
|
| 45 |
use strict;
|
| 46 |
use Debconf::Db;
|
| 47 |
use Debconf::Template;
|
| 48 |
use Debconf::AutoSelect qw(:all);
|
| 49 |
use Debconf::Log qw(:all);
|
| 50 |
use Debconf::Config;
|
| 51 |
use Debconf::Gettext;
|
| 52 |
|
| 53 |
Debconf::Db->load;
|
| 54 |
|
| 55 |
my $templates='';
|
| 56 |
my $package='';
|
| 57 |
Debconf::Config->getopt( # TODO: i18n this? What's the best way to break it up?
|
| 58 |
qq{Syntax: debconf [options] program [params]
|
| 59 |
-t, --templates Load specified templates file.
|
| 60 |
--package Specifiy package the program is part of.},
|
| 61 |
"templates|t=s", \$templates,
|
| 62 |
"package=s", \$package,
|
| 63 |
);
|
| 64 |
|
| 65 |
if (! @ARGV) {
|
| 66 |
warn gettext("you must specify a program to run");
|
| 67 |
exit(1);
|
| 68 |
}
|
| 69 |
|
| 70 |
my $frontend=make_frontend();
|
| 71 |
$frontend->default_title($package);
|
| 72 |
|
| 73 |
# Load templates.
|
| 74 |
if (length $templates) {
|
| 75 |
debug developer => "loading templates from $templates";
|
| 76 |
Debconf::Template->load($templates, $package);
|
| 77 |
}
|
| 78 |
|
| 79 |
# Start up the confmodule we were asked to run.
|
| 80 |
my $confmodule=make_confmodule(join " ", @ARGV);
|
| 81 |
|
| 82 |
# Make sure any questions the confmodule generates are owned by this package.
|
| 83 |
$confmodule->owner($package) if length $package;
|
| 84 |
|
| 85 |
# Talk to it until it is done.
|
| 86 |
1 while ($confmodule->communicate);
|
| 87 |
|
| 88 |
# End.
|
| 89 |
$frontend->shutdown;
|
| 90 |
Debconf::Db->save;
|
| 91 |
exit $confmodule->exitcode;
|
| 92 |
|
| 93 |
=head1 AUTHOR
|
| 94 |
|
| 95 |
Joey Hess <joey@kitenet.net>
|
| 96 |
|
| 97 |
=cut
|