X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/chopwood/blobdiff_plain/09ba568f49600999682b1d8652c94044f488b494..5dea00528b8c53b3462583b675cf9badafe68cbe:/agpl.py diff --git a/agpl.py b/agpl.py index 20b6166..43eba82 100644 --- a/agpl.py +++ b/agpl.py @@ -79,9 +79,10 @@ def filez(cmd): z = buf.find('\0', i) if z < 0: break f = buf[i:z] + i = z + 1 + if f == '.': continue if f.startswith('./'): f = f[2:] yield f - i = z + 1 left = buf[i:] if left: raise U.ExpectedError, \ @@ -93,16 +94,31 @@ DUMPERS = [ filez('find .git -print0')]), (lambda d: True, [filez('find . ( ! -perm +004 -prune ) -o -print0')])] -def dump_dir(dir, tf, root): +def dump_dir(name, dir, dirmap, tf, root): for test, listers in DUMPERS: if test(dir): break else: raise U.ExpectedError, (500, "no dumper for `%s'" % dir) + tf.add(dir, OS.path.join(root, name), recursive = False) for lister in listers: - base = OS.path.basename(dir) for file in lister(dir): - tf.add(OS.path.join(dir, file), OS.path.join(root, base, file), - recursive = False) + full = OS.path.join(dir, file) + tarname = OS.path.join(root, name, file) + skip = False + 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 + if not skip: + tf.add(full, tarname, recursive = False) def source(out): if SYS.version_info >= (2, 6): @@ -135,7 +151,7 @@ def source(out): gid = OS.getgid(); ti.gid, ti.gname = gid, GR.getgrgid(gid).gr_name tf.addfile(ti, fileobj = StringIO(fest)) for dir, name in dirmap: - dump_dir(dir, tf, root) + dump_dir(name, dir, dirmap, tf, root) tf.close() ###----- That's all, folks --------------------------------------------------