X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/chopwood/blobdiff_plain/16e577475d8953cfb4f2756d0a5d3b399ac4fe6f..8f6848e2f6be4cde36f1e3599de0e7ef0457a30b:/agpl.py diff --git a/agpl.py b/agpl.py index b49153b..0929e78 100644 --- a/agpl.py +++ b/agpl.py @@ -23,6 +23,8 @@ ### License along with Chopwood; if not, see ### . +from __future__ import with_statement + import contextlib as CTX import grp as GR import os as OS @@ -142,7 +144,7 @@ def filez(cmd): if z < 0: break f = buf[i:z] i = z + 1 - if f == '.': continue + if f.rstrip('/') == '.': continue if f.startswith('./'): f = f[2:] yield f @@ -198,28 +200,27 @@ def dump_dir(name, dir, dirmap, tf, root): ## Work through each file. for file in lister(dir): - full = OS.path.join(dir, file) - tarname = OS.path.join(root, name, file) - skip = False - - ## Check for symbolic links. If we find one that points to another - ## directory we're going to dump separately then fiddle it so that it - ## works in the directory tree we're going to make. - if OS.path.islink(full): - dest = OS.path.realpath(full) - for d, local in dirmap: - if dest.startswith(d): - fix = OS.path.relpath(OS.path.join('/', local, dest[len(d):]), - OS.path.join('/', name, - OS.path.dirname(file))) - st = OS.stat(full) - ti = tf.gettarinfo(full, tarname) - ti.linkname = fix - tf.addfile(ti) - skip = True - - ## Nothing special, so just dump the file. Or whatever it is. - if not skip: + with U.Escape() as skip: + full = OS.path.join(dir, file) + tarname = OS.path.join(root, name, file) + + ## Check for symbolic links. If we find one that points to another + ## directory we're going to dump separately then fiddle it so that it + ## works in the directory tree we're going to make. + if OS.path.islink(full): + dest = OS.path.realpath(full) + for d, local in dirmap: + if dest.startswith(d): + fix = OS.path.relpath(OS.path.join('/', local, dest[len(d):]), + OS.path.join('/', name, + OS.path.dirname(file))) + st = OS.stat(full) + ti = tf.gettarinfo(full, tarname) + ti.linkname = fix + tf.addfile(ti) + skip() + + ## Nothing special, so just dump the file. Or whatever it is. tf.add(full, tarname, recursive = False) def source(out):