From 68c7c4c23cc9de4243e54b90ee902d9f9bf00bac Mon Sep 17 00:00:00 2001 From: Modestas Vainius Date: Mon, 15 Jun 2009 15:55:34 +0300 Subject: Add "only if empty" flag to rmdir_builddir(). Signed-off-by: Modestas Vainius --- Debian/Debhelper/Buildsystem.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Debian/Debhelper/Buildsystem.pm b/Debian/Debhelper/Buildsystem.pm index b7d79c9e..c2bba0b2 100644 --- a/Debian/Debhelper/Buildsystem.pm +++ b/Debian/Debhelper/Buildsystem.pm @@ -297,15 +297,18 @@ sub doit_in_builddir { # If build directory does not exist, nothing is done and 0 is returned. sub rmdir_builddir { my $this=shift; + my $only_empty=shift; if ($this->get_builddir()) { my $buildpath = $this->get_buildpath(); if (-d $buildpath && ! $dh{NO_ACT}) { - doit("rm", "-rf", $buildpath); - # If build directory had 2 or more levels, delete empty - # parent directories until the source directory level. my @spdir = File::Spec->splitdir($this->get_build_rel2sourcedir()); my $peek; - pop @spdir; + if (!$only_empty) { + doit("rm", "-rf", $buildpath); + pop @spdir; + } + # If build directory had 2 or more levels, delete empty + # parent directories until the source directory level. while (($peek=pop(@spdir)) && $peek ne '.' && $peek ne '..') { last if ! rmdir($this->get_sourcepath(File::Spec->catdir(@spdir, $peek))); } -- cgit v1.2.3