Control: tag -1 + pending Hi,
On Sat, 14 Nov 2015 11:28:31 +0100 Johannes Schauer <jo...@debian.org> wrote: > On Fri, 13 Nov 2015 21:25:40 -0800 Dima Kogan <d...@secretsauce.net> wrote: > > Hi. I just tried to use sbuild for something, and it failed at the > > chroot-update step. This isn't sbuild's fault. But then I tried to use > > --anything-failed-commands to peek at the failure, and was unable to do > > that. That IS sbuild's fault. Here's a git tree with 2 patches that add > > an extra --...-failed-commands option to let us look at this error. > > > > > > http://anonscm.debian.org/cgit/users/dkogan-guest/sbuild.git/?h=added_chroot_update_failed > > this has already been reported by Luca Falavigna in #803505, albeit without a > patch. Thanks to your patch, I can now close both bugs in the next upload. > Thanks! a rebased and reworked version of your patch is now in my local sbuild git and will thus probably be part of the next release. I undid your changing of perl bracket placement, fixed indentation errors and improved the wording of the man page text. Thanks! cheers, josch
From e72e7a40f3547a03380de0000e6f027a0c738b4f Mon Sep 17 00:00:00 2001 From: Dima Kogan <d...@secretsauce.net> Date: Fri, 25 Dec 2015 18:01:08 +0100 Subject: [PATCH] added another -failed external command: chroot-update-failed (closes: #803505) --- lib/Sbuild/Build.pm | 96 +++++++++++++++++++++++++++++---------------------- lib/Sbuild/Conf.pm | 5 +++ lib/Sbuild/Options.pm | 6 ++++ man/sbuild.1.in | 17 +++++++-- 4 files changed, 79 insertions(+), 45 deletions(-) diff --git a/lib/Sbuild/Build.pm b/lib/Sbuild/Build.pm index 640b908..793cdc9 100644 --- a/lib/Sbuild/Build.pm +++ b/lib/Sbuild/Build.pm @@ -595,58 +595,66 @@ sub run_chroot_update { my $self = shift; my $resolver = $self->get('Dependency Resolver'); - if ($self->get_conf('APT_CLEAN') || $self->get_conf('APT_UPDATE') || - $self->get_conf('APT_DISTUPGRADE') || $self->get_conf('APT_UPGRADE')) { - $self->log_subsection('Update chroot'); - } + eval { + if ($self->get_conf('APT_CLEAN') || $self->get_conf('APT_UPDATE') || + $self->get_conf('APT_DISTUPGRADE') || $self->get_conf('APT_UPGRADE')) { + $self->log_subsection('Update chroot'); + } - # Clean APT cache. - $self->check_abort(); - if ($self->get_conf('APT_CLEAN')) { - if ($resolver->clean()) { - # Since apt-clean was requested specifically, fail on - # error when not in buildd mode. - $self->log("apt-get clean failed\n"); - if ($self->get_conf('SBUILD_MODE') ne 'buildd') { - Sbuild::Exception::Build->throw(error => "apt-get clean failed", - failstage => "apt-get-clean"); + # Clean APT cache. + $self->check_abort(); + if ($self->get_conf('APT_CLEAN')) { + if ($resolver->clean()) { + # Since apt-clean was requested specifically, fail on + # error when not in buildd mode. + $self->log("apt-get clean failed\n"); + if ($self->get_conf('SBUILD_MODE') ne 'buildd') { + Sbuild::Exception::Build->throw(error => "apt-get clean failed", + failstage => "apt-get-clean"); + } } } - } - # Update APT cache. - $self->check_abort(); - if ($self->get_conf('APT_UPDATE')) { - if ($resolver->update()) { - # Since apt-update was requested specifically, fail on - # error when not in buildd mode. - if ($self->get_conf('SBUILD_MODE') ne 'buildd') { - Sbuild::Exception::Build->throw(error => "apt-get update failed", - failstage => "apt-get-update"); + # Update APT cache. + $self->check_abort(); + if ($self->get_conf('APT_UPDATE')) { + if ($resolver->update()) { + # Since apt-update was requested specifically, fail on + # error when not in buildd mode. + if ($self->get_conf('SBUILD_MODE') ne 'buildd') { + Sbuild::Exception::Build->throw(error => "apt-get update failed", + failstage => "apt-get-update"); + } } } - } - # Upgrade using APT. - $self->check_abort(); - if ($self->get_conf('APT_DISTUPGRADE')) { - if ($resolver->distupgrade()) { - # Since apt-distupgrade was requested specifically, fail on - # error when not in buildd mode. - if ($self->get_conf('SBUILD_MODE') ne 'buildd') { - Sbuild::Exception::Build->throw(error => "apt-get dist-upgrade failed", - failstage => "apt-get-dist-upgrade"); + # Upgrade using APT. + $self->check_abort(); + if ($self->get_conf('APT_DISTUPGRADE')) { + if ($resolver->distupgrade()) { + # Since apt-distupgrade was requested specifically, fail on + # error when not in buildd mode. + if ($self->get_conf('SBUILD_MODE') ne 'buildd') { + Sbuild::Exception::Build->throw(error => "apt-get dist-upgrade failed", + failstage => "apt-get-dist-upgrade"); + } } - } - } elsif ($self->get_conf('APT_UPGRADE')) { - if ($resolver->upgrade()) { - # Since apt-upgrade was requested specifically, fail on - # error when not in buildd mode. - if ($self->get_conf('SBUILD_MODE') ne 'buildd') { - Sbuild::Exception::Build->throw(error => "apt-get upgrade failed", - failstage => "apt-get-upgrade"); + } elsif ($self->get_conf('APT_UPGRADE')) { + if ($resolver->upgrade()) { + # Since apt-upgrade was requested specifically, fail on + # error when not in buildd mode. + if ($self->get_conf('SBUILD_MODE') ne 'buildd') { + Sbuild::Exception::Build->throw(error => "apt-get upgrade failed", + failstage => "apt-get-upgrade"); + } } } + }; + + my $e = Exception::Class->caught('Sbuild::Exception::Build'); + if ($e) { + $self->run_external_commands("chroot-update-failed-commands"); + $e->rethrow(); } } @@ -1222,6 +1230,10 @@ sub run_external_commands { } elsif ($stage eq "chroot-setup-commands") { $self->log_subsection("Chroot Setup Commands"); $chroot = 1; + } elsif ($stage eq "chroot-update-failed-commands") { + $self->log_subsection("Chroot-update Install Failed Commands"); + $chroot = 1; + $rootuser = 1; } elsif ($stage eq "build-deps-failed-commands") { $self->log_subsection("Build-Deps Install Failed Commands"); $chroot = 1; diff --git a/lib/Sbuild/Conf.pm b/lib/Sbuild/Conf.pm index 41ff488..dd54473 100644 --- a/lib/Sbuild/Conf.pm +++ b/lib/Sbuild/Conf.pm @@ -979,6 +979,7 @@ sub setup ($) { DEFAULT => { "pre-build-commands" => [], "chroot-setup-commands" => [], + "chroot-update-failed-commands" => [], "build-deps-failed-commands" => [], "build-failed-commands" => [], "starting-build-commands" => [], @@ -997,6 +998,10 @@ sub setup ($) { [\'foo\', \'arg1\', \'arg2\'], [\'bar\', \'arg1\', \'arg2\', \'arg3\'], ], + "chroot-update-failed-commands" => [ + [\'foo\', \'arg1\', \'arg2\'], + [\'bar\', \'arg1\', \'arg2\', \'arg3\'], + ], "build-deps-failed-commands" => [ [\'foo\', \'arg1\', \'arg2\'], [\'bar\', \'arg1\', \'arg2\', \'arg3\'], diff --git a/lib/Sbuild/Options.pm b/lib/Sbuild/Options.pm index 73b3fb9..c8069dc 100644 --- a/lib/Sbuild/Options.pm +++ b/lib/Sbuild/Options.pm @@ -278,6 +278,10 @@ sub set_options { push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"chroot-setup-commands"}}, $_[1]); }, + "chroot-update-failed-commands=s" => sub { + push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"chroot-update-failed-commands"}}, + $_[1]); + }, "build-deps-failed-commands=s" => sub { push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"build-deps-failed-commands"}}, $_[1]); @@ -291,6 +295,8 @@ sub set_options { # --anything-failed-commands simply triggers all the # --xxx-failed-commands I know about + push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"chroot-update-failed-commands"}}, + $_[1]); push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"build-deps-failed-commands"}}, $_[1]); push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"build-failed-commands"}}, diff --git a/man/sbuild.1.in b/man/sbuild.1.in index ff40639..2f8f8cd 100644 --- a/man/sbuild.1.in +++ b/man/sbuild.1.in @@ -70,6 +70,7 @@ sbuild \- build debian packages from source .RB [ \-\-piuparts\-root\-args=\fIoptions\fP ] .RB [ \-\-pre\-build\-commands=\fIstring\fP ] .RB [ \-\-chroot\-setup\-commands=\fIstring\fP ] +.RB [ \-\-chroot\-update\-failed\-commands=\fIstring\fP ] .RB [ \-\-build\-deps\-failed\-commands=\fIstring\fP ] .RB [ \-\-starting\-build\-commands=\fIstring\fP ] .RB [ \-\-finished\-build\-commands=\fIstring\fP ] @@ -401,6 +402,14 @@ section .BR "EXTERNAL COMMANDS" for more information. .TP +.BR \-\-chroot\-update\-failed\-commands=\fIstring\fP +Run these commands after any of 'apt-get update', 'apt-get upgrade' or 'apt-get +dist-upgrade' failed. The environment is intact, and the failure can be +investigated. Especially %SBUILD_SHELL is useful here. This option can be used +multiple times to add multiple commands. See the section +.BR "EXTERNAL COMMANDS" +for more information. +.TP .BR \-\-build\-deps\-failed\-commands=\fIstring\fP These commands are run if installing the build dependencies has failed directly after the failed attempt. The environment is intact, and the failure can be @@ -553,9 +562,10 @@ There are several sets of commands. The \fIpre/post\-build\-\fP commands are run external to the chroot. The \fIchroot\-setup/cleanup\-\fP commands and \fIStarting/Finished\-Build\-\fP commands are run inside the chroot. They are all run as root except the \fIStarting/Finishing\-build-\fP commands, which are -run as the current sbuild user. \fIbuild\-deps\-failed\fP runs similarly to -\fIchroot\-setup\fP: in the chroot as root. \fIbuild\-failed\fP runs similarly -to \fIfinished\-build\fP: in the chroot as the user. +run as the current sbuild user. \fIchroot\-update\-failed\fP and +\fIbuild\-deps\-failed\fP runs similarly to \fIchroot\-setup\fP: in the chroot +as root. \fIbuild\-failed\fP runs similarly to \fIfinished\-build\fP: in the +chroot as the user. .PP Here is a summary of the ordering, user, internal/external to chroot for each command hook @@ -579,6 +589,7 @@ Initialise chroot session Setup the chroot and variables \f[CB]\-\-chroot\-setup\-commands\fP yes inside no no Update and upgrade packages +\f[CB]\-\-chroot\-update\-failed\-commands\fP yes inside no no Install Dependencies \f[CB]\-\-build\-deps\-failed\-commands\fP yes inside no no \f[CB]\-\-starting\-build\-commands\fP no inside no no -- 2.5.1
signature.asc
Description: signature