summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorModestas Vainius <modestas@vainius.eu>2009-06-15 15:55:34 +0300
committerModestas Vainius <modestas@vainius.eu>2009-06-15 15:55:34 +0300
commit68c7c4c23cc9de4243e54b90ee902d9f9bf00bac (patch)
tree5bc0eb65a06ea6e2bc311cf6d857294451d8dcfa
parentcf5803abbcde17f77668cbda82c26448158012bc (diff)
Add "only if empty" flag to rmdir_builddir().
Signed-off-by: Modestas Vainius <modestas@vainius.eu>
-rw-r--r--Debian/Debhelper/Buildsystem.pm11
1 files 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)));
}