From 5dea00528b8c53b3462583b675cf9badafe68cbe Mon Sep 17 00:00:00 2001 Message-Id: <5dea00528b8c53b3462583b675cf9badafe68cbe.1714600050.git.mdw@distorted.org.uk> From: Mark Wooding Date: Wed, 27 Mar 2013 21:26:39 +0000 Subject: [PATCH] agpl.py: Fix up symbolic links between directories being dumped. Organization: Straylight/Edgeware From: Mark Wooding This should make deployment from generated tarballs easier. --- agpl.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/agpl.py b/agpl.py index 734be25..43eba82 100644 --- a/agpl.py +++ b/agpl.py @@ -101,10 +101,24 @@ def dump_dir(name, dir, dirmap, tf, root): 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): -- [mdw]