home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / debconf < prev    next >
Encoding:
Text File  |  2007-03-24  |  2.5 KB  |  114 lines

  1. #!/usr/bin/perl -w
  2.  
  3. =head1 NAME
  4.  
  5. debconf - run a debconf-using program
  6.  
  7. =cut
  8.  
  9. =head1 SYNOPSIS
  10.  
  11.  debconf [options] command [args]
  12.  
  13. =head1 DESCRIPTION
  14.  
  15. Debconf is a configuration system for Debian packages. For a debconf
  16. overview and documentation for sysadmins, see L<debconf(7)> (in the
  17. debconf-doc package).
  18.  
  19. The B<debconf> program runs a program under debconf's control, setting it up
  20. to talk with debconf on stdio. The program's output is expected to be debconf
  21. protocol commands, and it is expected to read result codes on stdin. See
  22. L<debconf-devel(7)> for details about the debconf protocol.
  23.  
  24. The command to be run under debconf must be specified in a way that will
  25. let your PATH find it.
  26.  
  27. =head1 OPTIONS
  28.  
  29. =over 4
  30.  
  31. =item B<-o>I<package>, B<--owner=>I<package>
  32.  
  33. Tell debconf what package the command it is running is a part of. This is
  34. necessary to get ownership of registered questions right, and to support
  35. unregister and purge commands properly.
  36.  
  37. =item B<-f>I<type>, B<--frontend=>I<type>
  38.  
  39. Select the frontend to use.
  40.  
  41. =item B<-p>I<value>, B<--priority=>I<value>
  42.  
  43. Specify the minimum priority of question that will be displayed.
  44.  
  45. =back
  46.  
  47. =head1 EXAMPLES
  48.  
  49. To debug a shell script that uses debconf, you might use:
  50.  
  51.  DEBCONF_DEBUG=developer debconf my-shell-prog
  52.  
  53. Or, you might use this:
  54.  
  55.  debconf --frontend=readline sh -x my-shell-prog
  56.  
  57. =head1 SEE ALSO
  58.  
  59. L<debconf-devel(7)>, L<debconf(7)>
  60.  
  61. =cut
  62.  
  63. use strict;
  64. use Debconf::Db;
  65. use Debconf::AutoSelect qw(:all);
  66. use Debconf::Gettext;
  67. use Debconf::Config;
  68.  
  69. # Find the end of the options for this command, and the beginning of the
  70. # command to run, which may have arguments. Break those arguments out.
  71. my (@argv, @command);
  72. for (my $x=0; $x <= $#ARGV; $x++) {
  73.     if ($ARGV[$x] =~ /^-(o|f|p|-(owner|frontend|priority))$/) {
  74.         push @argv, $ARGV[$x++];
  75.         push @argv, $ARGV[$x]; # skip option argument
  76.         next;
  77.     }
  78.     elsif ($ARGV[$x] =~ /^-/) {
  79.         push @argv, $ARGV[$x];
  80.     }
  81.     else {
  82.         # end of arguments, start of command
  83.         @command=@ARGV[$x..$#ARGV];
  84.         last;
  85.     }
  86. }
  87. @ARGV=@argv;
  88. my $usage = gettext("Usage: debconf [options] command [args]");
  89. my $owner='';
  90. Debconf::Config->getopt($usage.gettext(qq{
  91.   -o,  --owner=package        Set the package that owns the command.}),
  92.         "o|owner=s"        => \$owner,
  93. );
  94. die "$usage\n" unless @command;
  95.  
  96. Debconf::Db->load;
  97. my $frontend=make_frontend();
  98. my $confmodule=make_confmodule(@command);
  99. $confmodule->owner($owner) if length $owner;
  100.  
  101. 1 while ($confmodule->communicate);
  102.  
  103. my $code=$confmodule->exitcode;
  104. $frontend->shutdown;
  105. $confmodule->finish;
  106. Debconf::Db->save;
  107. exit $code;
  108.  
  109. =head1 AUTHOR
  110.  
  111. Joey Hess <joeyh@debian.org>
  112.  
  113. =cut
  114.