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

lunar pushed a commit to branch pu/reproducible_builds
in repository dh-python.

commit 01b39b13473633c14bb28df6d1c0b543aaaf7bb1
Author: Matthias Klose <d...@debian.org>
Date:   Sun May 11 19:41:30 2014 +0200

    Remove empty directories when moving files
---
 debian/changelog |  4 ++++
 dhpython/fs.py   | 18 +++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 80547a0..98bc084 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,13 @@
 dh-python (1.20140128-2) UNRELEASED; urgency=medium
 
+  [ Piotr Ożarowski ]
   * pybuild: do not invoke clean commands for missing interpreters
     (and thus do not require all interpreter versions to be installed while
     building source package outside build environment, closes: 737091)
 
+  [ Matthias Klose ]
+  * Remove empty directories when moving files. 
+
  -- Piotr Ożarowski <pi...@debian.org>  Thu, 30 Jan 2014 21:41:34 +0100
 
 dh-python (1.20140128-1) unstable; urgency=low
diff --git a/dhpython/fs.py b/dhpython/fs.py
index 035804b..c10f2a0 100644
--- a/dhpython/fs.py
+++ b/dhpython/fs.py
@@ -22,7 +22,7 @@ import logging
 import os
 import re
 from filecmp import cmp as cmpfile
-from os.path import exists, isdir, islink, join, split, splitext
+from os.path import exists, dirname, isdir, islink, join, split, splitext
 from shutil import rmtree
 from stat import ST_MODE, S_IXUSR, S_IXGRP, S_IXOTH
 from dhpython import MULTIARCH_DIR_TPL
@@ -47,8 +47,12 @@ def fix_locations(package, interpreter, versions, options):
                 log.debug('moving files from %s to %s', srcdir, dstdir)
                 share_files(srcdir, dstdir, interpreter, options)
                 parent_dir = '/'.join(srcdir.split('/')[:-1])
-                if exists(parent_dir) and not os.listdir(parent_dir):
-                    os.rmdir(parent_dir)
+                while parent_dir:
+                    if exists(parent_dir):
+                        if os.listdir(parent_dir):
+                            break
+                        os.rmdir(parent_dir)
+                    parent_dir = dirname(parent_dir)
 
         # do the same with debug locations
         dstdir = interpreter.sitedir(package, gdb=True)
@@ -57,8 +61,12 @@ def fix_locations(package, interpreter, versions, options):
                 log.debug('moving files from %s to %s', srcdir, dstdir)
                 share_files(srcdir, dstdir, interpreter, options)
                 parent_dir = '/'.join(srcdir.split('/')[:-1])
-                if exists(parent_dir) and not os.listdir(parent_dir):
-                    os.rmdir(parent_dir)
+                while parent_dir:
+                    if exists(parent_dir):
+                        if os.listdir(parent_dir):
+                            break
+                        os.rmdir(parent_dir)
+                    parent_dir = dirname(parent_dir)
 
 
 def share_files(srcdir, dstdir, interpreter, options):

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

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to