public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/
Date: Fri, 28 Oct 2011 18:03:37 +0000 (UTC)	[thread overview]
Message-ID: <4198da0184aaec30c41f2e5d2c7af71c4d35b662.zmedico@gentoo> (raw)

commit:     4198da0184aaec30c41f2e5d2c7af71c4d35b662
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 28 18:03:02 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Oct 28 18:03:02 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4198da01

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',
 )
 
 from portage.const import CACHE_PATH, CONFIG_MEMORY_FILE, \
@@ -61,10 +62,12 @@ from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
 
 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=None, onProgress=None):
 			os = portage.os
 			encoding = _encodings['fs']
 
+	tar.encoding = encoding
 	root = normalize_path(root).rstrip(os.path.sep) + os.path.sep
 	id_strings = {}
 	maxval = len(contents)
@@ -4534,7 +4538,42 @@ def tar_contents(contents, root, tar, protect=None, onProgress=None):
 			# recorded as a real directory in the tar file to ensure that tar
 			# can properly extract it's children.
 			live_path = os.path.realpath(live_path)
-		tarinfo = tar.gettarinfo(live_path, arcname)
+			lst = 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 = tar.tarinfo()
+		tarinfo.name = arcname
+		tarinfo.mode = lst.st_mode
+		tarinfo.uid = lst.st_uid
+		tarinfo.gid = lst.st_gid
+		tarinfo.size = lst.st_size
+		tarinfo.mtime = lst.st_mtime
+		tarinfo.linkname = ""
+		if stat.S_ISREG(lst.st_mode):
+			tarinfo.type = tarfile.REGTYPE
+		elif stat.S_ISDIR(lst.st_mode):
+			tarinfo.type = tarfile.DIRTYPE
+		elif stat.S_ISLNK(lst.st_mode):
+			tarinfo.type = tarfile.SYMTYPE
+			tarinfo.linkname = os.readlink(live_path)
+		else:
+			continue
+		try:
+			tarinfo.uname = pwd.getpwuid(tarinfo.uid)[0]
+		except KeyError:
+			pass
+		try:
+			tarinfo.gname = grp.getgrgid(tarinfo.gid)[0]
+		except KeyError:
+			pass
 
 		if stat.S_ISREG(lst.st_mode):
 			if protect and protect(path):



             reply	other threads:[~2011-10-28 18:03 UTC|newest]

Thread overview: 288+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-28 18:03 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-07-16  5:27 [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/ Zac Medico
2018-07-15 21:40 Zac Medico
2018-07-14 23:58 Zac Medico
2018-06-26 20:24 Zac Medico
2018-04-30  6:29 Zac Medico
2018-04-29 21:29 Zac Medico
2018-04-24  6:56 Zac Medico
2018-04-23 19:53 Zac Medico
2018-04-23 18:52 Zac Medico
2018-04-17 17:18 Zac Medico
2018-04-13  1:23 Zac Medico
2018-04-11  1:47 Zac Medico
2018-04-10 22:17 Zac Medico
2018-04-10  1:33 Zac Medico
2018-03-16 21:11 Michał Górny
2018-02-28 18:41 Zac Medico
2017-11-21 19:27 Zac Medico
2017-11-21  1:34 Zac Medico
2017-11-14  3:15 Zac Medico
2017-10-15  0:59 Zac Medico
2017-08-27  9:33 Fabian Groffen
2017-02-28 22:07 Michał Górny
2017-02-28 22:07 Michał Górny
2016-11-10 20:25 Zac Medico
2016-06-19 22:17 Zac Medico
2016-06-02 15:48 Zac Medico
2016-03-05  8:21 Zac Medico
2016-01-24 10:33 Zac Medico
2015-09-24 20:30 Zac Medico
2015-05-16 19:14 Zac Medico
2015-05-09  7:33 Zac Medico
2015-05-04  5:15 Zac Medico
2015-05-02 23:11 Zac Medico
2015-04-29  4:20 Zac Medico
2015-04-06  5:07 Zac Medico
2015-04-01 19:16 Zac Medico
2015-03-04 21:37 Zac Medico
2015-03-04 21:37 Zac Medico
2015-03-04 21:37 Zac Medico
2015-02-17 18:31 Zac Medico
2014-12-17 22:13 Zac Medico
2014-12-15 16:28 Arfrever Frehtes Taifersar Arahesis
2014-12-07 23:14 Zac Medico
2014-12-07 23:14 Zac Medico
2014-12-07 23:14 Zac Medico
2014-12-07  0:58 Zac Medico
2014-11-18  3:00 Zac Medico
2014-11-02 18:22 Zac Medico
2014-09-11 23:37 Zac Medico
2014-04-04 23:01 Brian Dolbec
2014-02-24  0:53 Alexander Berntsen
2014-02-07 22:35 Chris Reffett
2014-01-19  8:16 Arfrever Frehtes Taifersar Arahesis
2013-12-05 15:38 Brian Dolbec
2013-09-17 23:32 Zac Medico
2013-08-12  3:23 Zac Medico
2013-08-04 22:09 Zac Medico
2013-07-07  3:23 Zac Medico
2013-06-08  5:48 Zac Medico
2013-06-08  3:00 Zac Medico
2013-06-08  2:49 Zac Medico
2013-06-07 20:52 Arfrever Frehtes Taifersar Arahesis
2013-06-02 22:48 Zac Medico
2013-05-17  2:06 Zac Medico
2013-05-15  7:40 Zac Medico
2013-05-07  3:49 Zac Medico
2013-05-06  8:18 Zac Medico
2013-04-12 17:23 Zac Medico
2013-04-01 17:28 Zac Medico
2013-03-16  5:39 Zac Medico
2013-03-16  5:30 Zac Medico
2013-03-16  1:46 Zac Medico
2013-01-28 21:19 Zac Medico
2013-01-24 18:29 Zac Medico
2013-01-17 14:20 Zac Medico
2013-01-10 14:06 Zac Medico
2013-01-06 20:50 Zac Medico
2013-01-03 22:42 Zac Medico
2012-12-30  9:36 Zac Medico
2012-12-28 22:45 Zac Medico
2012-12-27  3:10 Zac Medico
2012-12-24 21:12 Zac Medico
2012-12-24 21:06 Zac Medico
2012-12-24 20:21 Zac Medico
2012-12-10  8:55 Zac Medico
2012-12-10  8:39 Zac Medico
2012-11-26  3:27 Zac Medico
2012-11-15  0:03 Zac Medico
2012-10-30 23:11 Zac Medico
2012-10-25 19:49 Zac Medico
2012-10-25 15:42 Zac Medico
2012-10-25 15:33 Zac Medico
2012-10-25 15:31 Zac Medico
2012-10-25  9:35 Zac Medico
2012-10-25  9:32 Zac Medico
2012-10-25  8:23 Zac Medico
2012-10-25  6:59 Zac Medico
2012-10-18  3:32 Zac Medico
2012-10-18  0:48 Zac Medico
2012-10-09  2:02 Zac Medico
2012-10-07 22:02 Zac Medico
2012-09-26  3:47 Zac Medico
2012-09-16 21:16 Zac Medico
2012-09-16 21:01 Zac Medico
2012-08-08 20:52 Zac Medico
2012-08-08 20:34 Zac Medico
2012-08-02 20:22 Zac Medico
2012-08-02  0:57 Zac Medico
2012-07-31 23:10 Arfrever Frehtes Taifersar Arahesis
2012-07-12 20:58 Zac Medico
2012-07-05  3:28 Zac Medico
2012-07-02 22:27 Zac Medico
2012-07-02 21:41 Zac Medico
2012-07-01 20:07 Zac Medico
2012-07-01  8:11 Zac Medico
2012-06-24 21:01 Zac Medico
2012-06-24 19:16 Zac Medico
2012-06-23 20:39 Zac Medico
2012-06-23  1:14 Zac Medico
2012-06-15 23:43 Zac Medico
2012-06-12  6:41 Zac Medico
2012-05-17 20:08 Zac Medico
2012-05-14 23:56 Zac Medico
2012-05-14  0:46 Zac Medico
2012-05-14  0:29 Zac Medico
2012-05-09 22:29 Zac Medico
2012-05-05 16:54 Zac Medico
2012-04-22 20:34 Zac Medico
2012-04-18  1:48 Zac Medico
2012-03-23 17:28 Zac Medico
2012-03-18 22:40 Zac Medico
2012-02-23  5:31 Zac Medico
2012-02-23  3:07 Zac Medico
2012-02-15 22:28 Zac Medico
2012-02-15 22:17 Zac Medico
2012-02-11 18:46 Zac Medico
2012-02-09  5:17 Zac Medico
2012-02-09  5:05 Zac Medico
2012-01-27 22:02 Zac Medico
2012-01-11 16:02 Zac Medico
2011-12-22 19:43 Zac Medico
2011-12-22  0:32 Zac Medico
2011-12-22  0:29 Zac Medico
2011-12-21 23:16 Zac Medico
2011-12-21 22:58 Zac Medico
2011-12-20 20:27 Zac Medico
2011-12-10 19:41 Zac Medico
2011-12-10  7:04 Zac Medico
2011-12-01 20:34 Zac Medico
2011-11-27 21:00 Zac Medico
2011-11-26  1:54 Arfrever Frehtes Taifersar Arahesis
2011-10-30  0:00 Zac Medico
2011-10-29  5:35 Zac Medico
2011-10-29  4:17 Zac Medico
2011-10-25 14:52 Zac Medico
2011-10-19 21:19 Zac Medico
2011-10-17  5:21 Zac Medico
2011-10-16  5:59 Zac Medico
2011-10-15 20:29 Zac Medico
2011-10-14  0:24 Zac Medico
2011-10-05  4:27 Zac Medico
2011-10-02 20:02 Zac Medico
2011-09-27 16:46 Zac Medico
2011-09-27 14:58 Zac Medico
2011-09-24 22:24 Zac Medico
2011-09-24 22:03 Zac Medico
2011-09-24 21:44 Zac Medico
2011-09-24 21:32 Zac Medico
2011-09-24 21:18 Zac Medico
2011-09-24 20:47 Zac Medico
2011-09-24 20:15 Zac Medico
2011-09-24 19:50 Zac Medico
2011-09-24 19:27 Zac Medico
2011-09-24 19:05 Zac Medico
2011-09-24 18:29 Zac Medico
2011-09-24 18:13 Zac Medico
2011-09-23 20:50 Zac Medico
2011-09-23 20:01 Zac Medico
2011-09-23 19:53 Zac Medico
2011-09-23 18:19 Zac Medico
2011-09-23  1:48 Zac Medico
2011-09-23  0:53 Zac Medico
2011-09-07 17:36 Zac Medico
2011-09-02 15:08 Zac Medico
2011-09-01  8:43 Zac Medico
2011-09-01  6:46 Zac Medico
2011-08-30  2:09 Zac Medico
2011-08-06 11:10 Zac Medico
2011-08-04 23:09 Zac Medico
2011-08-02  8:56 Zac Medico
2011-08-01 12:32 Zac Medico
2011-07-29 20:27 Zac Medico
2011-07-29  7:22 Zac Medico
2011-07-28 11:29 Zac Medico
2011-07-27  1:51 Zac Medico
2011-07-23 18:47 Zac Medico
2011-07-12 19:50 Zac Medico
2011-07-08  6:46 Zac Medico
2011-07-01  4:02 Zac Medico
2011-06-29 11:37 Zac Medico
2011-06-17 20:57 Zac Medico
2011-06-13 22:14 Zac Medico
2011-06-11  3:41 Zac Medico
2011-06-10 17:20 Zac Medico
2011-06-10 12:21 Zac Medico
2011-06-10 12:04 Zac Medico
2011-06-06 11:52 Zac Medico
2011-06-05  9:18 Zac Medico
2011-06-05  9:01 Zac Medico
2011-06-05  8:55 Zac Medico
2011-06-05  8:14 Zac Medico
2011-06-05  7:23 Zac Medico
2011-06-05  7:10 Zac Medico
2011-06-04  2:13 Zac Medico
2011-06-03 11:20 Zac Medico
2011-06-03 10:16 Zac Medico
2011-06-03  2:38 Zac Medico
2011-05-27  2:38 Zac Medico
2011-05-27  2:15 Zac Medico
2011-05-27  0:01 Zac Medico
2011-05-26  2:34 Zac Medico
2011-05-26  1:39 Zac Medico
2011-05-26  0:57 Zac Medico
2011-05-25  5:10 Zac Medico
2011-05-25  5:02 Zac Medico
2011-05-25  4:37 Zac Medico
2011-05-25  4:08 Zac Medico
2011-05-24 10:40 Zac Medico
2011-05-21 14:23 Zac Medico
2011-05-21 13:15 Zac Medico
2011-05-18  5:38 Zac Medico
2011-05-18  5:27 Zac Medico
2011-05-16  1:26 Zac Medico
2011-05-16  0:22 Zac Medico
2011-05-15 23:20 Zac Medico
2011-05-15  9:32 Zac Medico
2011-05-15  4:32 Zac Medico
2011-05-15  2:55 Zac Medico
2011-05-15  2:44 Zac Medico
2011-05-14 23:55 Zac Medico
2011-05-14 22:56 Arfrever Frehtes Taifersar Arahesis
2011-05-14 22:14 Zac Medico
2011-05-14 21:41 Zac Medico
2011-05-14 21:25 Zac Medico
2011-05-12 19:02 Zac Medico
2011-05-12 17:51 Zac Medico
2011-05-12  7:09 Zac Medico
2011-05-12  5:35 Zac Medico
2011-05-12  1:16 Zac Medico
2011-05-10 19:53 Zac Medico
2011-05-10  5:05 Zac Medico
2011-05-10  4:47 Zac Medico
2011-05-09 20:36 Zac Medico
2011-05-09  6:25 Zac Medico
2011-05-09  4:52 Zac Medico
2011-05-08 20:46 Zac Medico
2011-05-08 20:19 Zac Medico
2011-05-08 19:35 Zac Medico
2011-05-08  7:30 Zac Medico
2011-05-08  4:53 Zac Medico
2011-05-08  4:53 Zac Medico
2011-05-03  3:02 Zac Medico
2011-03-27 22:38 Zac Medico
2011-03-27 21:26 Zac Medico
2011-03-27 20:57 Zac Medico
2011-03-27  6:09 Zac Medico
2011-03-26 23:26 Zac Medico
2011-03-26 18:01 Zac Medico
2011-03-26  8:23 Zac Medico
2011-03-26  2:43 Zac Medico
2011-03-26  2:43 Zac Medico
2011-03-25 20:53 Zac Medico
2011-03-25 10:39 Zac Medico
2011-03-25 10:13 Zac Medico
2011-03-25  9:47 Zac Medico
2011-03-25  8:25 Zac Medico
2011-03-25  8:12 Zac Medico
2011-03-16 20:58 Zac Medico
2011-03-07 17:34 Zac Medico
2011-03-02 19:49 Zac Medico
2011-03-02 18:54 Zac Medico
2011-03-01 21:23 Zac Medico
2011-03-01 21:05 Zac Medico
2011-03-01 20:43 Zac Medico
2011-03-01 20:08 Zac Medico
2011-03-01 18:07 Zac Medico
2011-02-14  4:02 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4198da0184aaec30c41f2e5d2c7af71c4d35b662.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox