On Mon, Oct 11, 2010 at 11:46:11AM -0400, Barry Warsaw wrote: > On Oct 08, 2010, at 11:37 PM, P.J. Eby wrote: > > >At this point, I'm a bit stumped, as I don't know enough about how tarballs > >are supposed to work internally; should I just whip up a patch for the > >situation where the path has no slashes in it (the logilab case), or do I > >need to do something more sophisticated in the general case? > > I don't know, but the fix you did commit fixes the build problem for me. > tarfile.extract() takes care of symlinks just fine. If you're going to reimplement extract()'s functionality by using tarfile's private methods directly, you probably should copy tarfile.extract()'s symlink handling routine.
Another option, less efficient but letting the tarfile module handle any nuances of the file format, would be to restructure the setuptools code to call tarfile.extract() and then move the file if filter_progress() returned a changed dst. Something like this: if not name.startswith('/') and '..' not in name: prelim_dst = os.path.join(extract_dir, *name.split('/')) if member.isfile() or member.isdir() or member.islnk(): final_dst = progress_filter(name, prelim_dst) if final_dst: tarfile.extract(member, extract_dir) if final_dst != prelim_dst: shutil.move(prelim_dst, final_dst) -Toshio
pgpEXwuX6HWAc.pgp
Description: PGP signature
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig