[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: apt-utils



Dave Sherohman wrote:
> When did apt-utils become mandatory?  I just did an apt-get upgrade (in
> testing) and it died immediately after downloading packages with the message
> 
> debconf: cannot preconfigure packages -- apt-utils is not installed
> E: Failure running script /usr/sbin/dpkg-preconfigure --apt || true
> 
> Installing apt-utils fixed this, but I thought it was supposed to be
> optional.

It is supposed to be optional. In fact, I cannot see how it could
possibly be failing as you show. The || true is there so no matter what
status code dpkg-preconfigure returns, apt always sees a return code of
zero. The only possiblity I can think of is that perhaps apt is now
checking to see if the program read all of its input, and assuming it
failed if it chooses not to.

Jason, if it's doing that, I think that's a dumb heuistic. As you can
see, there are valid reasons for ignoring the input and not failing.

Dave, you might try the attached version of apt-extracttemplates, which
reads all the input no matter what (almost -- I can think of situations
where it will not read all of its input -- for example, suppose
/usr/bin/perl is broken -- and apt may refuse to continue, making it hard to
upgrade. That's why I think apt should not do this.)

> (No, I don't want to use it until it actually works.  In theory,
> apt-utils is supposed to let you answer all the packages' questions up front.
> In practice, every question that I answer up front is asked again later,
> completely ignoring my previous answers.  How is that supposed to be
> helpful?)

I have never seen this behavior except for when people have told debconf
to re-show questions, or with a couple of broken packages that force
debconf to redisplay seen questions. In the default configuration, it
works, and has worked for a long time.

-- 
see shy jo
#!/usr/bin/perl -w
# This file was preprocessed, do not edit directly.
BEGIN {
	eval qq{
		use strict;
		use FileHandle;
		use Debconf::Log qw(:all);
		use Debconf::Db;
		use Debconf::Template;
		use Debconf::Config;
		use Debconf::AutoSelect qw(:all);
		use Debconf::Gettext;
	};
	if ($@) {
		print STDERR "debconf: Perl may be unconfigured ($@) -- aborting\n";
		exit 0;
	}
}
Debconf::Db->load;
my $apt=0;
Debconf::Config->getopt( # TODO: i18n this? What's the best way to break it up?
qq{Syntax: dpkg-reconfigure [options] [debs]
       --apt		Apt mode.},
	"apt"		=> \$apt,
);
$|=1;
my @debs=@ARGV;
@ARGV=();
if ($apt) {
	while (<>) {
		chomp;
		push @debs, $_ if length $_;
	}
	
	exit unless @debs;
	
	open (STDIN, "/dev/tty") ||
		(print STDERR sprintf("dpkg-preconfigure: ".gettext("unable to re-open stdin: %s"), $!)."\n", exit 0);
	Debconf::Config->showold('false');
}
elsif (! @debs) {
	print STDERR sprintf("dpkg-preconfigure: ".gettext("must specify some debs to preconfigure")), "\n";
	exit(1);
}

if (! -x "/usr/bin/apt-extracttemplates") {
	warn gettext("(not preconfiguring packages since apt-utils is not installed)");
	exit;
}

my $frontend=make_frontend();
my ($package, $version, $template, $config);
unless (open(INFO, "-|")) {
	exec "apt-extracttemplates", @debs or
		print STDERR "debconf: exec of apt-extracttemplates failed: $!";
}
my @buffer=<INFO>;
if ($apt && @buffer) {
	print "Preconfiguring packages ...\n";
}
foreach my $line (@buffer) {
	($package, $version, $template, $config)=split /\s/, $line;
	
	if (defined $template && length $template) {
		eval q{
			Debconf::Template->load($template, $package)
		};
		unlink $template;
		if ($@) {
			print STDERR "$package ".sprintf(gettext("template parse error: %s"), $@)."\n";
			unlink $config;
			next;
		}
	}
}
foreach my $line (@buffer) {
	($package, $version, $template, $config)=split /\s/, $line;
	if (defined $config && length $config && -e $config) {
		debug user => "preconfiguring $package ($version)";
		chmod(0755, $config) or
			die sprintf(gettext("debconf: can't chmod: %s"), $!);
		$frontend->default_title($package);
		my $confmodule=make_confmodule($config, 'configure', $version);
		$confmodule->owner($package);
		1 while ($confmodule->communicate);
		if ($confmodule->exitcode > 0) {
			print STDERR sprintf(
				gettext("%s failed to preconfigure, with exit status %s"),
				$package, $confmodule->exitcode)."\n";
		}
		unlink $config;
	}
}
$frontend->shutdown;
Debconf::Db->save;

Reply to: