aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2012-03-23 13:50:04 -0400
committerToshio Kuratomi <toshio@fedoraproject.org>2012-03-23 13:50:04 -0400
commit39f910e2e4b68cf11ecd2cf12c697aacce451d3d (patch)
tree8a3e3d8ac2ca84f058961b713db4522807c14398
parent8633ffe737039044e955a6e5bd52ac08a0d83b37 (diff)
downloadexternal_python_setuptools-39f910e2e4b68cf11ecd2cf12c697aacce451d3d.tar.gz
external_python_setuptools-39f910e2e4b68cf11ecd2cf12c697aacce451d3d.tar.bz2
external_python_setuptools-39f910e2e4b68cf11ecd2cf12c697aacce451d3d.zip
Include symlinks when extracting source dist. Fixes #183.
--HG-- branch : distribute extra : rebase_source : c0d44c559d3433e4e4ceddaff5467c2d82dd7688
-rwxr-xr-xsetuptools/archive_util.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/setuptools/archive_util.py b/setuptools/archive_util.py
index ab786f3d..5787753f 100755
--- a/setuptools/archive_util.py
+++ b/setuptools/archive_util.py
@@ -180,19 +180,22 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
try:
tarobj.chown = lambda *args: None # don't do any chowning!
for member in tarobj:
- if member.isfile() or member.isdir():
- name = member.name
- # don't extract absolute paths or ones with .. in them
- if not name.startswith('/') and '..' not in name:
- dst = os.path.join(extract_dir, *name.split('/'))
- dst = progress_filter(name, dst)
- if dst:
- if dst.endswith(os.sep):
- dst = dst[:-1]
- try:
- tarobj._extract_member(member,dst) # XXX Ugh
- except tarfile.ExtractError:
- pass # chown/chmod/mkfifo/mknode/makedev failed
+ name = member.name
+ # don't extract absolute paths or ones with .. in them
+ if not name.startswith('/') and '..' not in name:
+ prelim_dst = os.path.join(extract_dir, *name.split('/'))
+ final_dst = progress_filter(name, prelim_dst)
+ # If progress_filter returns None, then we do not extract
+ # this file
+ # TODO: Do we really need to limit to just these file types?
+ # tarobj.extract() will handle all files on all platforms,
+ # turning file types that aren't allowed on that platform into
+ # regular files.
+ if final_dst and (member.isfile() or member.isdir() or
+ member.islnk() or member.issym()):
+ tarobj.extract(member, extract_dir)
+ if final_dst != prelim_dst:
+ shutil.move(prelim_dst, final_dst)
return True
finally:
tarobj.close()