summaryrefslogtreecommitdiff
path: root/morphlib/bins.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-11-14 17:25:46 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-11-14 17:25:46 +0000
commit16c7c0a6d2dc03647f32406263864a4964104e7d (patch)
treeed592168c269be6c1503435370169a7b7d70f1d1 /morphlib/bins.py
parentb4def9d3aecfe92491c8d8c285d438753d891844 (diff)
downloadmorph-16c7c0a6d2dc03647f32406263864a4964104e7d.tar.gz
Fix chunk building to deal correctly with symlinks to directories
Diffstat (limited to 'morphlib/bins.py')
-rw-r--r--morphlib/bins.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/morphlib/bins.py b/morphlib/bins.py
index 24a8b1f0..a2562d43 100644
--- a/morphlib/bins.py
+++ b/morphlib/bins.py
@@ -63,11 +63,17 @@ def create_chunk(rootdir, chunk_filename, regexps):
for dirname, subdirs, basenames in os.walk(rootdir):
if matches(dirname):
include.add(dirname)
+ subdirpaths = [os.path.join(dirname, x) for x in subdirs]
+ subdirsymlinks = [x for x in subdirpaths if os.path.islink(x)]
filenames = [os.path.join(dirname, x) for x in basenames]
- for filename in filenames:
+ for filename in subdirsymlinks + filenames:
if matches(mkrel(filename)):
for name in names_to_root(filename):
- include.add(name)
+ if name not in include:
+ logging.debug('regexp match: %s' % name)
+ include.add(name)
+ else:
+ logging.debug('regexp MISMATCH: %s' % filename)
include = sorted(include)
@@ -76,9 +82,9 @@ def create_chunk(rootdir, chunk_filename, regexps):
tar.add(filename, arcname=mkrel(filename), recursive=False)
tar.close()
- include.remove(rootdir)
+ include.remove(rootdir)
for filename in reversed(include):
- if os.path.isdir(filename):
+ if os.path.isdir(filename) and not os.path.islink(filename):
if not os.listdir(filename):
os.rmdir(filename)
else: