tags 588818 + patch thanks On Mon, Jul 12, 2010 at 05:46:50PM +0200, Cyril Brulebois wrote: > as mentioned earlier, DEBIAN_FRONTEND doesn't get set to noninteractive > when using the aptitude resolver. The internal one uses run_apt, which > takes care of setting a sane(r) environment, while the aptitude one > calls aptitude directly, w/o setting DEBIAN_FRONTEND=noninteractive in > the environment. > > That broke building a package pulling some debconf-using > build-dependencies, and interrupting the build broke the chroots, > meaning manual cleanup. Hence the severity.
I've attached a proof of concept patch to fix this. Please could you give it a try? It's possible it needs a bit of tweaking; I'm afraid I'm pushed for time so it's untested tonight. Essentially, we add explicit support for Aptitude to Sbuild::Chroot so that there are pipe_aptitude_command etc. methods just like pipe_apt_command. These take care of setting up common aptitude options and work just as for apt-get. Note I'm not sure if it respects all of the apt-get options such as Dir::State, DPkg::Options and DPkg::Run-Directory which are essential for $chroot_mode="split". If you could verify that works too, I would appreciate it. Regards, Roger -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/ `- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
diff --git a/configure.ac b/configure.ac index 8214a5d..0ac8d48 100644 --- a/configure.ac +++ b/configure.ac @@ -85,6 +85,7 @@ fi # Checks for programs. AC_PATH_PROG([APT_CACHE], [apt-cache]) +AC_PATH_PROG([APTITUDE], [aptitude]) AC_PATH_PROG([APT_GET], [apt-get]) AC_PATH_PROG([CHMOD], [chmod]) AC_PATH_PROG([DATE], [date]) diff --git a/debian/rules b/debian/rules index aee0b55..55561ff 100755 --- a/debian/rules +++ b/debian/rules @@ -16,7 +16,8 @@ debian/build/config.status: configure DCMD=/usr/bin/dcmd \ SCHROOT=/usr/bin/schroot \ SSH=/usr/bin/ssh \ - SUDO=/usr/bin/sudo + SUDO=/usr/bin/sudo \ + APTITUDE=/usr/bin/aptitude build: debian/build/config.status debian/build-stamp debian/build-stamp: debian/build/config.status diff --git a/lib/Sbuild/AptitudeBuildDepSatisfier.pm b/lib/Sbuild/AptitudeBuildDepSatisfier.pm index e1c68f9..0685c00 100644 --- a/lib/Sbuild/AptitudeBuildDepSatisfier.pm +++ b/lib/Sbuild/AptitudeBuildDepSatisfier.pm @@ -149,11 +149,11 @@ EOF my @non_default_deps = $self->get_non_default_deps($dep, {}); my @aptitude_install_command = ( - 'aptitude', - '-y', - '--without-recommends', - '-o', 'APT::Install-Recommends=false', - '-o', 'Aptitude::ProblemResolver::StepScore=100', + $self->get_conf('APTITUDE'), + '-y', + '--without-recommends', + '-o', 'APT::Install-Recommends=false', + '-o', 'Aptitude::ProblemResolver::StepScore=100', '-o', "Aptitude::ProblemResolver::Hints::KeepDummy=reject $dummy_pkg_name :UNINST", '-o', 'Aptitude::ProblemResolver::Keep-All-Tier=55000', '-o', 'Aptitude::ProblemResolver::Remove-Essential-Tier=maximum', @@ -164,8 +164,9 @@ EOF $builder->log(join(" ", @aptitude_install_command), "\n"); - my $pipe = $session->pipe_command( + my $pipe = $session->pipe_aptitude_command( { COMMAND => \...@aptitude_install_command, + ENV => {'DEBIAN_FRONTEND' => 'noninteractive'}, PIPE => 'in', USER => 'root', CHROOT => 1, diff --git a/lib/Sbuild/Chroot.pm b/lib/Sbuild/Chroot.pm index b27c6de..5f06986 100644 --- a/lib/Sbuild/Chroot.pm +++ b/lib/Sbuild/Chroot.pm @@ -132,11 +132,17 @@ sub _setup_options { '-o', "DPkg::Options::=--root=$chroot_dir", '-o', "DPkg::Run-Directory=$chroot_dir"]); + $self->set('Aptitude Options', + ['-o', "Dir::State::status=$chroot_dir/var/lib/dpkg/status", + '-o', "DPkg::Options::=--root=$chroot_dir", + '-o', "DPkg::Run-Directory=$chroot_dir"]); + # sudo uses an absolute path on the host system. $self->get('Defaults')->{'ENV'}->{'APT_CONFIG'} = $self->get('Chroot APT Conf'); } else { # no split $self->set('APT Options', []); + $self->set('Aptitude Options', []); $self->get('Defaults')->{'ENV'}->{'APT_CONFIG'} = $self->get('APT Conf'); } @@ -404,6 +410,55 @@ sub pipe_apt_command { return $self->pipe_command_internal($options); } +sub get_aptitude_command_internal { + my $self = shift; + my $options = shift; + + my $command = $options->{'COMMAND'}; + my $apt_options = $self->get('Aptitude Options'); + + debug("Aptitude Options: ", join(" ", @$apt_options), "\n") + if defined($apt_options); + + my @aptcommand = (); + if (defined($apt_options)) { + push(@aptcommand, @{$command}[0]); + push(@aptcommand, @$apt_options); + if ($#$command > 0) { + push(@aptcommand, @{$command}[1 .. $#$command]); + } + } else { + @aptcommand = @$command; + } + + debug("APT Command: ", join(" ", @aptcommand), "\n"); + + $options->{'CHROOT'} = $self->apt_chroot(); + $options->{'CHDIR_CHROOT'} = !$options->{'CHROOT'}; + + $options->{'INTCOMMAND'} = \...@aptcommand; +} + +sub run_aptitude_command { + my $self = shift; + my $options = shift; + + # Set modfied command + $self->get_aptitude_command_internal($options); + + return $self->run_command_internal($options); +} + +sub pipe_aptitude_command { + my $self = shift; + my $options = shift; + + # Set modfied command + $self->get_aptitude_command_internal($options); + + return $self->pipe_command_internal($options); +} + sub apt_chroot { my $self = shift; diff --git a/lib/Sbuild/Conf.pm b/lib/Sbuild/Conf.pm index c3f895e..3003290 100644 --- a/lib/Sbuild/Conf.pm +++ b/lib/Sbuild/Conf.pm @@ -166,6 +166,10 @@ sub init_allowed_keys { CHECK => $validate_program, DEFAULT => $Sbuild::Sysconfig::programs{'APT_CACHE'} }, + 'APTITUDE' => { + CHECK => $validate_program, + DEFAULT => $Sbuild::Sysconfig::programs{'APTITUDE'} + }, 'DPKG_BUILDPACKAGE_USER_OPTIONS' => { DEFAULT => [] }, @@ -505,6 +509,7 @@ sub read_config { my $fakeroot = undef; my $apt_get = undef; my $apt_cache = undef; + my $aptitude = undef; my $dpkg_source = undef; my $dcmd = undef; my $md5sum = undef; @@ -592,6 +597,7 @@ sub read_config { $self->set('FAKEROOT', $fakeroot); $self->set('APT_GET', $apt_get); $self->set('APT_CACHE', $apt_cache); + $self->set('APTITUDE', $aptitude); $self->set('DPKG_SOURCE', $dpkg_source); $self->set('DCMD', $dcmd); $self->set('MD5SUM', $md5sum); diff --git a/lib/Sbuild/Sysconfig.pm.in b/lib/Sbuild/Sysconfig.pm.in index d78f9ba..720a639 100644 --- a/lib/Sbuild/Sysconfig.pm.in +++ b/lib/Sbuild/Sysconfig.pm.in @@ -85,6 +85,7 @@ our %paths = ( # Programs: our %programs = ( 'APT_CACHE' => '@APT_CACHE@', + 'APTITUDE' => '@APTITUDE@', 'APT_GET' => '@APT_GET@', 'CHMOD' => '@CHMOD@', 'DATE' => '@DATE@',
signature.asc
Description: Digital signature