[Python-checkins] r85381 - sandbox/branches/setuptools-0.6/setuptools/archive_util.py
phillip.eby
python-checkins at python.org
Tue Oct 12 17:44:18 CEST 2010
Author: phillip.eby
Date: Tue Oct 12 17:44:18 2010
New Revision: 85381
Log:
Backport
Modified:
sandbox/branches/setuptools-0.6/setuptools/archive_util.py
Modified: sandbox/branches/setuptools-0.6/setuptools/archive_util.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/archive_util.py (original)
+++ sandbox/branches/setuptools-0.6/setuptools/archive_util.py Tue Oct 12 17:44:18 2010
@@ -6,7 +6,7 @@
"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 @@
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 @@
# 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 @@
finally:
tarobj.close()
-
extraction_drivers = unpack_directory, unpack_zipfile, unpack_tarfile
More information about the Python-checkins
mailing list