From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RJqmT-00061K-5C for garchives@archives.gentoo.org; Fri, 28 Oct 2011 18:03:49 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CC70121C01F; Fri, 28 Oct 2011 18:03:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 8FEB321C0C2 for ; Fri, 28 Oct 2011 18:03:41 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C83321B4002 for ; Fri, 28 Oct 2011 18:03:37 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 3E01980042 for ; Fri, 28 Oct 2011 18:03:37 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <4198da0184aaec30c41f2e5d2c7af71c4d35b662.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dbapi/vartree.py X-VCS-Directories: pym/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 4198da0184aaec30c41f2e5d2c7af71c4d35b662 Date: Fri, 28 Oct 2011 18:03:37 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: de053bdd359424f612060f39de3764a8 commit: 4198da0184aaec30c41f2e5d2c7af71c4d35b662 Author: Zac Medico gentoo org> AuthorDate: Fri Oct 28 18:03:02 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Oct 28 18:03:02 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D4198da01 quickpkg: fix unicode for bug #388773 --- pym/portage/dbapi/vartree.py | 41 ++++++++++++++++++++++++++++++++++++= ++++- 1 files changed, 40 insertions(+), 1 deletions(-) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 7f94cc5..e719062 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -31,6 +31,7 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.util._dyn_libs.LinkageMapELF:LinkageMapELF@LinkageMap', 'portage.versions:best,catpkgsplit,catsplit,cpv_getkey,pkgcmp,' + \ '_pkgsplit@pkgsplit', + 'tarfile', ) =20 from portage.const import CACHE_PATH, CONFIG_MEMORY_FILE, \ @@ -61,10 +62,12 @@ from _emerge.MiscFunctionsProcess import MiscFunction= sProcess =20 import errno import gc +import grp import io from itertools import chain import logging import os as _os +import pwd import re import shutil import stat @@ -4501,6 +4504,7 @@ def tar_contents(contents, root, tar, protect=3DNon= e, onProgress=3DNone): os =3D portage.os encoding =3D _encodings['fs'] =20 + tar.encoding =3D encoding root =3D normalize_path(root).rstrip(os.path.sep) + os.path.sep id_strings =3D {} maxval =3D len(contents) @@ -4534,7 +4538,42 @@ def tar_contents(contents, root, tar, protect=3DNo= ne, onProgress=3DNone): # recorded as a real directory in the tar file to ensure that tar # can properly extract it's children. live_path =3D os.path.realpath(live_path) - tarinfo =3D tar.gettarinfo(live_path, arcname) + lst =3D os.lstat(live_path) + + # Since os.lstat() inside TarFile.gettarinfo() can trigger a + # UnicodeEncodeError when python has something other than utf_8 + # return from sys.getfilesystemencoding() (as in bug #388773), + # we implement the needed functionality here, using the result + # of our successful lstat call. An alternative to this would be + # to pass in the fileobj argument to TarFile.gettarinfo(), so + # that it could use fstat instead of lstat. However, that would + # have the unwanted effect of dereferencing symlinks. + + tarinfo =3D tar.tarinfo() + tarinfo.name =3D arcname + tarinfo.mode =3D lst.st_mode + tarinfo.uid =3D lst.st_uid + tarinfo.gid =3D lst.st_gid + tarinfo.size =3D lst.st_size + tarinfo.mtime =3D lst.st_mtime + tarinfo.linkname =3D "" + if stat.S_ISREG(lst.st_mode): + tarinfo.type =3D tarfile.REGTYPE + elif stat.S_ISDIR(lst.st_mode): + tarinfo.type =3D tarfile.DIRTYPE + elif stat.S_ISLNK(lst.st_mode): + tarinfo.type =3D tarfile.SYMTYPE + tarinfo.linkname =3D os.readlink(live_path) + else: + continue + try: + tarinfo.uname =3D pwd.getpwuid(tarinfo.uid)[0] + except KeyError: + pass + try: + tarinfo.gname =3D grp.getgrgid(tarinfo.gid)[0] + except KeyError: + pass =20 if stat.S_ISREG(lst.st_mode): if protect and protect(path):