[debhelper-devel] [debhelper] 01/01: Fix doit_in_sourcedir/doit_in_builddir exception handling

Niels Thykier nthykier at moszumanska.debian.org
Sat Sep 5 20:15:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit df7bd63909d8f4b29c90ca9674e3f91325544a54
Author: Colin Watson <cjwatson at debian.org>
Date:   Sat Sep 5 20:57:04 2015 +0100

    Fix doit_in_sourcedir/doit_in_builddir exception handling
    
    Buildsystem.pm: Fix doit_in_sourcedir/doit_in_builddir to always
    chdir back to the original directory even if the subprocess exits
    non-zero.  This makes sure that the autoconf and cmake buildsystems
    can still dump out configuration artifacts even when doing
    out-of-tree builds.
    
    Signed-off-by: Colin Watson <cjwatson at debian.org>
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Buildsystem.pm | 12 ++++++++++--
 debian/changelog                |  5 +++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Debian/Debhelper/Buildsystem.pm b/Debian/Debhelper/Buildsystem.pm
index 03d7e32..2fbb476 100644
--- a/Debian/Debhelper/Buildsystem.pm
+++ b/Debian/Debhelper/Buildsystem.pm
@@ -301,8 +301,12 @@ sub doit_in_sourcedir {
 	if ($this->get_sourcedir() ne '.') {
 		my $sourcedir = $this->get_sourcedir();
 		$this->_cd($sourcedir);
-		print_and_doit(@_);
+		eval {
+			print_and_doit(@_);
+		};
+		my $saved_exception = $@;
 		$this->_cd($this->_rel2rel($this->{cwd}, $sourcedir));
+		die $saved_exception if $saved_exception;
 	}
 	else {
 		print_and_doit(@_);
@@ -336,8 +340,12 @@ sub doit_in_builddir {
 	if ($this->get_buildpath() ne '.') {
 		my $buildpath = $this->get_buildpath();
 		$this->_cd($buildpath);
-		print_and_doit(@_);
+		eval {
+			print_and_doit(@_);
+		};
+		my $saved_exception = $@;
 		$this->_cd($this->_rel2rel($this->{cwd}, $buildpath));
+		die $saved_exception if $saved_exception;
 	}
 	else {
 		print_and_doit(@_);
diff --git a/debian/changelog b/debian/changelog
index 70c8b1e..f7500c9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -59,6 +59,11 @@ debhelper (9.20150811+unreleased) UNRELEASED; urgency=medium
   * dh: Call dh_strip_nondeterminism during build.
     (Closes: #759895)
 
+  [ Colin Watson ]
+  * Buildsystem.pm: Fix doit_in_sourcedir/doit_in_builddir to
+    always chdir back to the original directory even if the
+    subprocess exits non-zero.  (Closes: #798116)
+
  -- Paul Tagliamonte <paultag at debian.org>  Fri, 14 Aug 2015 21:25:16 +0200
 
 debhelper (9.20150811) unstable; urgency=medium

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list