Commit 39f910e2 authored by Toshio Kuratomi's avatar Toshio Kuratomi

Include symlinks when extracting source dist. Fixes #183.

--HG--
branch : distribute
extra : rebase_source : c0d44c559d3433e4e4ceddaff5467c2d82dd7688
parent 8633ffe7
...@@ -180,19 +180,22 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter): ...@@ -180,19 +180,22 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
try: try:
tarobj.chown = lambda *args: None # don't do any chowning! tarobj.chown = lambda *args: None # don't do any chowning!
for member in tarobj: for member in tarobj:
if member.isfile() or member.isdir(): name = member.name
name = member.name # don't extract absolute paths or ones with .. in them
# don't extract absolute paths or ones with .. in them if not name.startswith('/') and '..' not in name:
if not name.startswith('/') and '..' not in name: prelim_dst = os.path.join(extract_dir, *name.split('/'))
dst = os.path.join(extract_dir, *name.split('/')) final_dst = progress_filter(name, prelim_dst)
dst = progress_filter(name, dst) # If progress_filter returns None, then we do not extract
if dst: # this file
if dst.endswith(os.sep): # TODO: Do we really need to limit to just these file types?
dst = dst[:-1] # tarobj.extract() will handle all files on all platforms,
try: # turning file types that aren't allowed on that platform into
tarobj._extract_member(member,dst) # XXX Ugh # regular files.
except tarfile.ExtractError: if final_dst and (member.isfile() or member.isdir() or
pass # chown/chmod/mkfifo/mknode/makedev failed member.islnk() or member.issym()):
tarobj.extract(member, extract_dir)
if final_dst != prelim_dst:
shutil.move(prelim_dst, final_dst)
return True return True
finally: finally:
tarobj.close() tarobj.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment