aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/archive_util.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2013-05-03 07:59:45 -0400
committerJason R. Coombs <jaraco@jaraco.com>2013-05-03 07:59:45 -0400
commitb03a9e293b94b338027c4983c2ac3764692dd297 (patch)
tree0edbbba7b08bee89018dd7432254bb639b493305 /setuptools/archive_util.py
parent737fe613840baf2e10246ffb83f86690a0b1561b (diff)
downloadexternal_python_setuptools-b03a9e293b94b338027c4983c2ac3764692dd297.tar.gz
external_python_setuptools-b03a9e293b94b338027c4983c2ac3764692dd297.tar.bz2
external_python_setuptools-b03a9e293b94b338027c4983c2ac3764692dd297.zip
Copy changes to setuptools/archive_util.py setuptools/depends.py setuptools/extension.py and setuptools/__init__.py from 1aae1efe5733
--HG-- branch : Setuptools-Distribute merge extra : source : a3f8891a67625e751eacbf027d66feff19779da4
Diffstat (limited to 'setuptools/archive_util.py')
-rwxr-xr-xsetuptools/archive_util.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/setuptools/archive_util.py b/setuptools/archive_util.py
index 511f05ad..d44264f8 100755
--- a/setuptools/archive_util.py
+++ b/setuptools/archive_util.py
@@ -6,7 +6,7 @@ __all__ = [
"UnrecognizedFormat", "extraction_drivers", "unpack_directory",
]
-import zipfile, tarfile, os, shutil
+import zipfile, tarfile, os, shutil, posixpath
from pkg_resources import ensure_directory
from distutils.errors import DistutilsError
@@ -138,7 +138,7 @@ def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
name = info.filename
# don't extract absolute paths or ones with .. in them
- if name.startswith('/') or '..' in name:
+ if name.startswith('/') or '..' in name.split('/'):
continue
target = os.path.join(extract_dir, *name.split('/'))
@@ -169,37 +169,37 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
by ``tarfile.open()``). See ``unpack_archive()`` for an explanation
of the `progress_filter` argument.
"""
-
try:
tarobj = tarfile.open(filename)
except tarfile.TarError:
raise UnrecognizedFormat(
"%s is not a compressed or uncompressed tar file" % (filename,)
)
-
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('/'))
+ name = member.name
+ # don't extract absolute paths or ones with .. in them
+ if not name.startswith('/') and '..' not in name.split('/'):
+ dst = os.path.join(extract_dir, *name.split('/'))
+ while member is not None and (member.islnk() or member.issym()):
+ linkpath = member.linkname
+ if member.issym():
+ linkpath = posixpath.join(posixpath.dirname(member.name), linkpath)
+ linkpath = posixpath.normpath(linkpath)
+ member = tarobj._getmember(linkpath)
+
+ if member is not None and (member.isfile() or member.isdir()):
dst = progress_filter(name, dst)
if dst:
if dst.endswith(os.sep):
dst = dst[:-1]
- tarobj._extract_member(member,dst) # XXX Ugh
+ try:
+ tarobj._extract_member(member,dst) # XXX Ugh
+ except tarfile.ExtractError:
+ pass # chown/chmod/mkfifo/mknode/makedev failed
return True
finally:
tarobj.close()
-
-
-
extraction_drivers = unpack_directory, unpack_zipfile, unpack_tarfile
-
-
-
-
-