From 3f2ef068f801d407cf3fc46f22a1b8c6548a3695 Mon Sep 17 00:00:00 2001 From: "phillip.eby" Date: Tue, 12 Oct 2010 15:43:35 +0000 Subject: Handle tarballs with forward-referencing symlinks git-svn-id: http://svn.python.org/projects/sandbox/trunk/setuptools@85380 6015fed2-1504-0410-9fe1-9d1591cc4771 --- setuptools/archive_util.py | 12 ++++++------ 1 file 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 -- cgit v1.2.1