diff --git a/pisi/operations/build.py b/pisi/operations/build.py index b4e4ac74..315c6726 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -117,6 +117,8 @@ def exclude_special_files(filepath, fileinfo, ag): if not pattern in keeplist and re.match(patterns[pattern], fileinfo): ctx.ui.debug("Removing special %s file: %s" % (pattern, filepath)) os.unlink(filepath) + # Remove dir if it becomes empty (Bug #11588) + pisi.util.rmdirs(os.path.dirname(filepath)) def strip_debug_action(filepath, fileinfo, install_dir, ag): excludelist = [] if not ag.has_key('NoStrip') else ag['NoStrip'] diff --git a/pisi/util.py b/pisi/util.py index e754690b..af00d136 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -668,6 +668,13 @@ def config_changed(config_file): return True return False +# recursively remove empty dirs starting from dirpath +def rmdirs(dirpath): + if os.path.isdir(dirpath) and not os.listdir(dirpath): + ctx.ui.debug("Removing empty dir: %s" % dirpath) + os.rmdir(dirpath) + rmdirs(os.path.dirname(dirpath)) + # Python regex sucks # http://mail.python.org/pipermail/python-list/2009-January/523704.html def letters():