summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphillip.eby <phillip.eby@6015fed2-1504-0410-9fe1-9d1591cc4771>2010-10-12 15:43:35 +0000
committerphillip.eby <phillip.eby@6015fed2-1504-0410-9fe1-9d1591cc4771>2010-10-12 15:43:35 +0000
commit3f2ef068f801d407cf3fc46f22a1b8c6548a3695 (patch)
tree012b08f968efd0a060a34ba326b7482cf25f4ef5
parent5a8917839e0d8f721c73af80fa1d7fcde4540433 (diff)
downloadpython-setuptools-3f2ef068f801d407cf3fc46f22a1b8c6548a3695.tar.gz
Handle tarballs with forward-referencing symlinks
git-svn-id: http://svn.python.org/projects/sandbox/trunk/setuptools@85380 6015fed2-1504-0410-9fe1-9d1591cc4771
-rwxr-xr-xsetuptools/archive_util.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/setuptools/archive_util.py b/setuptools/archive_util.py
index a8c93ca..3afa68d 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
@@ -169,14 +169,12 @@ 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:
@@ -184,9 +182,12 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
# 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('/'))
-
while member is not None and (member.islnk() or member.issym()):
- member = tarobj._getmember(member.linkname, member)
+ 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)
@@ -201,5 +202,4 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
finally:
tarobj.close()
-
extraction_drivers = unpack_directory, unpack_zipfile, unpack_tarfile