5
dpkg-reconfigure - reconfigure an already installed package
9
dpkg-reconfigure [options] packages
13
B<dpkg-reconfigure> reconfigures packages after they have already been
14
installed. Pass it the names of a package or packages to reconfigure. It
15
will ask configuration questions, much like when the package was first
18
If you just want to see the current configuration of a package, see
19
L<debconf-show(1)> instead.
25
=item B<-f>I<type>, B<--frontend=>I<type>
27
Select the frontend to use. The default frontend can be permanently changed
30
dpkg-reconfigure debconf
32
Note that if you normally have debconf set to use the noninteractive
33
frontend, dpkg-reconfigure will use the dialog frontend instead, so you
34
actually get to reconfigure the package.
36
=item B<-p>I<value>, B<--priority=>I<value>
38
Specify the minimum priority of question that will be displayed.
39
dpkg-reconfigure normally shows low priority questions no matter what your
40
default priority is. See L<debconf(7)> for a list.
42
=item B<--default-priority>
44
Use whatever the default priority of question is, instead of forcing the
49
Reconfigure all installed packages that use debconf. Warning: this may take
52
=item B<-u>, B<--unseen-only>
54
By default, all questions are shown, even if they have already been
55
answered. If this parameter is set though, only questions that have not yet
56
been seen will be asked.
60
Force dpkg-reconfigure to reconfigure a package even if the package is in an
61
inconsistent or broken state. Use with caution.
65
Prevent dpkg-reconfigure from reloading templates. Use with caution; this
66
will prevent dpkg-reconfigure from repairing broken templates databases.
67
However, it may be useful in constrained environments where rewriting the
68
templates database is expensive.
70
=item B<-h>, B<--help>
84
my $infodir="/var/lib/dpkg/info";
89
use Debconf::Template;
91
use Debconf::AutoSelect qw(:all);
92
use Debconf::Log qw(:all);
94
# Use low priority unless an option below overrides.
95
Debconf::Config->priority('low');
100
my $default_priority=0;
102
Debconf::Config->getopt(
103
gettext(qq{Usage: dpkg-reconfigure [options] packages
104
-a, --all Reconfigure all packages.
105
-u, --unseen-only Show only not yet seen questions.
106
--default-priority Use default priority instead of low.
107
--force Force reconfiguration of broken packages.
108
--no-reload Do not reload templates. (Use with caution.)}),
110
"unseen-only|u" => \$unseen_only,
111
"default-priority" => \$default_priority,
113
"reload!" => \$reload,
117
print STDERR sprintf(gettext("%s must be run as root"), $0)."\n";
123
if ($default_priority) {
124
Debconf::Config->priority(Debconf::Question->get('debconf/priority')->value);
127
# If the frontend is noninteractive, change it temporarily to dialog.
128
if (lc Debconf::Config->frontend eq 'noninteractive' &&
129
! Debconf::Config->frontend_forced) {
130
Debconf::Config->frontend('dialog');
133
my $frontend=make_frontend();
135
unless ($unseen_only) {
136
# Make the frontend show questions even if the user has already seen
137
# them. Since this is a reconfigure program, they may want to change
139
Debconf::Config->reshow(1);
144
@packages=allpackages();
145
exit unless @packages;
150
print STDERR "$0: ".gettext("please specify a package to reconfigure")."\n";
155
# This is a hack to let postinsts know when they're being reconfigured. It
156
# would of course be better to pass them "reconfigure", but we can't for
157
# hysterical raisens.
158
$ENV{DEBCONF_RECONFIGURE}=1;
160
foreach my $pkg (@packages) {
162
$frontend->default_title($pkg);
163
$frontend->info(undef);
165
# Get the package version. Also check to make sure it is installed.
166
$_=`dpkg --status $pkg`;
167
my ($version)=m/Version: (.*)\n/;
168
my ($status)=m/Status: (.*)\n/;
170
if (! defined $status || $status =~ m/not-installed$/) {
171
print STDERR "$0: ".sprintf(gettext("%s is not installed"), $pkg)."\n";
174
if ($status !~ m/ ok installed$/) {
175
print STDERR "$0: ".sprintf(gettext("%s is broken or not fully installed"), $pkg)."\n";
181
# Load up templates just in case they aren't already.
182
Debconf::Template->load("$infodir/$pkg.templates", $pkg)
183
if -e "$infodir/$pkg.templates";
186
# Simulation of reinstalling a package, without bothering with
187
# removing the files and putting them back. Just like in a regular
188
# reinstall, run config, and postinst scripts in sequence, with args.
189
# Do not run postrm, because the postrm can depend on the package's
190
# files actually being gone already.
191
foreach my $info (['prerm', 'upgrade', $version],
192
['config', 'reconfigure', $version],
193
['postinst', 'configure', $version]) {
194
my $script=shift @$info;
195
next unless -x "$infodir/$pkg.$script";
197
my $is_confmodule='';
199
if ($script ne 'config') {
200
# Test to see if the script uses debconf.
201
open (IN, "<$infodir/$pkg.$script");
211
if ($script eq 'config' || $is_confmodule) {
212
# Start up the confmodule.
213
my $confmodule=make_confmodule(
214
"$infodir/$pkg.$script", @$info);
216
# Make sure any questions the confmodule registers
217
# are owned by this package.
218
$confmodule->owner($pkg);
220
# Talk to it until it is done.
221
1 while ($confmodule->communicate);
223
exit $confmodule->exitcode if $confmodule->exitcode > 0;
226
# Not a confmodule, so run it as a normal script.
227
# Since it might run other programs that do use
228
# debconf, checkpoint the current database state
229
# and re-initialize it when the script finishes.
232
delete $ENV{DEBIAN_HAS_FRONTEND};
233
my $ret=system("$infodir/$pkg.$script", @$info);
234
if (int($ret / 256) != 0) {
235
exit int($ret / 256);
237
$ENV{DEBIAN_HAS_FRONTEND}=1;
248
# Returns a list of all installed packages.
253
open (STATUS, "</var/lib/dpkg/status")
254
|| die sprintf(gettext("Cannot read status file: %s"), $!);
257
if m/Status:\s*.*\sinstalled\n/ && m/Package:\s*(.*)\n/;
266
Joey Hess <joeyh@debian.org>