diff -urN debconf-1.1.10.orig/Debconf/ConfModule.pm debconf-1.1.10/Debconf/ConfModule.pm --- debconf-1.1.10.orig/Debconf/ConfModule.pm Sat Apr 13 20:04:22 2002 +++ debconf-1.1.10/Debconf/ConfModule.pm Sun Jun 16 21:50:53 2002 @@ -255,6 +255,7 @@ # not. my $visible=1; + print "Should I show $question_name ?\n"; # Noninteractive frontends never show anything. $visible='' if ! $this->frontend->interactive; @@ -265,8 +266,10 @@ $visible='' if Debconf::Config->showold() eq 'false' && $question->flag('seen') eq 'true'; + print "Nope\n" unless $visible; my $element; if ($visible) { + print "Yup\n"; # Create an input Element of the type associated with # the frontend. $element=$this->frontend->makeelement($question); diff -urN debconf-1.1.10.orig/Debconf/Config.pm debconf-1.1.10/Debconf/Config.pm --- debconf-1.1.10.orig/Debconf/Config.pm Sat Apr 13 19:42:46 2002 +++ debconf-1.1.10/Debconf/Config.pm Sun Jun 16 18:20:13 2002 @@ -285,6 +285,23 @@ return 'root'; } +=item answers_file + +Returns the location of the answers file for the `Managed' front-end. + +If not set, defaults to F. + +=cut + +sub answers_file { + + my $class = shift; + return $ENV{DEBCONF_ANSWERS} if exists $ENV{DEBCONF_ANSWERS}; + return $config->{answers_file} if exists $config->{answers_file}; + return "/etc/debconf/answers"; + +} + =back =head1 FIELDS diff -urN debconf-1.1.10.orig/Debconf/Element/Managed/Boolean.pm debconf-1.1.10/Debconf/Element/Managed/Boolean.pm --- debconf-1.1.10.orig/Debconf/Element/Managed/Boolean.pm Thu Jan 1 01:00:00 1970 +++ debconf-1.1.10/Debconf/Element/Managed/Boolean.pm Sun Jun 16 21:33:21 2002 @@ -0,0 +1,51 @@ +#!/usr/bin/perl -w + +=head1 NAME + +Debconf::Element::Managed::Boolean - Yes/No question + +=cut + +package Debconf::Element::Managed::Boolean; +use strict; +use Debconf::Gettext; +use base qw(Debconf::Element::Managed); + +=head1 DESCRIPTION + + +=head1 METHODS + +=over 4 + +=item pick + +=cut + +sub pick { + + my $this=shift; + my $current_value=shift; + my $managed_answer=shift; + my $template_answer=shift; + + if ( $current_value =~ m/^(true|false)$/ ) { + return $1; + } elsif ( $managed_answer =~ m/^(true|false)$/ ) { + return $1; + } elsif ( $template_answer =~ m/^(true|false)$/ ) { + return $1; + } else { + return "maybe"; + } +} + +=back + +=head1 AUTHOR + +Joey Hess + +=cut + +1 diff -urN debconf-1.1.10.orig/Debconf/Element/Managed/Multiselect.pm debconf-1.1.10/Debconf/Element/Managed/Multiselect.pm --- debconf-1.1.10.orig/Debconf/Element/Managed/Multiselect.pm Thu Jan 1 01:00:00 1970 +++ debconf-1.1.10/Debconf/Element/Managed/Multiselect.pm Sun Jun 16 22:24:25 2002 @@ -0,0 +1,41 @@ +#!/usr/bin/perl -w + +=head1 NAME + +Debconf::Element::Managed::Multiselect - select multiple items + +=cut + +package Debconf::Element::Managed::Multiselect; +use strict; +use Debconf::Gettext; +use Debconf::Config; +use base qw(Debconf::Element::Multiselect Debconf::Element::Managed::Select); + +=head1 DESCRIPTION + + +=cut + +sub pick { + + my $this = shift; + + $this->question->template->i18n(''); + my %choices = map { $_ => 0 } $this->question->choices_split; + $this->question->template->i18n(1); + + ANSWER: + for my $answer ( @_ ) { + defined $answer or next; + for my $choice ( split /,\s+/, $answer ) { + next ANSWER unless ( exists $choices{$choice} ); + } + return $answer; + } + + return "cowboyneal, 42"; +} + +1; + diff -urN debconf-1.1.10.orig/Debconf/Element/Managed/Note.pm debconf-1.1.10/Debconf/Element/Managed/Note.pm --- debconf-1.1.10.orig/Debconf/Element/Managed/Note.pm Thu Jan 1 01:00:00 1970 +++ debconf-1.1.10/Debconf/Element/Managed/Note.pm Sun Jun 16 22:37:39 2002 @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w + +=head1 NAME + +Debconf::Element::Managed::Note - A note to the user + +=cut + +package Debconf::Element::Managed::Note; +use strict; +use base qw(Debconf::Element::Managed); + +=head1 DESCRIPTION + +This is a note to the user, presented using a teletype. + +=cut + +=item show + +Notes are not shown in terse mode. + +=cut + +sub visible { + my $this=shift; + + return 1; +} + +sub pick { "" } + +1 diff -urN debconf-1.1.10.orig/Debconf/Element/Managed/Password.pm debconf-1.1.10/Debconf/Element/Managed/Password.pm --- debconf-1.1.10.orig/Debconf/Element/Managed/Password.pm Thu Jan 1 01:00:00 1970 +++ debconf-1.1.10/Debconf/Element/Managed/Password.pm Sun Jun 16 22:35:45 2002 @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w + +=head1 NAME + +Debconf::Element::Managed::Password - password input field + +=cut + +package Debconf::Element::Managed::Password; +use strict; +use base qw(Debconf::Element::Managed); + +=head1 DESCRIPTION + +This is a password input field. + +=head1 show + +Prompts for a password, without displaying it or echoing keystrokes. + +=cut + +sub pick { + my $this = shift; + + for my $answer ( @_ ) { + return $answer if $answer; + } + + return join "", map { chr(rand(64+32)) } (1..8); # :-) + +} + +1 diff -urN debconf-1.1.10.orig/Debconf/Element/Managed/Select.pm debconf-1.1.10/Debconf/Element/Managed/Select.pm --- debconf-1.1.10.orig/Debconf/Element/Managed/Select.pm Thu Jan 1 01:00:00 1970 +++ debconf-1.1.10/Debconf/Element/Managed/Select.pm Sun Jun 16 23:03:25 2002 @@ -0,0 +1,57 @@ +#!/usr/bin/perl -w + +=head1 NAME + +Debconf::Element::Managed::Select - select from a list of values + +=cut + +package Debconf::Element::Managed::Select; +use strict; +use Debconf::Config; +use POSIX qw(ceil); +use base qw(Debconf::Element::Select Debconf::Element::Managed); + +=head1 DESCRIPTION + +This lets the user pick from a number of values. + +=head1 METHODS + +=over 4 + +=cut + +sub pick { + + my $this = shift; + my ($current_value, $managed_answer, $template_default) = (@_); + + $this->question->template->i18n(''); + my %choices = map { $_ => 1 } $this->question->choices_split; + $this->question->template->i18n(1); + + $current_value && + exists $choices{$current_value} && + return $current_value; + + $managed_answer && + exists $choices{$managed_answer} && + return $managed_answer; + + $template_default && + exists $choices{$template_default} && + return $template_default; + + return "cowboyneal"; +} + +=back + +=head1 AUTHOR + +Joey Hess + +=cut + +1 diff -urN debconf-1.1.10.orig/Debconf/Element/Managed/String.pm debconf-1.1.10/Debconf/Element/Managed/String.pm --- debconf-1.1.10.orig/Debconf/Element/Managed/String.pm Thu Jan 1 01:00:00 1970 +++ debconf-1.1.10/Debconf/Element/Managed/String.pm Sun Jun 16 22:35:01 2002 @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w + +=head1 NAME + +Debconf::Element::Managed::String - string input field + +=cut + +package Debconf::Element::Managed::String; +use strict; +use base qw(Debconf::Element::Managed); + +=head1 DESCRIPTION + +This is a string input field. + +=cut + + +1 diff -urN debconf-1.1.10.orig/Debconf/Element/Managed/Text.pm debconf-1.1.10/Debconf/Element/Managed/Text.pm --- debconf-1.1.10.orig/Debconf/Element/Managed/Text.pm Thu Jan 1 01:00:00 1970 +++ debconf-1.1.10/Debconf/Element/Managed/Text.pm Sun Jun 16 22:35:22 2002 @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w + +=head1 NAME + +Debconf::Element::Managed::Text - show text to the user + +=cut + +package Debconf::Element::Managed::Text; +use strict; +use base qw(Debconf::Element::Managed); + +=head1 DESCRIPTION + +This is a peice of text to output to the user. + +=cut + + +1 diff -urN debconf-1.1.10.orig/Debconf/Element/Managed.pm debconf-1.1.10/Debconf/Element/Managed.pm --- debconf-1.1.10.orig/Debconf/Element/Managed.pm Thu Jan 1 01:00:00 1970 +++ debconf-1.1.10/Debconf/Element/Managed.pm Sun Jun 16 22:37:05 2002 @@ -0,0 +1,92 @@ +#!/usr/bin/perl -w + +=head1 NAME + +Debconf::Element::Managed - Dummy Element for Managed front-end + +=cut + +package Debconf::Element::Managed; +use strict; +use base qw(Debconf::Element); + +=head1 DESCRIPTION + +Special managed debconf front-end. + +=head1 METHODS + +=over 4 + +=item visible + +This type of element is not visible. Yes, kind of. + +=cut + +sub visible { + my $this=shift; + + return 1; +} + +=over 4 + +=item show_and_tell + +=cut + +sub show_and_tell { + + my $this=shift; + my $q = $this->question; + my $q_name = $q->name; + + my $current_value = shift; + my $template_default = shift; + my $managed_answer = shift; + + print( + "Managed Question ---\n", + "Question: ",$q_name, "\n", + "Type: ",$q->type(), "\n", + "Description: ",$q->description, "\n", + "Choices: ",$q->choices, "\n", + "Current value: ",(defined $current_value ? + "`$current_value'" : + "none"), "\n", + "Managed default: ",(defined $managed_answer ? + "`$managed_answer'" : + "none"), "\n", + "Template default: ",(defined $template_default ? + "`$template_default'" : + "none"), "\n", + ); + + my $value = $this->pick($current_value, + $managed_answer, + $template_default); + + print "New value: `", $value, "'\n"; + + $this->value($value); + +} + +sub pick { + my $this = shift; + + my @d = map { defined $_ ? $_ : () } @_; + + return shift @d; +} + +=back + +=head1 AUTHOR + +Sam Vilain + +=cut + +1 diff -urN debconf-1.1.10.orig/Debconf/Element/Teletype/Password.pm debconf-1.1.10/Debconf/Element/Teletype/Password.pm --- debconf-1.1.10.orig/Debconf/Element/Teletype/Password.pm Sat Apr 13 19:08:21 2002 +++ debconf-1.1.10/Debconf/Element/Teletype/Password.pm Sun Jun 16 22:33:50 2002 @@ -2,13 +2,13 @@ =head1 NAME -Debconf::Element::Teletype::Password - password input field +Debconf::Element::Managed::Password - password input field =cut -package Debconf::Element::Teletype::Password; +package Debconf::Element::Managed::Password; use strict; -use base qw(Debconf::Element); +use base qw(Debconf::Element::Managed); =head1 DESCRIPTION diff -urN debconf-1.1.10.orig/Debconf/FrontEnd/Managed.pm debconf-1.1.10/Debconf/FrontEnd/Managed.pm --- debconf-1.1.10.orig/Debconf/FrontEnd/Managed.pm Thu Jan 1 01:00:00 1970 +++ debconf-1.1.10/Debconf/FrontEnd/Managed.pm Sun Jun 16 21:21:44 2002 @@ -0,0 +1,147 @@ +#!/usr/bin/perl -w + +=head1 NAME + +Debconf::FrontEnd::Managed - FrontEnd for central, managed package configuration + +=cut + +package Debconf::FrontEnd::Managed; + +use strict; + +use Debconf::Config; +use Debconf::Db; +use base qw(Debconf::FrontEnd); + +=head1 DESCRIPTION + +This Debconf frontend is designed to answer package installation +questions by first reading answers to questions from a system-wide +configuration file, held under F. If the +environment variable C is set, then configuration +comes from there instead. + +=head1 FIELDS + +Inherited from Debconf::Frontend: + +=over 4 + +=item elements + +A reference to an array that contains all the elements that the FrontEnd +needs to show to the user. + +=item interactive + +Is this an interactive FrontEnd? + +=item capb + +Holds any special capabilities the FrontEnd supports. + +=item title + +The title of the FrontEnd. + +=item backup + +A flag that Elements can set when they are displayed, to tell the FrontEnd +that the user has indicated they want to back up. + +=item capb_backup + +This will be set if the confmodule states it has the backup capability. + +=back + +=head1 METHODS + +=over 4 + +=item init + +Sets several of the fields to defaults. + +=cut + +use vars qw(%answers); + +sub init { + my $this=shift; + + $this->SUPER::init(); + + $this->interactive(1); + $this->title('Managed'); + + my $filename = Debconf::Config->answers_file; + if ( !%answers and -f $filename ) { + print "Loading Debconf-Managed answers from $filename\n"; + open ANSWERS, "<$filename" + or die "Could not open $filename for reading; $!"; + + my $i = 0; + while ( ) { + $i++, chomp; + next if /^\s*(#.*)?$/; + + if ( /^([\w\-\/]+)\s*:\s*(.*?)\s*$/ ) { + $answers{$1} = $2; + } else { + die "Bad line $i of $filename: `$_'"; + } + } + } +} + +=item makeelement($question, $nodebug) + +Makes a new element for this question and returns it + +=cut + +use Debconf::Element::Managed; + +sub makeelement_vanilla { + my $this = shift; + my $question = shift; + my $nodebug = shift; + + return Debconf::Element::Managed->new(question => $question); +} + +=item go + +Display accumulated Elements to the user. + +=cut + +sub go { + + my $this=shift; + $this->backup(''); + foreach my $element (@{$this->elements}) { + + my $q = $element->question; + my $q_name = $q->name; + + $element->show_and_tell + ( + $Debconf::Db::config->getfield ($q_name, 'value'), + $q->template->default, + ( exists $answers{$q_name} ? $answers{$q_name} : () ) + ); + + } + return 1; +} + +=head1 AUTHOR + +Sam Vilain + +=cut + +1