+
+ ## First of all, find out what needs to be dumped, and assign names to all
+ ## of the various directories.
+ root = '%s-%s' % (PACKAGE, VERSION)
+ seen = set()
+ dirmap = []
+ festout = StringIO()
+ for dir in dirs_to_dump():
+ dir = dir.rstrip('/')
+ base = OS.path.basename(dir)
+ if base not in seen:
+ name = base
+ else:
+ for i in I.count():
+ name = '%s.%d' % (base, i)
+ if name not in seen: break
+ dirmap.append((dir + '/', name))
+ festout.write('%s = %s\n' % (name, dir))
+
+ ## Write a map of where things were in the filesystem. This may help a
+ ## user figure out how to deploy the thing.
+ fest = festout.getvalue()
+ ti = TAR.TarInfo(OS.path.join(root, 'MANIFEST'))
+ ti.size = len(fest)
+ ti.mtime = T.time()
+ ti.mode = 0664
+ ti.type = TAR.REGTYPE
+ uid = OS.getuid(); ti.uid, ti.uname = uid, PW.getpwuid(uid).pw_name
+ gid = OS.getgid(); ti.gid, ti.gname = gid, GR.getgrgid(gid).gr_name
+ tf.addfile(ti, fileobj = StringIO(fest))
+
+ ## Now actually dump all of the individual directories.
+ for dir, name in dirmap:
+ dump_dir(name, dir, dirmap, tf, root)
+
+ ## We're done.