/usr/share/perl5/Debconf/Question.pm is in debconf 1.5.42ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | #!/usr/bin/perl -w
# This file was preprocessed, do not edit!
package Debconf::Question;
use strict;
use Debconf::Db;
use Debconf::Template;
use Debconf::Iterator;
use Debconf::Log qw(:all);
use fields qw(name priority);
our %question;
sub new {
my Debconf::Question $this=shift;
my $name=shift;
my $owner=shift;
my $type=shift || die "no type given for question";
die "A question called \"$name\" already exists"
if exists $question{$name};
unless (ref $this) {
$this = fields::new($this);
}
$this->{name}=$name;
return unless defined $this->addowner($owner, $type);
$this->flag('seen', 'false');
return $question{$name}=$this;
}
sub get {
my Debconf::Question $this=shift;
my $name=shift;
return $question{$name} if exists $question{$name};
if ($Debconf::Db::config->exists($name)) {
$this = fields::new($this);
$this->{name}=$name;
return $question{$name}=$this;
}
return undef;
}
sub iterator {
my $this=shift;
my $real_iterator=$Debconf::Db::config->iterator;
return Debconf::Iterator->new(callback => sub {
return unless my $name=$real_iterator->iterate;
return $this->get($name);
});
}
sub _expand_vars {
my $this=shift;
my $text=shift;
return '' unless defined $text;
my @vars=$Debconf::Db::config->variables($this->{name});
my $rest=$text;
my $result='';
my $variable;
my $varval;
my $escape;
while ($rest =~ m/^(.*?)(\\)?\${([^{}]+)}(.*)$/sg) {
$result.=$1; # copy anything before the variable
$escape=$2;
$variable=$3;
$rest=$4; # continue trying to expand rest of text
if (defined $escape && length $escape) {
$result.="\${$variable}";
}
else {
$varval=$Debconf::Db::config->getvariable($this->{name}, $variable);
$result.=$varval if defined($varval); # expand the variable
}
}
$result.=$rest; # add on anything that's left.
return $result;
}
sub description {
my $this=shift;
return $this->_expand_vars($this->template->description);
}
sub extended_description {
my $this=shift;
return $this->_expand_vars($this->template->extended_description);
}
sub choices {
my $this=shift;
return $this->_expand_vars($this->template->choices);
}
sub choices_split {
my $this=shift;
my @items;
my $item='';
for my $chunk (split /(\\[, ]|,\s+)/, $this->choices) {
if ($chunk=~/^\\([, ])$/) {
$item.=$1;
} elsif ($chunk=~/^,\s+$/) {
push @items, $item;
$item='';
} else {
$item.=$chunk;
}
}
push @items, $item if $item ne '';
return @items;
}
sub variable {
my $this=shift;
my $var=shift;
if (@_) {
return $Debconf::Db::config->setvariable($this->{name}, $var, shift);
}
else {
return $Debconf::Db::config->getvariable($this->{name}, $var);
}
}
sub flag {
my $this=shift;
my $flag=shift;
if ($flag eq 'isdefault') {
debug developer => "The isdefault flag is deprecated, use the seen flag instead";
if (@_) {
my $value=(shift eq 'true') ? 'false' : 'true';
$Debconf::Db::config->setflag($this->{name}, 'seen', $value);
}
return ($Debconf::Db::config->getflag($this->{name}, 'seen') eq 'true') ? 'false' : 'true';
}
if (@_) {
return $Debconf::Db::config->setflag($this->{name}, $flag, shift);
}
else {
return $Debconf::Db::config->getflag($this->{name}, $flag);
}
}
sub value {
my $this = shift;
unless (@_) {
my $ret=$Debconf::Db::config->getfield($this->{name}, 'value');
return $ret if defined $ret;
return $this->template->default if ref $this->template;
} else {
return $Debconf::Db::config->setfield($this->{name}, 'value', shift);
}
}
sub value_split {
my $this=shift;
my $value=$this->value;
$value='' if ! defined $value;
my @items;
my $item='';
for my $chunk (split /(\\[, ]|,\s+)/, $value) {
if ($chunk=~/^\\([, ])$/) {
$item.=$1;
} elsif ($chunk=~/^,\s+$/) {
push @items, $item;
$item='';
} else {
$item.=$chunk;
}
}
push @items, $item if $item ne '';
return @items;
}
sub addowner {
my $this=shift;
return $Debconf::Db::config->addowner($this->{name}, shift, shift);
}
sub removeowner {
my $this=shift;
my $template=$Debconf::Db::config->getfield($this->{name}, 'template');
return unless $Debconf::Db::config->removeowner($this->{name}, shift);
if (length $template and
not $Debconf::Db::config->exists($this->{name})) {
$Debconf::Db::templates->removeowner($template, $this->{name});
delete $question{$this->{name}};
}
}
sub owners {
my $this=shift;
return join(", ", sort($Debconf::Db::config->owners($this->{name})));
}
sub template {
my $this=shift;
if (@_) {
my $oldtemplate=$Debconf::Db::config->getfield($this->{name}, 'template');
my $newtemplate=shift;
if (not defined $oldtemplate or $oldtemplate ne $newtemplate) {
$Debconf::Db::templates->removeowner($oldtemplate, $this->{name})
if defined $oldtemplate and length $oldtemplate;
$Debconf::Db::config->setfield($this->{name}, 'template', $newtemplate);
$Debconf::Db::templates->addowner($newtemplate, $this->{name},
$Debconf::Db::templates->getfield($newtemplate, "type"));
}
}
return Debconf::Template->get(
$Debconf::Db::config->getfield($this->{name}, 'template'));
}
sub name {
my $this=shift;
return $this->{name};
}
sub priority {
my $this=shift;
$this->{priority}=shift if @_;
return $this->{priority};
}
sub AUTOLOAD {
(my $field = our $AUTOLOAD) =~ s/.*://;
no strict 'refs';
*$AUTOLOAD = sub {
my $this=shift;
if (@_) {
return $Debconf::Db::config->setfield($this->{name}, $field, shift);
}
my $ret=$Debconf::Db::config->getfield($this->{name}, $field);
unless (defined $ret) {
$ret = $this->template->$field() if ref $this->template;
}
if (defined $ret) {
if ($field =~ /^(?:description|extended_description|choices)-/i) {
return $this->_expand_vars($ret);
} else {
return $ret;
}
}
};
goto &$AUTOLOAD;
}
sub DESTROY {
}
1
|