From 16c7c0a6d2dc03647f32406263864a4964104e7d Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 14 Nov 2011 17:25:46 +0000 Subject: Fix chunk building to deal correctly with symlinks to directories --- morphlib/bins.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'morphlib') 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: -- cgit v1.2.1