public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-02-08  9:33 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-02-08  9:33 UTC (permalink / raw
  To: gentoo-commits

commit:     75c57abd6bdc86a2425d15013128e800c57ced7a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Feb  8 09:32:09 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Feb  8 09:32:09 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=75c57abd

portage.debug: handle threading ImportError

---
 pym/portage/debug.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/pym/portage/debug.py b/pym/portage/debug.py
index e18d02c..ce642fe 100644
--- a/pym/portage/debug.py
+++ b/pym/portage/debug.py
@@ -1,7 +1,13 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import os, sys, threading
+import os
+import sys
+
+try:
+	import threading
+except ImportError:
+	import dummy_threading as threading
 
 import portage.const
 from portage.util import writemsg



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-02-18  8:04 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-02-18  8:04 UTC (permalink / raw
  To: gentoo-commits

commit:     e33e94307ba0bd2f3fff543c407eee812c4ea5c9
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 18 08:03:10 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Feb 18 08:03:10 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e33e9430

mail: handle unicode in subject for python3

---
 pym/portage/mail.py |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/pym/portage/mail.py b/pym/portage/mail.py
index f87efe2..598c1f9 100644
--- a/pym/portage/mail.py
+++ b/pym/portage/mail.py
@@ -67,9 +67,19 @@ def create_message(sender, recipient, subject, body, attachments=None):
 	mymessage.set_unixfrom(sender)
 	mymessage["To"] = recipient
 	mymessage["From"] = sender
-	# Use Header as a workaround so that long subject lines are wrapped
-	# correctly by <=python-2.6 (gentoo bug #263370, python issue #1974).
-	mymessage["Subject"] = Header(subject)
+
+	if sys.hexversion >= 0x3000000:
+		# Avoid UnicodeEncodeError in python3 with non-ascii characters.
+		#  File "/usr/lib/python3.1/email/header.py", line 189, in __init__
+		#    self.append(s, charset, errors)
+		#  File "/usr/lib/python3.1/email/header.py", line 262, in append
+		#    input_bytes = s.encode(input_charset, errors)
+		#UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-9: ordinal not in range(128)
+		mymessage["Subject"] = subject
+	else:
+		# Use Header as a workaround so that long subject lines are wrapped
+		# correctly by <=python-2.6 (gentoo bug #263370, python issue #1974).
+		mymessage["Subject"] = Header(subject)
 	mymessage["Date"] = time.strftime("%a, %d %b %Y %H:%M:%S %z")
 	
 	return mymessage



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-02-18  8:33 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-02-18  8:33 UTC (permalink / raw
  To: gentoo-commits

commit:     e7ca7fc07c00584259b6a303c1cdca87e91dc70e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 18 08:32:27 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Feb 18 08:32:27 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e7ca7fc0

mail: handle unicode in subject more for python3

---
 pym/portage/mail.py |   48 ++++++++++++++++++++++++++----------------------
 1 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/pym/portage/mail.py b/pym/portage/mail.py
index 598c1f9..7268398 100644
--- a/pym/portage/mail.py
+++ b/pym/portage/mail.py
@@ -24,6 +24,20 @@ import portage
 if sys.hexversion >= 0x3000000:
 	basestring = str
 
+	def _force_ascii_if_necessary(s):
+		# Force ascii encoding in order to avoid UnicodeEncodeError
+		# from smtplib.sendmail with python3 (bug #291331).
+		s = _unicode_encode(s,
+			encoding='ascii', errors='backslashreplace')
+		s = _unicode_decode(s,
+			encoding='ascii', errors='replace')
+		return s
+
+else:
+
+	def _force_ascii_if_necessary(s):
+		return s
+
 def TextMessage(_text):
 	from email.mime.text import MIMEText
 	mimetext = MIMEText(_text)
@@ -68,18 +82,16 @@ def create_message(sender, recipient, subject, body, attachments=None):
 	mymessage["To"] = recipient
 	mymessage["From"] = sender
 
-	if sys.hexversion >= 0x3000000:
-		# Avoid UnicodeEncodeError in python3 with non-ascii characters.
-		#  File "/usr/lib/python3.1/email/header.py", line 189, in __init__
-		#    self.append(s, charset, errors)
-		#  File "/usr/lib/python3.1/email/header.py", line 262, in append
-		#    input_bytes = s.encode(input_charset, errors)
-		#UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-9: ordinal not in range(128)
-		mymessage["Subject"] = subject
-	else:
-		# Use Header as a workaround so that long subject lines are wrapped
-		# correctly by <=python-2.6 (gentoo bug #263370, python issue #1974).
-		mymessage["Subject"] = Header(subject)
+	# Use Header as a workaround so that long subject lines are wrapped
+	# correctly by <=python-2.6 (gentoo bug #263370, python issue #1974).
+	# Also, need to force ascii for python3, in order to avoid
+	# UnicodeEncodeError with non-ascii characters:
+	#  File "/usr/lib/python3.1/email/header.py", line 189, in __init__
+	#    self.append(s, charset, errors)
+	#  File "/usr/lib/python3.1/email/header.py", line 262, in append
+	#    input_bytes = s.encode(input_charset, errors)
+	#UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-9: ordinal not in range(128)
+	mymessage["Subject"] = Header(_force_ascii_if_necessary(subject))
 	mymessage["Date"] = time.strftime("%a, %d %b %Y %H:%M:%S %z")
 	
 	return mymessage
@@ -138,7 +150,7 @@ def send_mail(mysettings, message):
 	# user wants to use a sendmail binary instead of smtp
 	if mymailhost[0] == os.sep and os.path.exists(mymailhost):
 		fd = os.popen(mymailhost+" -f "+myfrom+" "+myrecipient, "w")
-		fd.write(message.as_string())
+		fd.write(_force_ascii_if_necessary(message.as_string()))
 		if fd.close() != None:
 			sys.stderr.write(_("!!! %s returned with a non-zero exit code. This generally indicates an error.\n") % mymailhost)
 	else:
@@ -155,15 +167,7 @@ def send_mail(mysettings, message):
 			if mymailuser != "" and mymailpasswd != "":
 				myconn.login(mymailuser, mymailpasswd)
 
-			message_str = message.as_string()
-			if sys.hexversion >= 0x3000000:
-				# Force ascii encoding in order to avoid UnicodeEncodeError
-				# from smtplib.sendmail with python3 (bug #291331).
-				message_str = _unicode_encode(message_str,
-					encoding='ascii', errors='backslashreplace')
-				message_str = _unicode_decode(message_str,
-					encoding='ascii', errors='replace')
-
+			message_str = _force_ascii_if_necessary(message.as_string())
 			myconn.sendmail(myfrom, myrecipient, message_str)
 			myconn.quit()
 		except smtplib.SMTPException as e:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-03-06  0:41 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-03-06  0:41 UTC (permalink / raw
  To: gentoo-commits

commit:     064a235876a0ad6bc34dbb72226064756652c131
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Mar  6 00:41:00 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Mar  6 00:41:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=064a2358

eclass_cache: remove deprecated methods

---
 pym/portage/eclass_cache.py |   17 ++---------------
 1 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py
index 878df4e..1374f1d 100644
--- a/pym/portage/eclass_cache.py
+++ b/pym/portage/eclass_cache.py
@@ -1,6 +1,6 @@
-# Copyright: 2005,2010 Gentoo Foundation
+# Copyright 2005-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
 # Author(s): Nicholas Carpaski (carpaski@gentoo.org), Brian Harring (ferringb@gentoo.org)
-# License: GPL2
 
 __all__ = ["cache"]
 
@@ -61,19 +61,6 @@ class cache(object):
 		self.eclasses.update(other.eclasses)
 		self._eclass_locations.update(other._eclass_locations)
 
-	def close_caches(self):
-		import traceback
-		traceback.print_stack()
-		print("%s close_cache is deprecated" % self.__class__)
-		self.eclasses.clear()
-
-	def flush_cache(self):
-		import traceback
-		traceback.print_stack()
-		print("%s flush_cache is deprecated" % self.__class__)
-
-		self.update_eclasses()
-
 	def update_eclasses(self):
 		self.eclasses = {}
 		self._eclass_locations = {}



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-05-04  4:12 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-05-04  4:12 UTC (permalink / raw
  To: gentoo-commits

commit:     80380311abe71536ac4dda8db54bf9d0b0ec03c1
Author:     Mike Gilbert <floppymaster <AT> gmail <DOT> com>
AuthorDate: Wed May  4 03:28:21 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed May  4 04:11:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=80380311

Fix Manifest.updateAllHashes()

---
 pym/portage/manifest.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index ec801a3..de7540f 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -481,7 +481,7 @@ class Manifest(object):
 	
 	def updateAllHashes(self, checkExisting=False, ignoreMissingFiles=True):
 		""" Regenerate all hashes for all files in this Manifest. """
-		for ftype in portage.const.MANIFEST2_IDENTIFIERS:
+		for idtype in portage.const.MANIFEST2_IDENTIFIERS:
 			self.updateTypeHashes(idtype, fname, checkExisting)
 
 	def updateCpvHashes(self, cpv, ignoreMissingFiles=True):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-06-03 21:51 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-06-03 21:51 UTC (permalink / raw
  To: gentoo-commits

commit:     9bc101a8508a325de3ffe4f1b6239dc300adb8a6
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  3 21:47:55 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jun  3 21:47:55 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9bc101a8

make_http_request: fix request arguments

This will fix "TypeError: must be string or buffer, not dict" with
python 2.7, as reported in bug #369913.

---
 pym/portage/getbinpkg.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 68e4543..a511f51 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -261,7 +261,7 @@ def make_http_request(conn, address, params={}, headers={}, dest=None):
 		try:
 			if (rc != 0):
 				conn,ignore,ignore,ignore,ignore = create_conn(address)
-			conn.request("GET", address, params, headers)
+			conn.request("GET", address, body=None, headers=headers)
 		except SystemExit as e:
 			raise
 		except Exception as e:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-06-09 10:41 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-06-09 10:41 UTC (permalink / raw
  To: gentoo-commits

commit:     65f3a4d8af054756b9b553c341118334b4526075
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  9 10:39:37 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jun  9 10:39:37 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=65f3a4d8

locks: use a private constant for fcntl.lockf

---
 pym/portage/locks.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 1f8f580..50a9200 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -25,6 +25,7 @@ if sys.hexversion >= 0x3000000:
 	basestring = str
 
 HARDLINK_FD = -2
+_default_lock_fn = fcntl.lockf
 
 # Used by emerge in order to disable the "waiting for lock" message
 # so that it doesn't interfere with the status display.
@@ -109,9 +110,9 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 
 	# try for a non-blocking lock, if it's held, throw a message
 	# we're waiting on lockfile and use a blocking attempt.
-	locking_method = fcntl.lockf
+	locking_method = _default_lock_fn
 	try:
-		fcntl.lockf(myfd,fcntl.LOCK_EX|fcntl.LOCK_NB)
+		locking_method(myfd, fcntl.LOCK_EX|fcntl.LOCK_NB)
 	except IOError as e:
 		if "errno" not in dir(e):
 			raise
@@ -135,7 +136,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 				out.ebegin(waiting_msg)
 			# try for the exclusive lock now.
 			try:
-				fcntl.lockf(myfd, fcntl.LOCK_EX)
+				locking_method(myfd, fcntl.LOCK_EX)
 			except EnvironmentError as e:
 				if out is not None:
 					out.eend(1, str(e))



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-06-09 15:44 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-06-09 15:44 UTC (permalink / raw
  To: gentoo-commits

commit:     6c5f977d943745f1eaa47da89e32b6c8cd49f41c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  9 15:43:40 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jun  9 15:43:40 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6c5f977d

lockfile: use hasattr() instead of dir()

---
 pym/portage/locks.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 50a9200..9ed1d6a 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -114,7 +114,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 	try:
 		locking_method(myfd, fcntl.LOCK_EX|fcntl.LOCK_NB)
 	except IOError as e:
-		if "errno" not in dir(e):
+		if not hasattr(e, "errno"):
 			raise
 		if e.errno in (errno.EACCES, errno.EAGAIN):
 			# resource temp unavailable; eg, someone beat us to the lock.



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-07-10 23:46 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-07-10 23:46 UTC (permalink / raw
  To: gentoo-commits

commit:     906b62b24d8a845356d59abc5acd39db2174ce0f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 10 23:40:56 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jul 10 23:45:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=906b62b2

Manifest: fix NameError in updateAllHashes

---
 pym/portage/manifest.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index f273cc2..4714da0 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -482,7 +482,8 @@ class Manifest(object):
 	def updateAllHashes(self, checkExisting=False, ignoreMissingFiles=True):
 		""" Regenerate all hashes for all files in this Manifest. """
 		for idtype in portage.const.MANIFEST2_IDENTIFIERS:
-			self.updateTypeHashes(idtype, fname, checkExisting)
+			self.updateTypeHashes(idtype, checkExisting=checkExisting,
+				ignoreMissingFiles=ignoreMissingFiles)
 
 	def updateCpvHashes(self, cpv, ignoreMissingFiles=True):
 		""" Regenerate all hashes associated to the given cpv (includes all AUX and MISC



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-07-11  0:13 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-07-11  0:13 UTC (permalink / raw
  To: gentoo-commits

commit:     034203acbf22320256aef748d7b0f45e3477e125
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 11 00:12:49 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 11 00:12:49 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=034203ac

Remove unused codecs import.

---
 pym/portage/__init__.py |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 47e2e48..38da8a0 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -10,7 +10,6 @@ VERSION="HEAD"
 
 try:
 	import sys
-	import codecs
 	import errno
 	if not hasattr(errno, 'ESTALE'):
 		# ESTALE may not be defined on some systems, such as interix.



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-07-12 22:49 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-07-12 22:49 UTC (permalink / raw
  To: gentoo-commits

commit:     3e7b0cbe1ccd875de2052821d91846880c76e6e0
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 12 22:46:54 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 22:46:54 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3e7b0cbe

Avoid baseline subprocess import under python2.

---
 pym/portage/__init__.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 5411ec9..2a2eb99 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -17,10 +17,12 @@ try:
 	import re
 	import types
 
+	# Try the commands module first, since this allows us to eliminate
+	# the subprocess module from the baseline imports under python2.
 	try:
-		from subprocess import getstatusoutput as subprocess_getstatusoutput
-	except ImportError:
 		from commands import getstatusoutput as subprocess_getstatusoutput
+	except ImportError:
+		from subprocess import getstatusoutput as subprocess_getstatusoutput
 
 	import platform
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-08-25 21:50 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2011-08-25 21:50 UTC (permalink / raw
  To: gentoo-commits

commit:     2aea972aa0c36531445172500ded32d7ddc07762
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
AuthorDate: Thu Aug 25 21:50:06 2011 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
CommitDate: Thu Aug 25 21:50:06 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2aea972a

Improve a comment.

---
 pym/portage/__init__.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 2a2eb99..78d9b54 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -215,7 +215,7 @@ class _unicode_func_wrapper(object):
 		rval = self._func(*wrapped_args, **wrapped_kwargs)
 
 		# Don't use isinstance() since we don't want to convert subclasses
-		# of tuple such as posix.stat_result in python-3.2.
+		# of tuple such as posix.stat_result in Python >=3.2.
 		if rval.__class__ in (list, tuple):
 			decoded_rval = []
 			for x in rval:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-08-29  5:21 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-08-29  5:21 UTC (permalink / raw
  To: gentoo-commits

commit:     276105a80d8fd1e6332a2dcb9733bf597fbcb0ed
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 29 05:20:49 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Aug 29 05:20:49 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=276105a8

python3.2 fixes: ResourceWarning: unclosed file

---
 pym/portage/update.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/pym/portage/update.py b/pym/portage/update.py
index 548d19c..1a2c86c 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -253,14 +253,19 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c
 			recursivefiles.append(x)
 	myxfiles = recursivefiles
 	for x in myxfiles:
+		f = None
 		try:
-			file_contents[x] = io.open(
+			f = io.open(
 				_unicode_encode(os.path.join(abs_user_config, x),
 				encoding=_encodings['fs'], errors='strict'),
 				mode='r', encoding=_encodings['content'],
-				errors='replace').readlines()
+				errors='replace')
+			file_contents[x] = f.readlines()
 		except IOError:
 			continue
+		finally:
+			if f is not None:
+				f.close()
 
 	# update /etc/portage/packages.*
 	ignore_line_re = re.compile(r'^#|^\s*$')



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-09-02  2:14 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-09-02  2:14 UTC (permalink / raw
  To: gentoo-commits

commit:     82562066096bcb3fa57656775aa79bad69bceada
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Sep  2 02:10:51 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Sep  2 02:10:51 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=82562066

Use utf_8 encoding for merge when ascii is configured.

It probably won't hurt, and forced conversion to ascii encoding is
known to break some packages that install file names with utf_8
encoding (see bug #381509). The ascii aliases are borrowed from
python's encodings.aliases.aliases dict.

---
 pym/portage/__init__.py |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 72cdf2d..901ea2c 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -158,9 +158,20 @@ _encodings = {
 	'stdio'                  : 'utf_8',
 }
 
-# This can happen if python is built with USE=build (stage 1).
-if _encodings['merge'] is None:
-	_encodings['merge'] = 'ascii'
+# sys.getfilesystemencoding() can return None if python is built with
+# USE=build (stage 1). If the filesystem encoding is undefined or is a
+# subset of utf_8, then we default to utf_8 encoding for merges, since
+# it probably won't hurt, and forced conversion to ascii encoding is
+# known to break some packages that install file names with utf_8
+# encoding (see bug #381509). The ascii aliases are borrowed from
+# python's encodings.aliases.aliases dict.
+if _encodings['merge'] is None or \
+	_encodings['merge'].lower().replace('-', '_') in \
+	('ascii', '646', 'ansi_x3.4_1968', 'ansi_x3_4_1968',
+	'ansi_x3.4_1986', 'cp367', 'csascii', 'ibm367', 'iso646_us',
+	'iso_646.irv_1991', 'iso_ir_6', 'us', 'us_ascii'):
+
+	_encodings['merge'] = 'utf_8'
 
 if sys.hexversion >= 0x3000000:
 	def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-09-06 19:15 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-09-06 19:15 UTC (permalink / raw
  To: gentoo-commits

commit:     4cb0e06b04d5dfa9c257decf9895365f975fb17c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Sep  6 19:15:06 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Sep  6 19:15:06 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4cb0e06b

abssymlink: fix inverted logic from last commit

---
 pym/portage/__init__.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d73ea6d..789d043 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -393,7 +393,7 @@ getcwd()
 
 def abssymlink(symlink, target=None):
 	"This reads symlinks, resolving the relative symlinks, and returning the absolute."
-	if target is None:
+	if target is not None:
 		mylink = target
 	else:
 		mylink = os.readlink(symlink)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-09-09  4:06 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-09-09  4:06 UTC (permalink / raw
  To: gentoo-commits

commit:     58eb89592bfc3ac40ac0235ebcc52910b51a826c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Sep  9 04:05:58 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Sep  9 04:05:58 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=58eb8959

getbinpkg: fix old binhost protocol for python3

This will fix bug #382233.

---
 pym/portage/getbinpkg.py |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 3e58672..579a46f 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -8,7 +8,9 @@ from portage.localization import _
 import portage
 from portage import os
 from portage import _encodings
+from portage import _unicode_decode
 from portage import _unicode_encode
+from _emerge.Package import _all_metadata_keys
 
 import sys
 import socket
@@ -65,8 +67,15 @@ def make_metadata_dict(data):
 	myid,myglob = data
 	
 	mydict = {}
-	for x in portage.xpak.getindex_mem(myid):
-		mydict[x] = portage.xpak.getitem(data,x)
+	for k_bytes in portage.xpak.getindex_mem(myid):
+		k = _unicode_decode(k_bytes,
+			encoding=_encodings['repo.content'], errors='replace')
+		if k not in _all_metadata_keys and \
+			k != "CATEGORY":
+			continue
+		v = _unicode_decode(portage.xpak.getitem(data, k_bytes),
+			encoding=_encodings['repo.content'], errors='replace')
+		mydict[k] = v
 
 	return mydict
 
@@ -354,7 +363,7 @@ def dir_get_list(baseurl,conn=None):
 		
 		if page:
 			parser = ParseLinks()
-			parser.feed(page)
+			parser.feed(_unicode_decode(page))
 			del page
 			listing = parser.get_anchors()
 		else:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-09-09 20:47 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-09-09 20:47 UTC (permalink / raw
  To: gentoo-commits

commit:     db32c3e3ca1e3cc724acacc79a5be2343efc13d1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Sep  9 20:47:30 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Sep  9 20:47:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=db32c3e3

Use utf_8 'merge' encoding for all locales.

Previously, we used sys.getfilesystemencoding() for the 'merge'
encoding, but that had various problems:

   1) If the locale is ever changed then it can cause orphan files due
      to changed character set translation.

   2) Ebuilds typically install files with utf_8 encoded file names,
      and then portage would be forced to rename those files to match
      sys.getfilesystemencoding(), possibly breaking things.

   3) Automatic translation between encodings can lead to nonsensical
      file names when the source encoding is unknown by portage.

   4) It's inconvenient for ebuilds to convert the encodings of file
      names themselves, and upstreams typically encode file names with
      utf_8 encoding.

So, instead of relying on sys.getfilesystemencoding(), we avoid the above
problems by using a constant utf_8 'merge' encoding for all locales, as
discussed in bug #382199 and bug #381509.

---
 pym/portage/__init__.py |   40 ++++++++++++++++++++++------------------
 1 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 789d043..d3df6e3 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -148,31 +148,35 @@ if sys.hexversion >= 0x3000000:
 	basestring = str
 	long = int
 
-# Assume utf_8 fs encoding everywhere except in merge code, where the
-# user's locale is respected.
+# We use utf_8 encoding everywhere. Previously, we used
+# sys.getfilesystemencoding() for the 'merge' encoding, but that had
+# various problems:
+#
+#   1) If the locale is ever changed then it can cause orphan files due
+#      to changed character set translation.
+#
+#   2) Ebuilds typically install files with utf_8 encoded file names,
+#      and then portage would be forced to rename those files to match
+#      sys.getfilesystemencoding(), possibly breaking things.
+#
+#   3) Automatic translation between encodings can lead to nonsensical
+#      file names when the source encoding is unknown by portage.
+#
+#   4) It's inconvenient for ebuilds to convert the encodings of file
+#      names to match the current locale, and upstreams typically encode
+#      file names with utf_8 encoding.
+#
+# So, instead of relying on sys.getfilesystemencoding(), we avoid the above
+# problems by using a constant utf_8 'merge' encoding for all locales, as
+# discussed in bug #382199 and bug #381509.
 _encodings = {
 	'content'                : 'utf_8',
 	'fs'                     : 'utf_8',
-	'merge'                  : sys.getfilesystemencoding(),
+	'merge'                  : 'utf_8',
 	'repo.content'           : 'utf_8',
 	'stdio'                  : 'utf_8',
 }
 
-# sys.getfilesystemencoding() can return None if python is built with
-# USE=build (stage 1). If the filesystem encoding is undefined or is a
-# subset of utf_8, then we default to utf_8 encoding for merges, since
-# it probably won't hurt, and forced conversion to ascii encoding is
-# known to break some packages that install file names with utf_8
-# encoding (see bug #381509). The ascii aliases are borrowed from
-# python's encodings.aliases.aliases dict.
-if _encodings['merge'] is None or \
-	_encodings['merge'].lower().replace('-', '_') in \
-	('ascii', '646', 'ansi_x3.4_1968', 'ansi_x3_4_1968',
-	'ansi_x3.4_1986', 'cp367', 'csascii', 'ibm367', 'iso646_us',
-	'iso_646.irv_1991', 'iso_ir_6', 'us', 'us_ascii'):
-
-	_encodings['merge'] = 'utf_8'
-
 if sys.hexversion >= 0x3000000:
 	def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'):
 		if isinstance(s, str):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-09-14  2:35 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-09-14  2:35 UTC (permalink / raw
  To: gentoo-commits

commit:     e91f097c248fa02b2273b2fd9b142703fda5372d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 14 02:35:36 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Sep 14 02:35:36 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e91f097c

manifest: remove unused 'pf is None' case

---
 pym/portage/manifest.py |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index ef1a552..4fd44b0 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -376,8 +376,6 @@ class Manifest(object):
 		if not filename.endswith(".ebuild"):
 			return None
 		pf = filename[:-7]
-		if pf is None:
-			return None
 		ps = portage.versions._pkgsplit(pf)
 		cpv = "%s/%s" % (cat, pf)
 		if not ps:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-09-15  2:23 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-09-15  2:23 UTC (permalink / raw
  To: gentoo-commits

commit:     d1f3fdfb943a9021d454c12b3418e44e5275ad69
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 15 02:21:45 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Sep 15 02:21:45 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d1f3fdfb

Don't write empty (thin) Manifest files.

With thin manifest, there's no need to have a Manifest file if there
are no DIST entries.

---
 pym/portage/manifest.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 3f0aa93..32cc2c0 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -257,7 +257,10 @@ class Manifest(object):
 								break
 				except (IOError, OSError) as e:
 					if e.errno == errno.ENOENT:
-						pass
+						if not myentries:
+							# With thin manifest, there's no need to have
+							# a Manifest file if there are no DIST entries.
+							update_manifest = False
 					else:
 						raise
 			if update_manifest:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-09-15  2:38 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-09-15  2:38 UTC (permalink / raw
  To: gentoo-commits

commit:     7a216218968dc1d00f2881121870611bc1b5dd33
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 15 02:36:54 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Sep 15 02:36:54 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7a216218

Remove Manifest if it is not needed.

With thin manifest, there's no need to have a Manifest file if there
are no DIST entries.

---
 pym/portage/manifest.py |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 32cc2c0..449f9fd 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -241,7 +241,7 @@ class Manifest(object):
 		try:
 			myentries = list(self._createManifestEntries())
 			update_manifest = True
-			if not force:
+			if myentries and not force:
 				try:
 					f = io.open(_unicode_encode(self.getFullname(),
 						encoding=_encodings['fs'], errors='strict'),
@@ -257,15 +257,23 @@ class Manifest(object):
 								break
 				except (IOError, OSError) as e:
 					if e.errno == errno.ENOENT:
-						if not myentries:
-							# With thin manifest, there's no need to have
-							# a Manifest file if there are no DIST entries.
-							update_manifest = False
+						pass
 					else:
 						raise
+
 			if update_manifest:
-				write_atomic(self.getFullname(),
-					"".join("%s\n" % str(myentry) for myentry in myentries))
+				if myentries:
+					write_atomic(self.getFullname(), "".join("%s\n" %
+						str(myentry) for myentry in myentries))
+				else:
+					# With thin manifest, there's no need to have
+					# a Manifest file if there are no DIST entries.
+					try:
+						os.unlink(self.getFullname())
+					except OSError as e:
+						if e.errno != errno.ENOENT:
+							raise
+
 			if sign:
 				self.sign()
 		except (IOError, OSError) as e:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-09-28  6:49 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-09-28  6:49 UTC (permalink / raw
  To: gentoo-commits

commit:     6d35053a55470f9e8d5c359215f18d75acbcf043
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 28 06:48:59 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Sep 28 06:48:59 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6d35053a

Manifest.write(): tweak unlink logic

This narrows the range of possible behaviors, such that the manifest
will always be either written or unlinked, eliminating the possiblity
that a stale manifest will ever be allowed to slip through without
being overwritten or unlinked.

---
 pym/portage/manifest.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 7cac09c..49c05bd 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -267,10 +267,14 @@ class Manifest(object):
 						raise
 
 			if update_manifest:
-				if myentries:
+				if myentries or not (self.thin or self.allow_missing):
+					# If myentries is empty, don't write an empty manifest
+					# when thin or allow_missing is enabled. Except for
+					# thin manifests with no DIST entries, myentries is
+					# non-empty for all currently known use cases.
 					write_atomic(self.getFullname(), "".join("%s\n" %
 						str(myentry) for myentry in myentries))
-				elif self.thin:
+				else:
 					# With thin manifest, there's no need to have
 					# a Manifest file if there are no DIST entries.
 					try:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-02  4:58 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-02  4:58 UTC (permalink / raw
  To: gentoo-commits

commit:     c246c6db51b97f1c556c8bddfb955e7f55db700f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  2 04:58:35 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 04:58:35 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c246c6db

Convert create_color_func into a class.

---
 pym/portage/output.py |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 763d74a..6b10f7b 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -341,12 +341,12 @@ compat_functions_colors = ["bold","white","teal","turquoise","darkteal",
 	"fuchsia","purple","blue","darkblue","green","darkgreen","yellow",
 	"brown","darkyellow","red","darkred"]
 
-def create_color_func(color_key):
-	def derived_func(*args):
-		newargs = list(args)
-		newargs.insert(0, color_key)
-		return colorize(*newargs)
-	return derived_func
+class create_color_func(object):
+	__slots__ = ("_color_key",)
+	def __init__(self, color_key):
+		self._color_key = color_key
+	def __call__(self, text):
+		return colorize(self._color_key, text)
 
 for c in compat_functions_colors:
 	globals()[c] = create_color_func(c)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-02  5:18 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-02  5:18 UTC (permalink / raw
  To: gentoo-commits

commit:     1ae379c59a5cdc2d729f2b33807e70548afcbfb4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  2 05:17:52 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 05:17:52 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1ae379c5

Convert _generate_hash_function into a class.

---
 pym/portage/checksum.py |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 9e7e455..52e45d3 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -16,8 +16,16 @@ import tempfile
 hashfunc_map = {}
 hashorigin_map = {}
 
-def _generate_hash_function(hashtype, hashobject, origin="unknown"):
-	def pyhash(filename):
+class _generate_hash_function(object):
+
+	__slots__ = ("_hashobject",)
+
+	def __init__(self, hashtype, hashobject, origin="unknown"):
+		self._hashobject = hashobject
+		hashfunc_map[hashtype] = self
+		hashorigin_map[hashtype] = origin
+
+	def __call__(self, filename):
 		"""
 		Run a checksum against a file.
 	
@@ -41,7 +49,7 @@ def _generate_hash_function(hashtype, hashobject, origin="unknown"):
 		blocksize = HASHING_BLOCKSIZE
 		data = f.read(blocksize)
 		size = 0
-		checksum = hashobject()
+		checksum = self._hashobject()
 		while data:
 			checksum.update(data)
 			size = size + len(data)
@@ -49,9 +57,6 @@ def _generate_hash_function(hashtype, hashobject, origin="unknown"):
 		f.close()
 
 		return (checksum.hexdigest(), size)
-	hashfunc_map[hashtype] = pyhash
-	hashorigin_map[hashtype] = origin
-	return pyhash
 
 # Define hash functions, try to use the best module available. Later definitions
 # override earlier ones



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-02  5:25 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-02  5:25 UTC (permalink / raw
  To: gentoo-commits

commit:     f27473d04e6dee44983d1e5ac32ea9d4d375b5a2
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  1 07:40:51 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 05:24:58 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f27473d0

Refactor RMD160 hashlib code for less-hardcoding

To be used shortly for WHIRLPOOL as well as RMD160.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

---
 pym/portage/checksum.py |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 52e45d3..8daefbc 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -87,19 +87,22 @@ except ImportError as e:
 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
 # Need special handling for RMD160 as it may not always be provided by hashlib.
 try:
-	import hashlib
+	import hashlib, functools
 	
 	md5hash = _generate_hash_function("MD5", hashlib.md5, origin="hashlib")
 	sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
 	sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
-	try:
-		hashlib.new('ripemd160')
-	except ValueError:
-		pass
-	else:
-		def rmd160():
-			return hashlib.new('ripemd160')
-		rmd160hash = _generate_hash_function("RMD160", rmd160, origin="hashlib")
+	for local_name, hash_name in (("rmd160", "ripemd160"), ):
+		try:
+			hashlib.new(hash_name)
+		except ValueError:
+			pass
+		else:
+			globals()['%shash' % local_name] = \
+				_generate_hash_function(local_name.upper(), \
+				functools.partial(hashlib.new, hash_name), \
+				origin='hashlib')
+
 except ImportError as e:
 	pass
 	



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-02  5:42 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-02  5:42 UTC (permalink / raw
  To: gentoo-commits

commit:     8ac29097395f24ad331602d8e87fdf105ebd972b
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  1 07:40:53 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 05:37:06 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8ac29097

Manifest2 hash: SHA512

Provide SHA512 hash algorithm to be used as new Manifest2 hash.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

---
 pym/portage/checksum.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index a4cf8de..6bace4d 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -96,6 +96,7 @@ try:
 	md5hash = _generate_hash_function("MD5", hashlib.md5, origin="hashlib")
 	sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
 	sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
+	sha512hash = _generate_hash_function("SHA512", hashlib.sha512, origin="hashlib")
 	for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")):
 		try:
 			hashlib.new(hash_name)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-02  5:55 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-02  5:55 UTC (permalink / raw
  To: gentoo-commits

commit:     faf87ba9877e3b5a7866c6649f956f15950e789a
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  1 07:40:54 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 05:55:02 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=faf87ba9

Manifest2 hash backend provider: mhash

Offer mhash as a provider for Manifest2 hash generation and validation.
This is important as either of pycrypto or fchksum offer an accelerated
Whirlpool implementation, and hashlib might not offer it. Additionally,
the mhash implementation is accelerated and ships with a rigorious
testsuite.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

---
 pym/portage/checksum.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 6bace4d..a4a744b 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -80,6 +80,25 @@ sha1hash = _generate_hash_function("SHA1", _new_sha1, origin="internal")
 from portage.util.whirlpool import new as _new_whirlpool
 whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
 
+# Try to use mhash if available
+# mhash causes GIL presently, so it gets less priority than hashlib and
+# pycrypto. However, it might be the only accelerated implementation of
+# WHIRLPOOL available.
+try:
+	import mhash, functools
+	md5hash = _generate_hash_function("MD5", functools.partial(mhash.MHASH, mhash.MHASH_MD5), origin="mhash")
+	sha1hash = _generate_hash_function("SHA1", functools.partial(mhash.MHASH, mhash.MHASH_SHA1), origin="mhash")
+	sha256hash = _generate_hash_function("SHA256", functools.partial(mhash.MHASH, mhash.MHASH_SHA256), origin="mhash")
+	sha512hash = _generate_hash_function("SHA512", functools.partial(mhash.MHASH, mhash.MHASH_SHA512), origin="mhash")
+	for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")):
+		if hasattr(mhash, 'MHASH_%s' % local_name.upper()):
+			globals()['%shash' % local_name] = \
+				_generate_hash_function(local_name.upper(), \
+				functools.partial(mhash.MHASH, getattr(mhash, 'MHASH_%s' % hash_name.upper())), \
+				origin='mhash')
+except ImportError:
+	pass
+
 # Use pycrypto when available, prefer it over the internal fallbacks
 try:
 	from Crypto.Hash import SHA256, RIPEMD



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-02  6:01 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-02  6:01 UTC (permalink / raw
  To: gentoo-commits

commit:     06ad8911b5790a2ed963fe1b981751ab0a2be8d5
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  2 06:01:17 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 06:01:17 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=06ad8911

checksum.py: lazily import bundled whirlpool

---
 pym/portage/checksum.py |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index a4a744b..080a6df 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -76,10 +76,6 @@ except ImportError:
 
 sha1hash = _generate_hash_function("SHA1", _new_sha1, origin="internal")
 
-# Bundled WHIRLPOOL implementation
-from portage.util.whirlpool import new as _new_whirlpool
-whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
-
 # Try to use mhash if available
 # mhash causes GIL presently, so it gets less priority than hashlib and
 # pycrypto. However, it might be the only accelerated implementation of
@@ -104,7 +100,7 @@ try:
 	from Crypto.Hash import SHA256, RIPEMD
 	sha256hash = _generate_hash_function("SHA256", SHA256.new, origin="pycrypto")
 	rmd160hash = _generate_hash_function("RMD160", RIPEMD.new, origin="pycrypto")
-except ImportError as e:
+except ImportError:
 	pass
 
 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
@@ -127,9 +123,13 @@ try:
 				functools.partial(hashlib.new, hash_name), \
 				origin='hashlib')
 
-except ImportError as e:
+except ImportError:
 	pass
-	
+
+if "WHIRLPOOL" not in hashfunc_map:
+	# Bundled WHIRLPOOL implementation
+	from portage.util.whirlpool import new as _new_whirlpool
+	whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
 
 # Use python-fchksum if available, prefer it over all other MD5 implementations
 try:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-02  6:32 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-02  6:32 UTC (permalink / raw
  To: gentoo-commits

commit:     a1ed3230d6a121fb2bccc0a1d51255cae382ed4f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  2 06:31:52 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 06:31:52 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a1ed3230

checksum.py: use fchksum.fmd5t directly

---
 pym/portage/checksum.py |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 080a6df..9f3d81c 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -133,10 +133,7 @@ if "WHIRLPOOL" not in hashfunc_map:
 
 # Use python-fchksum if available, prefer it over all other MD5 implementations
 try:
-	import fchksum
-	
-	def md5hash(filename):
-		return fchksum.fmd5t(filename)
+	from fchksum import fmd5t as md5hash
 	hashfunc_map["MD5"] = md5hash
 	hashorigin_map["MD5"] = "python-fchksum"
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-02 22:54 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-02 22:54 UTC (permalink / raw
  To: gentoo-commits

commit:     814200b68822ed2681dc434631c99ad3c9251fc8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  2 22:53:39 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 22:53:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=814200b6

Manifest.create(): pass allow_* to constructor

This fixes commit f3101b3adce6731790f80f83fafece54b7bd8a63 to ensure
that Manifest.create() works correctly.

---
 pym/portage/manifest.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 49c05bd..9db8acc 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -349,7 +349,8 @@ class Manifest(object):
 			distfilehashes = {}
 		self.__init__(self.pkgdir, self.distdir,
 			fetchlist_dict=self.fetchlist_dict, from_scratch=True,
-			thin=self.thin)
+			thin=self.thin, allow_missing=self.allow_missing,
+			allow_create=self.allow_create)
 		pn = os.path.basename(self.pkgdir.rstrip(os.path.sep))
 		cat = self._pkgdir_category()
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-02 23:43 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-02 23:43 UTC (permalink / raw
  To: gentoo-commits

commit:     e5b963b794be20276786447bc4f2515e17e38086
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  2 23:43:27 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 23:43:27 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e5b963b7

Manifest.create(): tweak assume-digests code

If we have a local file, before we assume that we don't need to compute
any digests, make sure that the pre-computed digest types are exactly
the same types that we desire.

---
 pym/portage/manifest.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 9db8acc..d09de26 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -387,7 +387,7 @@ class Manifest(object):
 				((assumeDistHashesSometimes and mystat is None) or \
 				(assumeDistHashesAlways and mystat is None) or \
 				(assumeDistHashesAlways and mystat is not None and \
-				len(distfilehashes[f]) == len(self.hashes) and \
+				set(distfilehashes[f]) == set(self.hashes) and \
 				distfilehashes[f]["size"] == mystat.st_size)):
 				self.fhashdict["DIST"][f] = distfilehashes[f]
 			else:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-03 17:42 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-03 17:42 UTC (permalink / raw
  To: gentoo-commits

commit:     255e31ccb265fac768857da3ee6d966151a1e561
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct  3 17:42:25 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct  3 17:42:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=255e31cc

manfest.py: import constants directly

---
 pym/portage/manifest.py |   37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 78153c0..da40ae1 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -18,8 +18,8 @@ from portage import _unicode_encode
 from portage.exception import DigestException, FileNotFound, \
 	InvalidDataType, MissingParameter, PermissionDenied, \
 	PortageException, PortagePackageException
-from portage.const import (MANIFEST2_HASH_DEFAULTS,
-	MANIFEST2_HASH_FUNCTIONS, MANIFEST2_REQUIRED_HASH)
+from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS,
+	MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH)
 from portage.localization import _
 
 class FileNotInManifestException(PortageException):
@@ -60,7 +60,7 @@ def guessThinManifestFileType(filename):
 
 def parseManifest2(mysplit):
 	myentry = None
-	if len(mysplit) > 4 and mysplit[0] in portage.const.MANIFEST2_IDENTIFIERS:
+	if len(mysplit) > 4 and mysplit[0] in MANIFEST2_IDENTIFIERS:
 		mytype = mysplit[0]
 		myname = mysplit[1]
 		try:
@@ -127,8 +127,8 @@ class Manifest(object):
 		self.hashes.difference_update(hashname for hashname in \
 			list(self.hashes) if hashname not in hashfunc_map)
 		self.hashes.add("size")
-		self.hashes.add(portage.const.MANIFEST2_REQUIRED_HASH)
-		for t in portage.const.MANIFEST2_IDENTIFIERS:
+		self.hashes.add(MANIFEST2_REQUIRED_HASH)
+		for t in MANIFEST2_IDENTIFIERS:
 			self.fhashdict[t] = {}
 		if not from_scratch:
 			self._read()
@@ -152,7 +152,7 @@ class Manifest(object):
 	def getDigests(self):
 		""" Compability function for old digest/manifest code, returns dict of filename:{hashfunction:hashvalue} """
 		rval = {}
-		for t in portage.const.MANIFEST2_IDENTIFIERS:
+		for t in MANIFEST2_IDENTIFIERS:
 			rval.update(self.fhashdict[t])
 		return rval
 	
@@ -223,7 +223,7 @@ class Manifest(object):
 		return myhashdict
 
 	def _createManifestEntries(self):
-		valid_hashes = set(portage.const.MANIFEST2_HASH_FUNCTIONS)
+		valid_hashes = set(MANIFEST2_HASH_FUNCTIONS)
 		valid_hashes.add('size')
 		mytypes = list(self.fhashdict)
 		mytypes.sort()
@@ -241,8 +241,9 @@ class Manifest(object):
 	def checkIntegrity(self):
 		for t in self.fhashdict:
 			for f in self.fhashdict[t]:
-				if portage.const.MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]:
-					raise MissingParameter(_("Missing %s checksum: %s %s") % (portage.const.MANIFEST2_REQUIRED_HASH, t, f))
+				if MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]:
+					raise MissingParameter(_("Missing %s checksum: %s %s") %
+						(MANIFEST2_REQUIRED_HASH, t, f))
 
 	def write(self, sign=False, force=False):
 		""" Write Manifest instance to disk, optionally signing it """
@@ -310,14 +311,14 @@ class Manifest(object):
 			fname = os.path.join("files", fname)
 		if not os.path.exists(self.pkgdir+fname) and not ignoreMissing:
 			raise FileNotFound(fname)
-		if not ftype in portage.const.MANIFEST2_IDENTIFIERS:
+		if not ftype in MANIFEST2_IDENTIFIERS:
 			raise InvalidDataType(ftype)
 		if ftype == "AUX" and fname.startswith("files"):
 			fname = fname[6:]
 		self.fhashdict[ftype][fname] = {}
 		if hashdict != None:
 			self.fhashdict[ftype][fname].update(hashdict)
-		if not portage.const.MANIFEST2_REQUIRED_HASH in self.fhashdict[ftype][fname]:
+		if not MANIFEST2_REQUIRED_HASH in self.fhashdict[ftype][fname]:
 			self.updateFileHashes(ftype, fname, checkExisting=False, ignoreMissing=ignoreMissing)
 	
 	def removeFile(self, ftype, fname):
@@ -330,7 +331,7 @@ class Manifest(object):
 	
 	def findFile(self, fname):
 		""" Return entrytype of the given file if present in Manifest or None if not present """
-		for t in portage.const.MANIFEST2_IDENTIFIERS:
+		for t in MANIFEST2_IDENTIFIERS:
 			if fname in self.fhashdict[t]:
 				return t
 		return None
@@ -380,7 +381,7 @@ class Manifest(object):
 			requiredDistfiles = distlist.copy()
 		required_hash_types = set()
 		required_hash_types.add("size")
-		required_hash_types.add(portage.const.MANIFEST2_REQUIRED_HASH)
+		required_hash_types.add(MANIFEST2_REQUIRED_HASH)
 		for f in distlist:
 			fname = os.path.join(self.distdir, f)
 			mystat = None
@@ -489,7 +490,7 @@ class Manifest(object):
 		return absname	
 	
 	def checkAllHashes(self, ignoreMissingFiles=False):
-		for t in portage.const.MANIFEST2_IDENTIFIERS:
+		for t in MANIFEST2_IDENTIFIERS:
 			self.checkTypeHashes(t, ignoreMissingFiles=ignoreMissingFiles)
 	
 	def checkTypeHashes(self, idtype, ignoreMissingFiles=False):
@@ -553,7 +554,7 @@ class Manifest(object):
 	
 	def updateAllHashes(self, checkExisting=False, ignoreMissingFiles=True):
 		""" Regenerate all hashes for all files in this Manifest. """
-		for idtype in portage.const.MANIFEST2_IDENTIFIERS:
+		for idtype in MANIFEST2_IDENTIFIERS:
 			self.updateTypeHashes(idtype, checkExisting=checkExisting,
 				ignoreMissingFiles=ignoreMissingFiles)
 
@@ -598,9 +599,11 @@ class Manifest(object):
 		myfile.close()
 		for l in lines:
 			mysplit = l.split()
-			if len(mysplit) == 4 and mysplit[0] in portage.const.MANIFEST1_HASH_FUNCTIONS and not 1 in rVal:
+			if len(mysplit) == 4 and mysplit[0] in MANIFEST1_HASH_FUNCTIONS \
+				and 1 not in rVal:
 				rVal.append(1)
-			elif len(mysplit) > 4 and mysplit[0] in portage.const.MANIFEST2_IDENTIFIERS and ((len(mysplit) - 3) % 2) == 0 and not 2 in rVal:
+			elif len(mysplit) > 4 and mysplit[0] in MANIFEST2_IDENTIFIERS \
+				and ((len(mysplit) - 3) % 2) == 0 and not 2 in rVal:
 				rVal.append(2)
 		return rVal
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-08  8:05 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-08  8:05 UTC (permalink / raw
  To: gentoo-commits

commit:     e606fa6e8c23bff65618d73dfc19b8dd301460e1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  8 08:03:17 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Oct  8 08:03:17 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e606fa6e

portage/mail: always UTF-8 charset for MIMEText

This will fix bug #386095.

---
 pym/portage/mail.py |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/pym/portage/mail.py b/pym/portage/mail.py
index 17dfcaf..3fcadd2 100644
--- a/pym/portage/mail.py
+++ b/pym/portage/mail.py
@@ -40,8 +40,7 @@ else:
 def TextMessage(_text):
 	from email.mime.text import MIMEText
 	mimetext = MIMEText(_text)
-	if sys.hexversion >= 0x3000000:
-		mimetext.set_charset("UTF-8")
+	mimetext.set_charset("UTF-8")
 	return mimetext
 
 def create_message(sender, recipient, subject, body, attachments=None):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-15  1:49 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-15  1:49 UTC (permalink / raw
  To: gentoo-commits

commit:     5e88b0d4ced1deb01ae18ea7868745d35b2fd7b2
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 15 01:49:13 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Oct 15 01:49:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5e88b0d4

eclass_cache: fix cache_getter typo

This triggered a regression since commit
2ed1cb53cc4158af08c22d466b15b9a9a7767212 that caused cache entries
containing eclass paths to appear invalid.

---
 pym/portage/eclass_cache.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py
index fb18741..2f6e947 100644
--- a/pym/portage/eclass_cache.py
+++ b/pym/portage/eclass_cache.py
@@ -138,7 +138,7 @@ class cache(object):
 		our_getter = operator.attrgetter(chf_type)
 		cache_getter = lambda x:x
 		if stores_paths:
-			key_getter = operator.itemgetter(1)
+			cache_getter = operator.itemgetter(1)
 		d = {}
 		for eclass, ec_data in ec_dict.items():
 			cached_data = self.eclasses.get(eclass)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-16 12:50 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2011-10-16 12:50 UTC (permalink / raw
  To: gentoo-commits

commit:     c9e22480dbb1767cc0e59eee5c1c3b358da7a078
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
AuthorDate: Sun Oct 16 12:49:58 2011 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
CommitDate: Sun Oct 16 12:49:58 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c9e22480

Fix a typo in a comment.

---
 pym/portage/eclass_cache.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py
index 808662b..adfe69a 100644
--- a/pym/portage/eclass_cache.py
+++ b/pym/portage/eclass_cache.py
@@ -29,7 +29,7 @@ class hashed_path(object):
 			# some rounding issues that aren't present for people using
 			# the straight c api.
 			# thus use the defacto python compatibility work around;
-			# access via index, which gurantees you get the raw long.
+			# access via index, which guarantees you get the raw long.
 			self.mtime = obj = os.stat(self.location)[stat.ST_MTIME]
 			return obj
 		if not attr.islower():



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-17  3:00 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-17  3:00 UTC (permalink / raw
  To: gentoo-commits

commit:     60a2c22e1c40bb2e575320c5d30a5c23bb0a16bd
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 17 03:00:08 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 17 03:00:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=60a2c22e

hashed_path: convert OSError to PermissionDenied

---
 pym/portage/eclass_cache.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py
index 4a934f1..77adcd0 100644
--- a/pym/portage/eclass_cache.py
+++ b/pym/portage/eclass_cache.py
@@ -35,6 +35,8 @@ class hashed_path(object):
 			except OSError as e:
 				if e.errno in (errno.ENOENT, errno.ESTALE):
 					raise FileNotFound(self.location)
+				elif e.errno == PermissionDenied.errno:
+					raise PermissionDenied(self.location)
 				raise
 			return obj
 		if not attr.islower():



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-17  3:04 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-17  3:04 UTC (permalink / raw
  To: gentoo-commits

commit:     5e2982d998ac5683612de4a776f92a0887a8839d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 17 03:03:25 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 17 03:03:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5e2982d9

perform_checksum: OSerror to PermissionDenied

---
 pym/portage/checksum.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 9f3d81c..e0bff2a 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -284,8 +284,10 @@ def perform_checksum(filename, hashname="MD5", calc_prelink=0):
 					" hash function not available (needs dev-python/pycrypto)")
 			myhash, mysize = hashfunc_map[hashname](myfilename)
 		except (OSError, IOError) as e:
-			if e.errno == errno.ENOENT:
+			if e.errno in (errno.ENOENT, errno.ESTALE):
 				raise portage.exception.FileNotFound(myfilename)
+			elif e.errno == portage.exception.PermissionDenied.errno:
+				raise portage.exception.PermissionDenied(myfilename)
 			raise
 		return myhash, mysize
 	finally:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-17 21:46 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-17 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     58b1c71329f9d9ce0ee3a004d9ecaa8887d1dfd5
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 17 21:42:09 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 17 21:42:09 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=58b1c713

eclass_cache: fix volatile cache DigestException

The deepcopy in catch/volatile.py misbehaved when it tried to copy
attributes like __DEEPCOPY__ that didn't correspond to known functions.

---
 pym/portage/eclass_cache.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py
index 77adcd0..1044ad0 100644
--- a/pym/portage/eclass_cache.py
+++ b/pym/portage/eclass_cache.py
@@ -42,10 +42,10 @@ class hashed_path(object):
 		if not attr.islower():
 			# we don't care to allow .mD5 as an alias for .md5
 			raise AttributeError(attr)
-		try:
-			val = checksum.perform_checksum(self.location, attr.upper())[0]
-		except KeyError:
+		hashname = attr.upper()
+		if hashname not in checksum.hashfunc_map:
 			raise AttributeError(attr)
+		val = checksum.perform_checksum(self.location, hashname)[0]
 		setattr(self, attr, val)
 		return val
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-23 18:32 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-23 18:32 UTC (permalink / raw
  To: gentoo-commits

commit:     a3005f69ba99d0e882da44716e3743737e6e4987
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 23 18:31:05 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct 23 18:31:05 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a3005f69

parse_updates: filter invalid for bug #388187

---
 pym/portage/update.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/pym/portage/update.py b/pym/portage/update.py
index 1a2c86c..6d13dfc 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -156,6 +156,7 @@ def parse_updates(mycontent):
 			if len(mysplit) != 3:
 				errors.append(_("ERROR: Update command invalid '%s'") % myline)
 				continue
+			valid = True
 			for i in (1, 2):
 				try:
 					atom = Atom(mysplit[i])
@@ -169,7 +170,11 @@ def parse_updates(mycontent):
 				else:
 					errors.append(
 						_("ERROR: Malformed update entry '%s'") % myline)
+					valid = False
 					break
+			if not valid:
+				continue
+
 		if mysplit[0] == "slotmove":
 			if len(mysplit)!=4:
 				errors.append(_("ERROR: Update command invalid '%s'") % myline)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-26 21:51 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-26 21:51 UTC (permalink / raw
  To: gentoo-commits

commit:     8b41c9adc96e7b2482be7a43e08f582cca96f5ca
Author:     Martin von Gagern <Martin.vGagern <AT> gmx <DOT> net>
AuthorDate: Wed Oct 26 21:49:36 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct 26 21:49:36 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8b41c9ad

Bug #388615 - optimize FEATURES=prelink-checksums

Only spawn prelink if the file has an ELF header.

---
 pym/portage/checksum.py |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index e0bff2a..8e5abff 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -16,6 +16,21 @@ import tempfile
 hashfunc_map = {}
 hashorigin_map = {}
 
+def _open_file(filename):
+	try:
+		return open(_unicode_encode(filename,
+			encoding=_encodings['fs'], errors='strict'), 'rb')
+	except IOError as e:
+		func_call = "open('%s')" % filename
+		if e.errno == errno.EPERM:
+			raise portage.exception.OperationNotPermitted(func_call)
+		elif e.errno == errno.EACCES:
+			raise portage.exception.PermissionDenied(func_call)
+		elif e.errno == errno.ENOENT:
+			raise portage.exception.FileNotFound(filename)
+		else:
+			raise
+
 class _generate_hash_function(object):
 
 	__slots__ = ("_hashobject",)
@@ -33,19 +48,7 @@ class _generate_hash_function(object):
 		@type filename: String
 		@return: The hash and size of the data
 		"""
-		try:
-			f = open(_unicode_encode(filename,
-				encoding=_encodings['fs'], errors='strict'), 'rb')
-		except IOError as e:
-			func_call = "open('%s')" % filename
-			if e.errno == errno.EPERM:
-				raise portage.exception.OperationNotPermitted(func_call)
-			elif e.errno == errno.EACCES:
-				raise portage.exception.PermissionDenied(func_call)
-			elif e.errno == errno.ENOENT:
-				raise portage.exception.FileNotFound(filename)
-			else:
-				raise
+		f = _open_file(filename)
 		blocksize = HASHING_BLOCKSIZE
 		data = f.read(blocksize)
 		size = 0
@@ -156,6 +159,15 @@ if os.path.exists(PRELINK_BINARY):
 		prelink_capable=1
 	del results
 
+def is_prelinkable_elf(filename):
+	f = _open_file(filename)
+	try:
+		magic = f.read(17)
+	finally:
+		f.close()
+	return (len(magic) == 17 and magic.startswith(b'\x7fELF') and
+		magic[16] in (b'\x02', b'\x03')) # 2=ET_EXEC, 3=ET_DYN
+
 def perform_md5(x, calc_prelink=0):
 	return perform_checksum(x, "MD5", calc_prelink)[0]
 
@@ -263,7 +275,8 @@ def perform_checksum(filename, hashname="MD5", calc_prelink=0):
 	myfilename = filename
 	prelink_tmpfile = None
 	try:
-		if calc_prelink and prelink_capable:
+		if (calc_prelink and prelink_capable and
+		    is_prelinkable_elf(filename)):
 			# Create non-prelinked temporary file to checksum.
 			# Files rejected by prelink are summed in place.
 			try:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-28  0:54 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-28  0:54 UTC (permalink / raw
  To: gentoo-commits

commit:     db1db3b011546e99e5248cb5f292b584eba26f03
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 28 00:53:51 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Oct 28 00:53:51 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=db1db3b0

create_trees: ensure trees is _trees_dict type

---
 pym/portage/__init__.py |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 03ec286..e4abab3 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -480,15 +480,13 @@ def portageexit():
 		close_portdbapi_caches()
 
 class _trees_dict(dict):
-	def __init__(self):
-		super(dict, self).__init__()
+	def __init__(self, *pargs, **kargs):
+		dict.__init__(self, *pargs, **kargs)
 		self._running_eroot = None
 		self._target_eroot = None
 
 def create_trees(config_root=None, target_root=None, trees=None, env=None):
-	if trees is None:
-		trees = _trees_dict()
-	else:
+	if trees is not None:
 		# clean up any existing portdbapi instances
 		for myroot in trees:
 			portdb = trees[myroot]["porttree"].dbapi
@@ -496,6 +494,13 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None):
 			portdbapi.portdbapi_instances.remove(portdb)
 			del trees[myroot]["porttree"], myroot, portdb
 
+	if trees is None:
+		trees = _trees_dict()
+	elif not isinstance(trees, _trees_dict):
+		# caller passed a normal dict or something,
+		# but we need a _trees_dict instance
+		trees = _trees_dict(trees)
+
 	if env is None:
 		env = os.environ
 	eprefix = env.get("__PORTAGE_TEST_EPREFIX")



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-29  3:34 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-29  3:34 UTC (permalink / raw
  To: gentoo-commits

commit:     81e1f72cc7c749b4c46bac995e144678dea2d3fe
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 29 03:34:34 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Oct 29 03:34:34 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=81e1f72c

_trees_dict: define __slots__

---
 pym/portage/__init__.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index e4abab3..27353a1 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -480,6 +480,7 @@ def portageexit():
 		close_portdbapi_caches()
 
 class _trees_dict(dict):
+	__slots__ = ('_running_eroot', '_target_eroot',)
 	def __init__(self, *pargs, **kargs):
 		dict.__init__(self, *pargs, **kargs)
 		self._running_eroot = None



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-30  6:53 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-30  6:53 UTC (permalink / raw
  To: gentoo-commits

commit:     b2faef886620fd93c235e088ecbebe1448d5896e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 30 06:52:42 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct 30 06:53:06 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b2faef88

_legacy_globals: fix grammar in comment

---
 pym/portage/_legacy_globals.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/_legacy_globals.py b/pym/portage/_legacy_globals.py
index 072b3f7..f13e95d 100644
--- a/pym/portage/_legacy_globals.py
+++ b/pym/portage/_legacy_globals.py
@@ -42,7 +42,7 @@ def _get_legacy_global(name):
 	constructed.add('settings')
 
 	# Since portage.db now uses EROOT for keys instead of ROOT, we make
-	# portage.root refer to EROOT such that it continues works as a key.
+	# portage.root refer to EROOT such that it continues to work as a key.
 	portage.root = portage.db._target_eroot
 	constructed.add('root')
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-10-30  7:08 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-10-30  7:08 UTC (permalink / raw
  To: gentoo-commits

commit:     f6b6bdd687b252267babaa4bbfb145a18c1764e8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 30 07:08:22 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct 30 07:08:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f6b6bdd6

news.py: remove unused 'updates' variable

---
 pym/portage/news.py |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/pym/portage/news.py b/pym/portage/news.py
index 24b5107..f34fd6f 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -119,7 +119,6 @@ class NewsManager(object):
 			except PermissionDenied:
 				return
 
-			updates = []
 			for itemid in news:
 				try:
 					itemid = _unicode_decode(itemid,



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-11-13 20:33 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-11-13 20:33 UTC (permalink / raw
  To: gentoo-commits

commit:     e1a671011993a7ebb73845b3ac12fea80bfc2074
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 13 20:33:43 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Nov 13 20:33:43 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e1a67101

checksum.py: handle pycrypto breakage

---
 pym/portage/checksum.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 8e5abff..f10fc4d 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -99,10 +99,18 @@ except ImportError:
 	pass
 
 # Use pycrypto when available, prefer it over the internal fallbacks
+# Check for 'new' attributes, since they can be missing if the module
+# is broken somehow.
 try:
 	from Crypto.Hash import SHA256, RIPEMD
-	sha256hash = _generate_hash_function("SHA256", SHA256.new, origin="pycrypto")
-	rmd160hash = _generate_hash_function("RMD160", RIPEMD.new, origin="pycrypto")
+	sha256hash = getattr(SHA256, 'new', None)
+	if sha256hash is not None:
+		sha256hash = _generate_hash_function("SHA256",
+			sha256hash, origin="pycrypto")
+	rmd160hash = getattr(RIPEMD, 'new', None)
+	if rmd160hash is not None:
+		rmd160hash = _generate_hash_function("RMD160",
+			rmd160hash, origin="pycrypto")
 except ImportError:
 	pass
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-01 17:52 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-01 17:52 UTC (permalink / raw
  To: gentoo-commits

commit:     af013a2de5a2dc7069de5e95c7474556cf9208ab
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  1 17:52:23 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Dec  1 17:52:43 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=af013a2d

locks.py: use flock with PyPy for issue 747

---
 pym/portage/locks.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 9ed1d6a..9cfb87e 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -8,6 +8,7 @@ __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \
 
 import errno
 import fcntl
+import platform
 import stat
 import sys
 import time
@@ -27,6 +28,10 @@ if sys.hexversion >= 0x3000000:
 HARDLINK_FD = -2
 _default_lock_fn = fcntl.lockf
 
+if platform.python_implementation() == 'PyPy':
+	# workaround for https://bugs.pypy.org/issue747
+	_default_lock_fn = fcntl.flock
+
 # Used by emerge in order to disable the "waiting for lock" message
 # so that it doesn't interfere with the status display.
 _quiet = False



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-01 23:26 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-01 23:26 UTC (permalink / raw
  To: gentoo-commits

commit:     e7a0179ed39f707a42b8c15157bdb3f0aa45dd13
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  1 23:25:31 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Dec  1 23:25:31 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e7a0179e

checksum.py: detect PyPy crashes in hashlib

Use a fork to try and PyPy by digesting random data with hashlib
functions. It doesn't look like a bug has been reported upstream for
this yet, so it may or may not be reproducible by others. Anyway, this
allows me to avoid crashing the main PyPy process until I find a real
fix.

---
 pym/portage/checksum.py |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index f10fc4d..77035b6 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -9,6 +9,7 @@ from portage import os
 from portage import _encodings
 from portage import _unicode_encode
 import errno
+import platform
 import stat
 import tempfile
 
@@ -61,6 +62,28 @@ class _generate_hash_function(object):
 
 		return (checksum.hexdigest(), size)
 
+_test_hash_func = False
+if platform.python_implementation() == 'PyPy':
+	def _test_hash_func(constructor):
+		"""
+		Test for PyPy crashes observed with hashlib's ripemd160 and whirlpool
+		functions executed under pypy-1.7 with Python 2.7.1:
+		*** glibc detected *** pypy-c1.7: free(): invalid next size (fast): 0x0b963a38 ***
+		*** glibc detected *** pypy-c1.7: free(): corrupted unsorted chunks: 0x09c490b0 ***
+		"""
+		import random
+		pid = os.fork()
+		if pid == 0:
+			data = list(b'abcdefg')
+			for i in range(10):
+				checksum = constructor()
+				random.shuffle(data)
+				checksum.update(b''.join(data))
+				checksum.hexdigest()
+			os._exit(os.EX_OK)
+		pid, status = os.waitpid(pid, 0)
+		return os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK
+
 # Define hash functions, try to use the best module available. Later definitions
 # override earlier ones
 
@@ -129,6 +152,12 @@ try:
 		except ValueError:
 			pass
 		else:
+			if _test_hash_func and \
+				not _test_hash_func(functools.partial(hashlib.new, hash_name)):
+				portage.util.writemsg("\n!!! hash function appears to "
+					"crash python: %s from %s\n" %
+					(hash_name, "hashlib"), noiselevel=-1)
+				continue
 			globals()['%shash' % local_name] = \
 				_generate_hash_function(local_name.upper(), \
 				functools.partial(hashlib.new, hash_name), \



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-02  3:24 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-02  3:24 UTC (permalink / raw
  To: gentoo-commits

commit:     caea9ee807eba03118564030a166f9856d4439de
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Dec  2 03:24:10 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Dec  2 03:24:10 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=caea9ee8

process._exec: tweak opt_name for PyPy

PyPy 1.7 will die due to "libary path not found" if argv[0] does not
contain the full path of the binary.

---
 pym/portage/process.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 3c15370..1ee5b9a 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -343,7 +343,12 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
 	# If the process we're creating hasn't been given a name
 	# assign it the name of the executable.
 	if not opt_name:
-		opt_name = os.path.basename(binary)
+		if binary is portage._python_interpreter:
+			# NOTE: PyPy 1.7 will die due to "libary path not found" if argv[0]
+			# does not contain the full path of the binary.
+			opt_name = binary
+		else:
+			opt_name = os.path.basename(binary)
 
 	# Set up the command's argument list.
 	myargs = [opt_name]



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-08 21:16 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-08 21:16 UTC (permalink / raw
  To: gentoo-commits

commit:     9fd2fbb571fccae2e1f58daeeef348a91023cde5
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  8 21:15:55 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Dec  8 21:15:55 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9fd2fbb5

Add portage.const.EPREFIX, for prefix installs.

The EPREFIX for the current install is hardcoded here, but access to
this constant should be minimal, in favor of access via the EPREFIX
setting of a config instance (since it's possible to contruct a config
instance with a different EPREFIX).

---
 pym/portage/const.py |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 3dad36a..5eeebe1 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -140,6 +140,24 @@ MANIFEST2_HASH_DEFAULTS = frozenset(["SHA1", "SHA256", "RMD160"])
 MANIFEST2_REQUIRED_HASH  = "SHA256"
 
 MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")
+
+# The EPREFIX for the current install is hardcoded here, but access to this
+# constant should be minimal, in favor of access via the EPREFIX setting of
+# a config instance (since it's possible to contruct a config instance with
+# a different EPREFIX). Therefore, the EPREFIX constant should *NOT* be used
+# in the definition of any other contstants within this file.
+EPREFIX=""
+
+# pick up EPREFIX from the environment if set
+if "__PORTAGE_TEST_EPREFIX" in os.environ:
+	EPREFIX = os.environ["__PORTAGE_TEST_EPREFIX"]
+	if EPREFIX:
+		EPREFIX = os.path.normpath(EPREFIX)
+
+elif EPREFIX:
+	# Propagate the constant to other portage code which uses this variable.
+	os.environ["__PORTAGE_TEST_EPREFIX"] = EPREFIX
+
 # ===========================================================================
 # END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT
 # ===========================================================================



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-09 23:23 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-09 23:23 UTC (permalink / raw
  To: gentoo-commits

commit:     10689f11f50a5452dc7f2ead53aef998657a2917
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Dec  9 23:23:16 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Dec  9 23:23:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=10689f11

data.py: grp/pwd struct attrs, not indexes

---
 pym/portage/data.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/data.py b/pym/portage/data.py
index fa6970c..fe390a1 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -86,8 +86,8 @@ def _get_global(k):
 			secpass = 2
 		#Discover the uid and gid of the portage user/group
 		try:
-			portage_uid = pwd.getpwnam(_get_global('_portage_uname'))[2]
-			portage_gid = grp.getgrnam(_get_global('_portage_grpname'))[2]
+			portage_uid = pwd.getpwnam(_get_global('_portage_uname')).pw_uid
+			portage_gid = grp.getgrnam(_get_global('_portage_grpname')).gr_gid
 			if secpass < 1 and portage_gid in os.getgroups():
 				secpass = 1
 		except KeyError:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-10  5:28 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2011-12-10  5:28 UTC (permalink / raw
  To: gentoo-commits

commit:     5dfa6ccea15ae4b71756a7cb581a5a83392fc33a
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
AuthorDate: Sat Dec 10 05:26:32 2011 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
CommitDate: Sat Dec 10 05:26:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5dfa6cce

Add portage.exception.OperationNotSupported exception.

---
 pym/portage/exception.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 7891120..5ccd750 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -78,6 +78,10 @@ class OperationNotPermitted(PortageException):
 	from errno import EPERM as errno
 	"""An operation was not permitted operating system"""
 
+class OperationNotSupported(PortageException):
+	from errno import EOPNOTSUPP as errno
+	"""Operation not supported"""
+
 class PermissionDenied(PortageException):
 	from errno import EACCES as errno
 	"""Permission denied"""



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-10 19:13 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-10 19:13 UTC (permalink / raw
  To: gentoo-commits

commit:     93c60fc277e37109a4ead36f69a6a50b7f72b229
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 10 19:13:28 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 10 19:13:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=93c60fc2

get_term_size: all values >= 0 for bug #394091

---
 pym/portage/output.py |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 6b10f7b..43d7503 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -422,12 +422,14 @@ class StyleWriter(formatter.DumbWriter):
 def get_term_size():
 	"""
 	Get the number of lines and columns of the tty that is connected to
-	stdout.  Returns a tuple of (lines, columns) or (-1, -1) if an error
+	stdout.  Returns a tuple of (lines, columns) or (0, 0) if an error
 	occurs. The curses module is used if available, otherwise the output of
-	`stty size` is parsed.
+	`stty size` is parsed. The lines and columns values are guaranteed to be
+	greater than or equal to zero, since a negative COLUMNS variable is
+	known to prevent some commands from working (see bug #394091).
 	"""
 	if not sys.stdout.isatty():
-		return -1, -1
+		return (0, 0)
 	try:
 		import curses
 		try:
@@ -442,10 +444,13 @@ def get_term_size():
 		out = out.split()
 		if len(out) == 2:
 			try:
-				return int(out[0]), int(out[1])
+				val = (int(out[0]), int(out[1]))
 			except ValueError:
 				pass
-	return -1, -1
+			else:
+				if val[0] >= 0 and val[1] >= 0:
+					return val
+	return (0, 0)
 
 def set_term_size(lines, columns, fd):
 	"""



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-10 22:02 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-10 22:02 UTC (permalink / raw
  To: gentoo-commits

commit:     981cefdae6bc70c98b518b059558e295269490bf
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 10 22:01:55 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 10 22:01:55 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=981cefda

const.py: fix spelling of a comment

---
 pym/portage/const.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index a32933c..5c738e4 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -145,7 +145,7 @@ MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")
 # constant should be minimal, in favor of access via the EPREFIX setting of
 # a config instance (since it's possible to contruct a config instance with
 # a different EPREFIX). Therefore, the EPREFIX constant should *NOT* be used
-# in the definition of any other contstants within this file.
+# in the definition of any other constants within this file.
 EPREFIX=""
 
 # pick up EPREFIX from the environment if set



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-10 22:40 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-10 22:40 UTC (permalink / raw
  To: gentoo-commits

commit:     98031d249cf328a397eac507a289743d2ce719f2
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 10 22:40:21 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 10 22:40:21 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=98031d24

data.py: rename var to _portage_username

---
 pym/portage/data.py |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/pym/portage/data.py b/pym/portage/data.py
index 7c17334..f17fd73 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -1,5 +1,5 @@
 # data.py -- Calculated/Discovered Data Values
-# Copyright 1998-2010 Gentoo Foundation
+# Copyright 1998-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import os, pwd, grp, platform
@@ -86,7 +86,7 @@ def _get_global(k):
 			secpass = 2
 		#Discover the uid and gid of the portage user/group
 		try:
-			portage_uid = pwd.getpwnam(_get_global('_portage_uname')).pw_uid
+			portage_uid = pwd.getpwnam(_get_global('_portage_username')).pw_uid
 			portage_gid = grp.getgrnam(_get_global('_portage_grpname')).gr_gid
 			if secpass < 1 and portage_gid in os.getgroups():
 				secpass = 1
@@ -125,7 +125,7 @@ def _get_global(k):
 			# grp.getgrall() since it is known to trigger spurious
 			# SIGPIPE problems with nss_ldap.
 			mystatus, myoutput = \
-				portage.subprocess_getstatusoutput("id -G %s" % _portage_uname)
+				portage.subprocess_getstatusoutput("id -G %s" % _portage_username)
 			if mystatus == os.EX_OK:
 				for x in myoutput.split():
 					try:
@@ -137,7 +137,7 @@ def _get_global(k):
 	elif k == '_portage_grpname':
 		env = getattr(portage, 'settings', os.environ)
 		v = env.get('PORTAGE_GRPNAME', 'portage')
-	elif k == '_portage_uname':
+	elif k == '_portage_username':
 		env = getattr(portage, 'settings', os.environ)
 		v = env.get('PORTAGE_USERNAME', 'portage')
 	else:
@@ -159,7 +159,7 @@ class _GlobalProxy(portage.proxy.objectproxy.ObjectProxy):
 		return _get_global(object.__getattribute__(self, '_name'))
 
 for k in ('portage_gid', 'portage_uid', 'secpass', 'userpriv_groups',
-	'_portage_grpname', '_portage_uname'):
+	'_portage_grpname', '_portage_username'):
 	globals()[k] = _GlobalProxy(k)
 del k
 
@@ -170,7 +170,7 @@ def _init(settings):
 	instead of requiring them to be set in the calling environment.
 	"""
 	if '_portage_grpname' not in _initialized_globals and \
-		'_portage_uname' not in _initialized_globals:
+		'_portage_username' not in _initialized_globals:
 
 		v = settings.get('PORTAGE_GRPNAME')
 		if v is not None:
@@ -179,5 +179,5 @@ def _init(settings):
 
 		v = settings.get('PORTAGE_USERNAME')
 		if v is not None:
-			globals()['_portage_uname'] = v
-			_initialized_globals.add('_portage_uname')
+			globals()['_portage_username'] = v
+			_initialized_globals.add('_portage_username')



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-10 23:49 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-10 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     54e4ab36340f1ef3ffa250132bc5458e3d77ab6d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 10 23:49:21 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 10 23:49:21 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=54e4ab36

data.py: avoid portage.settings when possible

---
 pym/portage/data.py |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/pym/portage/data.py b/pym/portage/data.py
index f17fd73..a25b282 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -134,12 +134,24 @@ def _get_global(k):
 						pass
 				v = sorted(set(v))
 
+	# Avoid instantiating portage.settings when the desired
+	# variable is set in os.environ.
 	elif k == '_portage_grpname':
-		env = getattr(portage, 'settings', os.environ)
-		v = env.get('PORTAGE_GRPNAME', 'portage')
+		v = None
+		if 'PORTAGE_GRPNAME' in os.environ:
+			v = os.environ['PORTAGE_GRPNAME']
+		elif hasattr(portage, 'settings'):
+			v = portage.settings.get('PORTAGE_GRPNAME')
+		if v is None:
+			v = 'portage'
 	elif k == '_portage_username':
-		env = getattr(portage, 'settings', os.environ)
-		v = env.get('PORTAGE_USERNAME', 'portage')
+		v = None
+		if 'PORTAGE_USERNAME' in os.environ:
+			v = os.environ['PORTAGE_USERNAME']
+		elif hasattr(portage, 'settings'):
+			v = portage.settings.get('PORTAGE_USERNAME')
+		if v is None:
+			v = 'portage'
 	else:
 		raise AssertionError('unknown name: %s' % k)
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-11  8:15 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-11  8:15 UTC (permalink / raw
  To: gentoo-commits

commit:     0654d66ccead49eb7d5edf2df189bfe77773b89e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 11 08:15:16 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Dec 11 08:15:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0654d66c

data._init(): use 'portage' default in first call

---
 pym/portage/data.py |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/pym/portage/data.py b/pym/portage/data.py
index a25b282..cf94ab0 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -184,12 +184,10 @@ def _init(settings):
 	if '_portage_grpname' not in _initialized_globals and \
 		'_portage_username' not in _initialized_globals:
 
-		v = settings.get('PORTAGE_GRPNAME')
-		if v is not None:
-			globals()['_portage_grpname'] = v
-			_initialized_globals.add('_portage_grpname')
-
-		v = settings.get('PORTAGE_USERNAME')
-		if v is not None:
-			globals()['_portage_username'] = v
-			_initialized_globals.add('_portage_username')
+		v = settings.get('PORTAGE_GRPNAME', 'portage')
+		globals()['_portage_grpname'] = v
+		_initialized_globals.add('_portage_grpname')
+
+		v = settings.get('PORTAGE_USERNAME', 'portage')
+		globals()['_portage_username'] = v
+		_initialized_globals.add('_portage_username')



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-14  2:03 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-14  2:03 UTC (permalink / raw
  To: gentoo-commits

commit:     c11b7c487c518f9a2aceaddbe119a70877053cf5
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 02:02:23 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 02:02:23 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c11b7c48

locks.py: make hardlink lock files hidden

This is for consistency with the behavior for normal lock files, since
commit ce44ea3e914098a52bc0d1d995e71661659e77ca (bug #142369).

---
 pym/portage/locks.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 9cfb87e..41539ba 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -1,5 +1,5 @@
 # portage: Lock management code
-# Copyright 2004-2010 Gentoo Foundation
+# Copyright 2004-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \
@@ -267,7 +267,9 @@ def unlockfile(mytuple):
 
 
 def hardlock_name(path):
-	return path+".hardlock-"+os.uname()[1]+"-"+str(os.getpid())
+	base, tail = os.path.split(path)
+	return os.path.join(base, ".%s.hardlock-%s-%s" %
+		(tail, os.uname()[1], os.getpid()))
 
 def hardlink_is_mine(link,lock):
 	try:
@@ -349,7 +351,7 @@ def hardlock_cleanup(path, remove_all_locks=False):
 		if os.path.isfile(path+"/"+x):
 			parts = x.split(".hardlock-")
 			if len(parts) == 2:
-				filename = parts[0]
+				filename = parts[0][1:]
 				hostpid  = parts[1].split("-")
 				host  = "-".join(hostpid[:-1])
 				pid   = hostpid[-1]
@@ -373,7 +375,7 @@ def hardlock_cleanup(path, remove_all_locks=False):
 				 remove_all_locks:
 				for y in mylist[x]:
 					for z in mylist[x][y]:
-						filename = path+"/"+x+".hardlock-"+y+"-"+z
+						filename = path+"/."+x+".hardlock-"+y+"-"+z
 						if filename == mylockname:
 							continue
 						try:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-14  5:26 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-14  5:26 UTC (permalink / raw
  To: gentoo-commits

commit:     cdb992758a3120ff18254039c9ac9a61d1c15489
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 05:26:17 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 05:26:17 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cdb99275

hardlink_is_mine: return False, never None

---
 pym/portage/locks.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index cab0fa3..980c1c7 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -285,7 +285,8 @@ def hardlink_is_mine(link,lock):
 			return lock_st.st_ino == link_st.st_ino and \
 				lock_st.st_dev == link_st.st_dev
 	except OSError:
-		return False
+		pass
+	return False
 
 def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
 	waiting_msg=None, flags=0):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-14  6:00 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-14  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     3bcbe6b069687855fa3cc8f0e39be6c240ee3e3e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 05:59:59 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 05:59:59 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3bcbe6b0

hardlink_lockfile: optimize away most link calls

If fstat shows more than one hardlink, then it's extremely unlikely
that the following link call will result in a lock, so optimize away
the wasteful link call and sleep or raise TryAgain.

---
 pym/portage/locks.py |   71 +++++++++++++++++++++++++++++---------------------
 1 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 980c1c7..59026e9 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -337,8 +337,10 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
 			else:
 				raise
 		else:
+			myfd_st = None
 			try:
-				if os.fstat(myfd).st_gid != portage_gid:
+				myfd_st = os.fstat(myfd)
+				if myfd_st.st_gid != portage_gid:
 					os.fchown(myfd, -1, portage_gid)
 			except OSError as e:
 				if e.errno not in (errno.ENOENT, errno.ESTALE):
@@ -349,38 +351,47 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
 					writemsg(_("Group IDs of current user: %s\n") % \
 						" ".join(str(n) for n in os.getgroups()),
 						noiselevel=-1)
+				else:
+					# another process has removed the file, so we'll have
+					# to create it again
+					continue
 			finally:
 				os.close(myfd)
 
-		try:
-			os.link(lockfilename, myhardlock)
-		except OSError as e:
-			func_call = "link('%s', '%s')" % (lockfilename, myhardlock)
-			if e.errno == OperationNotPermitted.errno:
-				raise OperationNotPermitted(func_call)
-			elif e.errno == PermissionDenied.errno:
-				raise PermissionDenied(func_call)
-			elif e.errno in (errno.ESTALE, errno.ENOENT):
-				# another process has removed the file, so we'll have
-				# to create it again
-				continue
-			else:
-				raise
-
-		if hardlink_is_mine(myhardlock, lockfilename):
-			if out is not None:
-				out.eend(os.EX_OK)
-			break
-
-		try:
-			os.unlink(myhardlock)
-		except OSError as e:
-			# This should not happen, since the file name of
-			# myhardlock is unique to our host and PID,
-			# and the above link() call succeeded.
-			if e.errno not in (errno.ENOENT, errno.ESTALE):
-				raise
-			raise FileNotFound(myhardlock)
+			# If fstat shows more than one hardlink, then it's extremely
+			# unlikely that the following link call will result in a lock,
+			# so optimize away the wasteful link call and sleep or raise
+			# TryAgain.
+			if myfd_st is not None and myfd_st.st_nlink < 2:
+				try:
+					os.link(lockfilename, myhardlock)
+				except OSError as e:
+					func_call = "link('%s', '%s')" % (lockfilename, myhardlock)
+					if e.errno == OperationNotPermitted.errno:
+						raise OperationNotPermitted(func_call)
+					elif e.errno == PermissionDenied.errno:
+						raise PermissionDenied(func_call)
+					elif e.errno in (errno.ESTALE, errno.ENOENT):
+						# another process has removed the file, so we'll have
+						# to create it again
+						continue
+					else:
+						raise
+				else:
+					if hardlink_is_mine(myhardlock, lockfilename):
+						if out is not None:
+							out.eend(os.EX_OK)
+						break
+
+					try:
+						os.unlink(myhardlock)
+					except OSError as e:
+						# This should not happen, since the file name of
+						# myhardlock is unique to our host and PID,
+						# and the above link() call succeeded.
+						if e.errno not in (errno.ENOENT, errno.ESTALE):
+							raise
+						raise FileNotFound(myhardlock)
 
 		if flags & os.O_NONBLOCK:
 			raise TryAgain(lockfilename)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-14  7:33 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-14  7:33 UTC (permalink / raw
  To: gentoo-commits

commit:     29315ffe4d5c0d4030252ed25ecd81905654d534
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 07:33:28 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 07:33:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=29315ffe

lockfile: deprecate file object or fd parameters

Support for file object or integer file descriptor parameters is
deprecated due to ambiguity in whether or not it's safe to close
the file descriptor, making it prone to "Bad file descriptor" errors
or file descriptor leaks.

---
 pym/portage/locks.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 59026e9..297609c 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -51,14 +51,24 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 	if not mypath:
 		raise InvalidData(_("Empty path given"))
 
+	# Support for file object or integer file descriptor parameters is
+	# deprecated due to ambiguity in whether or not it's safe to close
+	# the file descriptor, making it prone to "Bad file descriptor" errors
+	# or file descriptor leaks.
 	if isinstance(mypath, basestring) and mypath[-1] == '/':
 		mypath = mypath[:-1]
 
 	lockfilename_path = mypath
 	if hasattr(mypath, 'fileno'):
+		warnings.warn("portage.locks.lockfile() support for "
+			"file object parameters is deprecated. Use a file path instead.",
+			DeprecationWarning, stacklevel=2)
 		lockfilename_path = getattr(mypath, 'name', None)
 		mypath = mypath.fileno()
 	if isinstance(mypath, int):
+		warnings.warn("portage.locks.lockfile() support for integer file "
+			"descriptor parameters is deprecated. Use a file path instead.",
+			DeprecationWarning, stacklevel=2)
 		lockfilename    = mypath
 		wantnewlockfile = 0
 		unlinkfile      = 0
@@ -157,7 +167,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 			if not isinstance(lockfilename, int):
 				# If a file object was passed in, it's not safe
 				# to close the file descriptor because it may
-				# still be in use (for example, see emergelog).
+				# still be in use.
 				os.close(myfd)
 			lockfilename_path = _unicode_decode(lockfilename_path,
 				encoding=_encodings['fs'], errors='strict')



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-14  9:11 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-14  9:11 UTC (permalink / raw
  To: gentoo-commits

commit:     2dbb9bb3bdb826a7da41ba1ccd89f4f8c8ee529c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 09:11:07 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 09:11:07 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2dbb9bb3

hardlink_lockfile: preserve existing permissions

---
 pym/portage/locks.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 297609c..a645e25 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -316,6 +316,7 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
 	global _quiet
 	out = None
 	displayed_waiting_msg = False
+	preexisting = os.path.exists(lockfilename)
 	myhardlock = hardlock_name(lockfilename)
 
 	# myhardlock must not exist prior to our link() call, and we can
@@ -350,8 +351,11 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
 			myfd_st = None
 			try:
 				myfd_st = os.fstat(myfd)
-				if myfd_st.st_gid != portage_gid:
-					os.fchown(myfd, -1, portage_gid)
+				if not preexisting:
+					# Don't chown the file if it is preexisting, since we
+					# want to preserve existing permissions in that case.
+					if myfd_st.st_gid != portage_gid:
+						os.fchown(myfd, -1, portage_gid)
 			except OSError as e:
 				if e.errno not in (errno.ENOENT, errno.ESTALE):
 					writemsg("%s: fchown('%s', -1, %d)\n" % \



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-14 17:54 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-14 17:54 UTC (permalink / raw
  To: gentoo-commits

commit:     85587655d47737be31415d36e8e6a0c9ff0f298f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 14 17:54:22 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 17:54:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=85587655

create_trees: pass __PORTAGE_TEST_HARDLINK_LOCKS

This allows testing of stage builds with __PORTAGE_TEST_HARDLINK_LOCKS
set in the environment, since __PORTAGE_TEST_HARDLINK_LOCKS needs to
propagate to childs processes for all ROOTs.

---
 pym/portage/__init__.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 339c64f..3495b96 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -522,7 +522,8 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None,
 		clean_env = {}
 		for k in ('PATH', 'PORTAGE_GRPNAME', 'PORTAGE_USERNAME',
 			'SSH_AGENT_PID', 'SSH_AUTH_SOCK', 'TERM',
-			'ftp_proxy', 'http_proxy', 'no_proxy'):
+			'ftp_proxy', 'http_proxy', 'no_proxy',
+			'__PORTAGE_TEST_HARDLINK_LOCKS'):
 			v = settings.get(k)
 			if v is not None:
 				clean_env[k] = v



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-14 20:14 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2011-12-14 20:14 UTC (permalink / raw
  To: gentoo-commits

commit:     d2afde1fa696d9c47c893f868606cfeb66e6c067
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
AuthorDate: Wed Dec 14 20:13:54 2011 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
CommitDate: Wed Dec 14 20:13:54 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d2afde1f

Fix a typo in a comment.

---
 pym/portage/locks.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index a645e25..9fee5ae 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -320,7 +320,7 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
 	myhardlock = hardlock_name(lockfilename)
 
 	# myhardlock must not exist prior to our link() call, and we can
-	# can safely unlink it since its file name is unique to our PID
+	# safely unlink it since its file name is unique to our PID
 	try:
 		os.unlink(myhardlock)
 	except OSError as e:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-20 23:27 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-20 23:27 UTC (permalink / raw
  To: gentoo-commits

commit:     73ae5b670836e389949d085ad394a0b9061caf13
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 20 23:26:54 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Dec 20 23:26:54 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=73ae5b67

hashed_path: implement __repr__

---
 pym/portage/eclass_cache.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py
index 1044ad0..cb2cf8a 100644
--- a/pym/portage/eclass_cache.py
+++ b/pym/portage/eclass_cache.py
@@ -49,6 +49,8 @@ class hashed_path(object):
 		setattr(self, attr, val)
 		return val
 
+	def __repr__(self):
+		return "<portage.eclass_cache.hashed_path('%s')>" % (self.location,)
 
 class cache(object):
 	"""



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-21 20:56 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2011-12-21 20:56 UTC (permalink / raw
  To: gentoo-commits

commit:     962f4d5387aa19b2a9a4cf41370000c849ff587d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 21 20:55:56 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 21 20:55:56 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=962f4d53

data.py: stat EROOT for PORTAGE_GRPNAME/USERNAME

The config class has equivalent code, but we also need to do it here if
_disable_legacy_globals() has been called.

---
 pym/portage/data.py |   48 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/pym/portage/data.py b/pym/portage/data.py
index ec750a6..c4d967a 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -141,20 +141,44 @@ def _get_global(k):
 
 	# Avoid instantiating portage.settings when the desired
 	# variable is set in os.environ.
-	elif k == '_portage_grpname':
+	elif k in ('_portage_grpname', '_portage_username'):
 		v = None
-		if 'PORTAGE_GRPNAME' in os.environ:
-			v = os.environ['PORTAGE_GRPNAME']
-		elif hasattr(portage, 'settings'):
-			v = portage.settings.get('PORTAGE_GRPNAME')
-		if v is None:
-			v = 'portage'
-	elif k == '_portage_username':
-		v = None
-		if 'PORTAGE_USERNAME' in os.environ:
-			v = os.environ['PORTAGE_USERNAME']
+		if k == '_portage_grpname':
+			env_key = 'PORTAGE_GRPNAME'
+		else:
+			env_key = 'PORTAGE_USERNAME'
+
+		if env_key in os.environ:
+			v = os.environ[env_key]
 		elif hasattr(portage, 'settings'):
-			v = portage.settings.get('PORTAGE_USERNAME')
+			v = portage.settings.get(env_key)
+		elif portage.const.EPREFIX:
+			# For prefix environments, default to the UID and GID of
+			# the top-level EROOT directory. The config class has
+			# equivalent code, but we also need to do it here if
+			# _disable_legacy_globals() has been called.
+			eroot = os.path.join(os.environ.get('ROOT', os.sep),
+				portage.const.EPREFIX.lstrip(os.sep))
+			try:
+				eroot_st = os.stat(eroot)
+			except OSError:
+				pass
+			else:
+				if k == '_portage_grpname':
+					try:
+						grp_struct = grp.getgrgid(eroot_st.st_gid)
+					except KeyError:
+						pass
+					else:
+						v = grp_struct.gr_name
+				else:
+					try:
+						pwd_struct = pwd.getpwuid(eroot_st.st_uid)
+					except KeyError:
+						pass
+					else:
+						v = pwd_struct.pw_name
+
 		if v is None:
 			v = 'portage'
 	else:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2011-12-24  1:29 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2011-12-24  1:29 UTC (permalink / raw
  To: gentoo-commits

commit:     27905e596eeba6e76370561e63f3184d5a8d7a26
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
AuthorDate: Sat Dec 24 01:28:50 2011 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
CommitDate: Sat Dec 24 01:28:50 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=27905e59

Fix a typo in a doc string.

---
 pym/portage/xpak.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py
index f95ade9..b507243 100644
--- a/pym/portage/xpak.py
+++ b/pym/portage/xpak.py
@@ -112,7 +112,7 @@ def xpak(rootdir,outfile=None):
 		return xpak_segment
 
 def xpak_mem(mydata):
-	"""Create an xpack segement from a map object."""
+	"""Create an xpack segment from a map object."""
 
 	mydata_encoded = {}
 	for k, v in mydata.items():



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-01-11  3:59 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2012-01-11  3:59 UTC (permalink / raw
  To: gentoo-commits

commit:     93db7e12b01cde9f29cc404a9ca8886143f3e988
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
AuthorDate: Wed Jan 11 03:57:23 2012 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
CommitDate: Wed Jan 11 03:57:23 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=93db7e12

portage.debug.trace_handler.__init__(): Fix compatibility with Python 3.

---
 pym/portage/debug.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/debug.py b/pym/portage/debug.py
index ce642fe..ebf1a13 100644
--- a/pym/portage/debug.py
+++ b/pym/portage/debug.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import os
@@ -26,7 +26,7 @@ class trace_handler(object):
 	def __init__(self):
 		python_system_paths = []
 		for x in sys.path:
-			if os.path.basename(x).startswith("python2."):
+			if os.path.basename(x) == "python%s.%s" % sys.version_info[:2]:
 				python_system_paths.append(x)
 
 		self.ignore_prefixes = []



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-02-06 17:20 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-02-06 17:20 UTC (permalink / raw
  To: gentoo-commits

commit:     6a94a074aa0475173a51f3f726377d4c407e986b
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Feb  6 17:20:05 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb  6 17:20:05 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6a94a074

spawn: assert that fork returns int type

---
 pym/portage/process.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 1ee5b9a..47b0a21 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -244,7 +244,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 
 	pid = os.fork()
 
-	if not pid:
+	if pid == 0:
 		try:
 			_exec(binary, mycommand, opt_name, fd_pipes,
 			      env, gid, groups, uid, umask, pre_exec)
@@ -259,6 +259,9 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 			sys.stderr.flush()
 			os._exit(1)
 
+	if not isinstance(pid, int):
+		raise AssertionError("fork returned non-integer: %s" % (repr(pid),))
+
 	# Add the pid to our local and the global pid lists.
 	mypids.append(pid)
 	spawned_pids.append(pid)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-02-12  3:39 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-02-12  3:39 UTC (permalink / raw
  To: gentoo-commits

commit:     b3cfb2065ccbeb8f769d630ff997c0327fb2eb35
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 12 03:39:10 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Feb 12 03:39:10 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b3cfb206

xpak.unpackinfo: validate paths, bug #403149

---
 pym/portage/xpak.py |   44 ++++++++++++++++++++------------------------
 1 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py
index b507243..db2a2bc 100644
--- a/pym/portage/xpak.py
+++ b/pym/portage/xpak.py
@@ -1,4 +1,4 @@
-# Copyright 2001-2011 Gentoo Foundation
+# Copyright 2001-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 
@@ -246,16 +246,9 @@ def getitem(myid,myitem):
 	return mydata[myloc[0]:myloc[0]+myloc[1]]
 
 def xpand(myid,mydest):
+	mydest = normalize_path(mydest) + os.sep
 	myindex=myid[0]
 	mydata=myid[1]
-	try:
-		origdir=os.getcwd()
-	except SystemExit as e:
-		raise
-	except:
-		os.chdir("/")
-		origdir="/"
-	os.chdir(mydest)
 	myindexlen=len(myindex)
 	startpos=0
 	while ((startpos+8)<myindexlen):
@@ -263,16 +256,22 @@ def xpand(myid,mydest):
 		datapos=decodeint(myindex[startpos+4+namelen:startpos+8+namelen]);
 		datalen=decodeint(myindex[startpos+8+namelen:startpos+12+namelen]);
 		myname=myindex[startpos+4:startpos+4+namelen]
-		dirname=os.path.dirname(myname)
+		myname = _unicode_decode(myname,
+			encoding=_encodings['repo.content'], errors='replace')
+		filename = os.path.join(mydest, myname.lstrip(os.sep))
+		filename = normalize_path(filename)
+		if not filename.startswith(mydest):
+			# myname contains invalid ../ component(s)
+			continue
+		dirname = os.path.dirname(filename)
 		if dirname:
 			if not os.path.exists(dirname):
 				os.makedirs(dirname)
-		mydat = open(_unicode_encode(myname,
+		mydat = open(_unicode_encode(filename,
 			encoding=_encodings['fs'], errors='strict'), 'wb')
 		mydat.write(mydata[datapos:datapos+datalen])
 		mydat.close()
 		startpos=startpos+namelen+12
-	os.chdir(origdir)
 
 class tbz2(object):
 	def __init__(self,myfile):
@@ -398,7 +397,7 @@ class tbz2(object):
 			self.datapos=a.tell()
 			a.close()
 			return 2
-		except SystemExit as e:
+		except SystemExit:
 			raise
 		except:
 			return 0
@@ -434,18 +433,11 @@ class tbz2(object):
 		"""Unpacks all the files from the dataSegment into 'mydest'."""
 		if not self.scan():
 			return 0
-		try:
-			origdir=os.getcwd()
-		except SystemExit as e:
-			raise
-		except:
-			os.chdir("/")
-			origdir="/"
+		mydest = normalize_path(mydest) + os.sep
 		a = open(_unicode_encode(self.file,
 			encoding=_encodings['fs'], errors='strict'), 'rb')
 		if not os.path.exists(mydest):
 			os.makedirs(mydest)
-		os.chdir(mydest)
 		startpos=0
 		while ((startpos+8)<self.indexsize):
 			namelen=decodeint(self.index[startpos:startpos+4])
@@ -454,18 +446,22 @@ class tbz2(object):
 			myname=self.index[startpos+4:startpos+4+namelen]
 			myname = _unicode_decode(myname,
 				encoding=_encodings['repo.content'], errors='replace')
-			dirname=os.path.dirname(myname)
+			filename = os.path.join(mydest, myname.lstrip(os.sep))
+			filename = normalize_path(filename)
+			if not filename.startswith(mydest):
+				# myname contains invalid ../ component(s)
+				continue
+			dirname = os.path.dirname(filename)
 			if dirname:
 				if not os.path.exists(dirname):
 					os.makedirs(dirname)
-			mydat = open(_unicode_encode(myname,
+			mydat = open(_unicode_encode(filename,
 				encoding=_encodings['fs'], errors='strict'), 'wb')
 			a.seek(self.datapos+datapos)
 			mydat.write(a.read(datalen))
 			mydat.close()
 			startpos=startpos+namelen+12
 		a.close()
-		os.chdir(origdir)
 		return 1
 
 	def get_data(self):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-02-13 21:58 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-02-13 21:58 UTC (permalink / raw
  To: gentoo-commits

commit:     36883148297f4ff96c404ab23d75739dd21de31c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 13 21:57:31 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb 13 21:57:31 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=36883148

checksum.py: remove PyPy 1.7 workarounds

The corresponding hashlib issues are fixed in PyPy 1.8:

	https://bugs.pypy.org/issue957

---
 pym/portage/checksum.py |   31 +------------------------------
 1 files changed, 1 insertions(+), 30 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 77035b6..73e01b5 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -1,5 +1,5 @@
 # checksum.py -- core Portage functionality
-# Copyright 1998-2011 Gentoo Foundation
+# Copyright 1998-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import portage
@@ -9,7 +9,6 @@ from portage import os
 from portage import _encodings
 from portage import _unicode_encode
 import errno
-import platform
 import stat
 import tempfile
 
@@ -62,28 +61,6 @@ class _generate_hash_function(object):
 
 		return (checksum.hexdigest(), size)
 
-_test_hash_func = False
-if platform.python_implementation() == 'PyPy':
-	def _test_hash_func(constructor):
-		"""
-		Test for PyPy crashes observed with hashlib's ripemd160 and whirlpool
-		functions executed under pypy-1.7 with Python 2.7.1:
-		*** glibc detected *** pypy-c1.7: free(): invalid next size (fast): 0x0b963a38 ***
-		*** glibc detected *** pypy-c1.7: free(): corrupted unsorted chunks: 0x09c490b0 ***
-		"""
-		import random
-		pid = os.fork()
-		if pid == 0:
-			data = list(b'abcdefg')
-			for i in range(10):
-				checksum = constructor()
-				random.shuffle(data)
-				checksum.update(b''.join(data))
-				checksum.hexdigest()
-			os._exit(os.EX_OK)
-		pid, status = os.waitpid(pid, 0)
-		return os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK
-
 # Define hash functions, try to use the best module available. Later definitions
 # override earlier ones
 
@@ -152,12 +129,6 @@ try:
 		except ValueError:
 			pass
 		else:
-			if _test_hash_func and \
-				not _test_hash_func(functools.partial(hashlib.new, hash_name)):
-				portage.util.writemsg("\n!!! hash function appears to "
-					"crash python: %s from %s\n" %
-					(hash_name, "hashlib"), noiselevel=-1)
-				continue
 			globals()['%shash' % local_name] = \
 				_generate_hash_function(local_name.upper(), \
 				functools.partial(hashlib.new, hash_name), \



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-02-15  9:32 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-02-15  9:32 UTC (permalink / raw
  To: gentoo-commits

commit:     a979c180b5c8ce98231d7e3c20f2d38d272f7b45
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 15 09:32:40 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Feb 15 09:32:40 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a979c180

get_open_fds: handle EAGAIN for PyPy 1.8

---
 pym/portage/process.py |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index e7313ab..febaf66 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -1,9 +1,11 @@
 # portage.py -- core Portage functionality
-# Copyright 1998-2010 Gentoo Foundation
+# Copyright 1998-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 
 import atexit
+import errno
+import platform
 import signal
 import sys
 import traceback
@@ -32,6 +34,18 @@ if os.path.isdir("/proc/%i/fd" % os.getpid()):
 	def get_open_fds():
 		return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) \
 			if fd.isdigit())
+
+	if platform.python_implementation() == 'PyPy':
+		# EAGAIN observed with PyPy 1.8.
+		_get_open_fds = get_open_fds
+		def get_open_fds():
+			try:
+				return _get_open_fds()
+			except OSError as e:
+				if e.errno != errno.EAGAIN:
+					raise
+				return range(max_fd_limit)
+
 else:
 	def get_open_fds():
 		return range(max_fd_limit)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-02-16 19:44 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2012-02-16 19:44 UTC (permalink / raw
  To: gentoo-commits

commit:     dec82cb8c449e833e4b9934d56927c2ba682b0d9
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Thu Feb 16 19:43:00 2012 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Thu Feb 16 19:43:00 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=dec82cb8

portage.update.fixdbentries(): Fix ResourceWarnings with Python 3.2.

---
 pym/portage/update.py |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/pym/portage/update.py b/pym/portage/update.py
index 6d13dfc..34e4663 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -86,10 +86,11 @@ def fixdbentries(update_iter, dbdir):
 	mydata = {}
 	for myfile in [f for f in os.listdir(dbdir) if f not in ignored_dbentries]:
 		file_path = os.path.join(dbdir, myfile)
-		mydata[myfile] = io.open(_unicode_encode(file_path,
+		with io.open(_unicode_encode(file_path,
 			encoding=_encodings['fs'], errors='strict'),
 			mode='r', encoding=_encodings['repo.content'],
-			errors='replace').read()
+			errors='replace') as f:
+			mydata[myfile] = f.read()
 	updated_items = update_dbentries(update_iter, mydata)
 	for myfile, mycontent in updated_items.items():
 		file_path = os.path.join(dbdir, myfile)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-02-28  4:58 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-02-28  4:58 UTC (permalink / raw
  To: gentoo-commits

commit:     ef4fc7d5347e96e085c11d8843cceae1f433fe24
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 28 04:57:35 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Feb 28 04:57:35 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ef4fc7d5

cvstree.getentries: handle "ignored" files in cvs

It's possible for files to be under version control even though they
match our ignore filter, so don't ignore them if they are listed in the
"Entries" file. Thanks to Mike Gilbert <floppym <AT> gentoo.org> for
reporting in this blog post:

http://floppym.blogspot.com/2012/02/cvs-status-display-cvs-checkout-in-svn.html

---
 pym/portage/cvstree.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/pym/portage/cvstree.py b/pym/portage/cvstree.py
index 9ba22f3..3680ae4 100644
--- a/pym/portage/cvstree.py
+++ b/pym/portage/cvstree.py
@@ -248,11 +248,13 @@ def getentries(mydir,recursive=0):
 			if entries["files"][mysplit[1]]["revision"][0]=="-":
 				entries["files"][mysplit[1]]["status"]+=["removed"]
 
-	for file in apply_cvsignore_filter(os.listdir(mydir)):
+	for file in os.listdir(mydir):
 		if file=="CVS":
 			continue
 		if os.path.isdir(mydir+"/"+file):
 			if file not in entries["dirs"]:
+				if ignore_list.match(file) is not None:
+					continue
 				entries["dirs"][file]={"dirs":{},"files":{}}
 				# It's normal for a directory to be unlisted in Entries
 				# when checked out without -P (see bug #257660).
@@ -266,6 +268,8 @@ def getentries(mydir,recursive=0):
 				entries["dirs"][file]["status"]=["exists"]
 		elif os.path.isfile(mydir+"/"+file):
 			if file not in entries["files"]:
+				if ignore_list.match(file) is not None:
+					continue
 				entries["files"][file]={"revision":"","date":"","flags":"","tags":""}
 			if "status" in entries["files"][file]:
 				if "exists" not in entries["files"][file]["status"]:
@@ -285,7 +289,9 @@ def getentries(mydir,recursive=0):
 				print("failed to stat",file)
 				print(e)
 				return
-				
+
+		elif ignore_list.match(file) is not None:
+			pass
 		else:
 			print()
 			print("File of unknown type:",mydir+"/"+file)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-03-18 17:07 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-03-18 17:07 UTC (permalink / raw
  To: gentoo-commits

commit:     f1fb411525e7429e4f361ad3d352a9154c0e44b6
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 18 17:07:09 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Mar 18 17:07:09 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f1fb4115

dispatch_conf: fix broken diffstatusoutput_len

---
 pym/portage/dispatch_conf.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index 6e8de0f..3d53f64 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -138,7 +138,7 @@ def file_archive(archive, curconf, newconf, mrgconf):
 
     # Archive the current config file if it isn't already saved
     if os.path.exists(archive) \
-     and diffstatusoutput_len("diff -aq '%s' '%s'" % (curconf,archive))[1] != 0:
+     and len(diffstatusoutput("diff -aq '%s' '%s'", curconf, archive)[1]) != 0:
         suf = 1
         while suf < 9 and os.path.exists(archive + '.' + str(suf)):
             suf += 1



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-03-28  0:36 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-03-28  0:36 UTC (permalink / raw
  To: gentoo-commits

commit:     0fc7ed733f41e71a0a7fb6e886f6e6a8ec5056cc
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 28 00:35:59 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Mar 28 00:35:59 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0fc7ed73

locks.py: fix _close_fds docstring

---
 pym/portage/locks.py |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 87fbe07..59fbc6e 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -45,7 +45,6 @@ def _close_fds():
 	descriptors for locks held by the parent process. This can be called
 	safely after a fork without exec, unlike the _setup_pipes close_fds
 	behavior.
-	.
 	"""
 	while _open_fds:
 		os.close(_open_fds.pop())



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-03-29  3:35 Mike Frysinger
  0 siblings, 0 replies; 248+ messages in thread
From: Mike Frysinger @ 2012-03-29  3:35 UTC (permalink / raw
  To: gentoo-commits

commit:     b8a5d5d288b6d4138ee81f4c24692bdcb5c2c189
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 27 20:38:18 2012 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Mar 29 03:32:40 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b8a5d5d2

xpak: clean up style

A few spaces here and there go a long way to making this readable.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 pym/portage/xpak.py |  247 +++++++++++++++++++++++++--------------------------
 1 files changed, 123 insertions(+), 124 deletions(-)

diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py
index db2a2bc..8689737 100644
--- a/pym/portage/xpak.py
+++ b/pym/portage/xpak.py
@@ -62,12 +62,12 @@ def encodeint(myint):
 	"""Takes a 4 byte integer and converts it into a string of 4 characters.
 	Returns the characters in a string."""
 	a = array.array('B')
-	a.append((myint >> 24 ) & 0xff)
-	a.append((myint >> 16 ) & 0xff)
-	a.append((myint >> 8 ) & 0xff)
+	a.append((myint >> 24) & 0xff)
+	a.append((myint >> 16) & 0xff)
+	a.append((myint >>  8) & 0xff)
 	a.append(myint & 0xff)
 	try:
-		# Python >=3.2
+		# Python >= 3.2
 		return a.tobytes()
 	except AttributeError:
 		return a.tostring()
@@ -84,12 +84,12 @@ def decodeint(mystring):
 	myint += mystring[0] << 24
 	return myint
 
-def xpak(rootdir,outfile=None):
-	"""(rootdir,outfile) -- creates an xpak segment of the directory 'rootdir'
+def xpak(rootdir, outfile=None):
+	"""(rootdir, outfile) -- creates an xpak segment of the directory 'rootdir'
 	and under the name 'outfile' if it is specified. Otherwise it returns the
 	xpak segment."""
 
-	mylist=[]
+	mylist = []
 
 	addtolist(mylist, rootdir)
 	mylist.sort()
@@ -125,21 +125,21 @@ def xpak_mem(mydata):
 	del mydata_encoded
 
 	indexglob = b''
-	indexpos=0
+	indexpos = 0
 	dataglob = b''
-	datapos=0
+	datapos = 0
 	for x, newglob in mydata.items():
-		mydatasize=len(newglob)
-		indexglob=indexglob+encodeint(len(x))+x+encodeint(datapos)+encodeint(mydatasize)
-		indexpos=indexpos+4+len(x)+4+4
-		dataglob=dataglob+newglob
-		datapos=datapos+mydatasize
+		mydatasize = len(newglob)
+		indexglob = indexglob + encodeint(len(x)) + x + encodeint(datapos) + encodeint(mydatasize)
+		indexpos = indexpos + 4 + len(x) + 4 + 4
+		dataglob = dataglob + newglob
+		datapos = datapos + mydatasize
 	return b'XPAKPACK' \
-	+ encodeint(len(indexglob)) \
-	+ encodeint(len(dataglob)) \
-	+ indexglob \
-	+ dataglob \
-	+ b'XPAKSTOP'
+		+ encodeint(len(indexglob)) \
+		+ encodeint(len(dataglob)) \
+		+ indexglob \
+		+ dataglob \
+		+ b'XPAKSTOP'
 
 def xsplit(infile):
 	"""(infile) -- Splits the infile into two files.
@@ -149,7 +149,7 @@ def xsplit(infile):
 		encoding=_encodings['fs'], errors='strict')
 	myfile = open(_unicode_encode(infile,
 		encoding=_encodings['fs'], errors='strict'), 'rb')
-	mydat=myfile.read()
+	mydat = myfile.read()
 	myfile.close()
 	
 	splits = xsplit_mem(mydat)
@@ -171,35 +171,35 @@ def xsplit_mem(mydat):
 		return None
 	if mydat[-8:] != b'XPAKSTOP':
 		return None
-	indexsize=decodeint(mydat[8:12])
-	return (mydat[16:indexsize+16], mydat[indexsize+16:-8])
+	indexsize = decodeint(mydat[8:12])
+	return (mydat[16:indexsize + 16], mydat[indexsize + 16:-8])
 
 def getindex(infile):
 	"""(infile) -- grabs the index segment from the infile and returns it."""
 	myfile = open(_unicode_encode(infile,
 		encoding=_encodings['fs'], errors='strict'), 'rb')
-	myheader=myfile.read(16)
+	myheader = myfile.read(16)
 	if myheader[0:8] != b'XPAKPACK':
 		myfile.close()
 		return
-	indexsize=decodeint(myheader[8:12])
-	myindex=myfile.read(indexsize)
+	indexsize = decodeint(myheader[8:12])
+	myindex = myfile.read(indexsize)
 	myfile.close()
 	return myindex
 
 def getboth(infile):
 	"""(infile) -- grabs the index and data segments from the infile.
-	Returns an array [indexSegment,dataSegment]"""
+	Returns an array [indexSegment, dataSegment]"""
 	myfile = open(_unicode_encode(infile,
 		encoding=_encodings['fs'], errors='strict'), 'rb')
-	myheader=myfile.read(16)
+	myheader = myfile.read(16)
 	if myheader[0:8] != b'XPAKPACK':
 		myfile.close()
 		return
-	indexsize=decodeint(myheader[8:12])
-	datasize=decodeint(myheader[12:16])
-	myindex=myfile.read(indexsize)
-	mydata=myfile.read(datasize)
+	indexsize = decodeint(myheader[8:12])
+	datasize = decodeint(myheader[12:16])
+	myindex = myfile.read(indexsize)
+	mydata = myfile.read(datasize)
 	myfile.close()
 	return myindex, mydata
 
@@ -210,52 +210,52 @@ def listindex(myindex):
 
 def getindex_mem(myindex):
 	"""Returns the filenames listed in the indexglob passed in."""
-	myindexlen=len(myindex)
-	startpos=0
-	myret=[]
-	while ((startpos+8)<myindexlen):
-		mytestlen=decodeint(myindex[startpos:startpos+4])
-		myret=myret+[myindex[startpos+4:startpos+4+mytestlen]]
-		startpos=startpos+mytestlen+12
+	myindexlen = len(myindex)
+	startpos = 0
+	myret = []
+	while ((startpos + 8) < myindexlen):
+		mytestlen = decodeint(myindex[startpos:startpos + 4])
+		myret = myret + [myindex[startpos + 4:startpos + 4 + mytestlen]]
+		startpos = startpos + mytestlen + 12
 	return myret
 
-def searchindex(myindex,myitem):
-	"""(index,item) -- Finds the offset and length of the file 'item' in the
+def searchindex(myindex, myitem):
+	"""(index, item) -- Finds the offset and length of the file 'item' in the
 	datasegment via the index 'index' provided."""
 	myitem = _unicode_encode(myitem,
 		encoding=_encodings['repo.content'], errors='backslashreplace')
-	mylen=len(myitem)
-	myindexlen=len(myindex)
-	startpos=0
-	while ((startpos+8)<myindexlen):
-		mytestlen=decodeint(myindex[startpos:startpos+4])
-		if mytestlen==mylen:
-			if myitem==myindex[startpos+4:startpos+4+mytestlen]:
+	mylen = len(myitem)
+	myindexlen = len(myindex)
+	startpos = 0
+	while ((startpos + 8) < myindexlen):
+		mytestlen = decodeint(myindex[startpos:startpos + 4])
+		if mytestlen == mylen:
+			if myitem == myindex[startpos + 4:startpos + 4 + mytestlen]:
 				#found
-				datapos=decodeint(myindex[startpos+4+mytestlen:startpos+8+mytestlen]);
-				datalen=decodeint(myindex[startpos+8+mytestlen:startpos+12+mytestlen]);
+				datapos = decodeint(myindex[startpos + 4 + mytestlen:startpos + 8 + mytestlen])
+				datalen = decodeint(myindex[startpos + 8 + mytestlen:startpos + 12 + mytestlen])
 				return datapos, datalen
-		startpos=startpos+mytestlen+12
+		startpos = startpos + mytestlen + 12
 		
-def getitem(myid,myitem):
-	myindex=myid[0]
-	mydata=myid[1]
-	myloc=searchindex(myindex,myitem)
+def getitem(myid, myitem):
+	myindex = myid[0]
+	mydata = myid[1]
+	myloc = searchindex(myindex, myitem)
 	if not myloc:
 		return None
-	return mydata[myloc[0]:myloc[0]+myloc[1]]
+	return mydata[myloc[0]:myloc[0] + myloc[1]]
 
-def xpand(myid,mydest):
+def xpand(myid, mydest):
 	mydest = normalize_path(mydest) + os.sep
-	myindex=myid[0]
-	mydata=myid[1]
-	myindexlen=len(myindex)
-	startpos=0
-	while ((startpos+8)<myindexlen):
-		namelen=decodeint(myindex[startpos:startpos+4])
-		datapos=decodeint(myindex[startpos+4+namelen:startpos+8+namelen]);
-		datalen=decodeint(myindex[startpos+8+namelen:startpos+12+namelen]);
-		myname=myindex[startpos+4:startpos+4+namelen]
+	myindex = myid[0]
+	mydata = myid[1]
+	myindexlen = len(myindex)
+	startpos = 0
+	while ((startpos + 8) < myindexlen):
+		namelen = decodeint(myindex[startpos:startpos + 4])
+		datapos = decodeint(myindex[startpos + 4 + namelen:startpos + 8 + namelen])
+		datalen = decodeint(myindex[startpos + 8 + namelen:startpos + 12 + namelen])
+		myname = myindex[startpos + 4:startpos + 4 + namelen]
 		myname = _unicode_decode(myname,
 			encoding=_encodings['repo.content'], errors='replace')
 		filename = os.path.join(mydest, myname.lstrip(os.sep))
@@ -269,23 +269,23 @@ def xpand(myid,mydest):
 				os.makedirs(dirname)
 		mydat = open(_unicode_encode(filename,
 			encoding=_encodings['fs'], errors='strict'), 'wb')
-		mydat.write(mydata[datapos:datapos+datalen])
+		mydat.write(mydata[datapos:datapos + datalen])
 		mydat.close()
-		startpos=startpos+namelen+12
+		startpos = startpos + namelen + 12
 
 class tbz2(object):
-	def __init__(self,myfile):
-		self.file=myfile
-		self.filestat=None
+	def __init__(self, myfile):
+		self.file = myfile
+		self.filestat = None
 		self.index = b''
-		self.infosize=0
-		self.xpaksize=0
-		self.indexsize=None
-		self.datasize=None
-		self.indexpos=None
-		self.datapos=None
-
-	def decompose(self,datadir,cleanup=1):
+		self.infosize = 0
+		self.xpaksize = 0
+		self.indexsize = None
+		self.datasize = None
+		self.indexpos = None
+		self.datapos = None
+
+	def decompose(self, datadir, cleanup=1):
 		"""Alias for unpackinfo() --- Complement to recompose() but optionally
 		deletes the destination directory. Extracts the xpak from the tbz2 into
 		the directory provided. Raises IOError if scan() fails.
@@ -297,9 +297,9 @@ class tbz2(object):
 		if not os.path.exists(datadir):
 			os.makedirs(datadir)
 		return self.unpackinfo(datadir)
-	def compose(self,datadir,cleanup=0):
+	def compose(self, datadir, cleanup=0):
 		"""Alias for recompose()."""
-		return self.recompose(datadir,cleanup)
+		return self.recompose(datadir, cleanup)
 
 	def recompose(self, datadir, cleanup=0, break_hardlinks=True):
 		"""Creates an xpak segment from the datadir provided, truncates the tbz2
@@ -337,9 +337,9 @@ class tbz2(object):
 			encoding=_encodings['fs'], errors='strict'), 'ab+')
 		if not myfile:
 			raise IOError
-		myfile.seek(-self.xpaksize,2) # 0,2 or -0,2 just mean EOF.
+		myfile.seek(-self.xpaksize, 2) # 0,2 or -0,2 just mean EOF.
 		myfile.truncate()
-		myfile.write(xpdata+encodeint(len(xpdata)) + b'STOP')
+		myfile.write(xpdata + encodeint(len(xpdata)) + b'STOP')
 		myfile.flush()
 		myfile.close()
 		return 1
@@ -361,40 +361,40 @@ class tbz2(object):
 		"""Scans the tbz2 to locate the xpak segment and setup internal values.
 		This function is called by relevant functions already."""
 		try:
-			mystat=os.stat(self.file)
+			mystat = os.stat(self.file)
 			if self.filestat:
-				changed=0
+				changed = 0
 				if mystat.st_size != self.filestat.st_size \
 					or mystat.st_mtime != self.filestat.st_mtime \
 					or mystat.st_ctime != self.filestat.st_ctime:
 					changed = True
 				if not changed:
 					return 1
-			self.filestat=mystat
+			self.filestat = mystat
 			a = open(_unicode_encode(self.file,
 				encoding=_encodings['fs'], errors='strict'), 'rb')
-			a.seek(-16,2)
-			trailer=a.read()
-			self.infosize=0
-			self.xpaksize=0
+			a.seek(-16, 2)
+			trailer = a.read()
+			self.infosize = 0
+			self.xpaksize = 0
 			if trailer[-4:] != b'STOP':
 				a.close()
 				return 0
 			if trailer[0:8] != b'XPAKSTOP':
 				a.close()
 				return 0
-			self.infosize=decodeint(trailer[8:12])
-			self.xpaksize=self.infosize+8
-			a.seek(-(self.xpaksize),2)
-			header=a.read(16)
+			self.infosize = decodeint(trailer[8:12])
+			self.xpaksize = self.infosize + 8
+			a.seek(-(self.xpaksize), 2)
+			header = a.read(16)
 			if header[0:8] != b'XPAKPACK':
 				a.close()
 				return 0
-			self.indexsize=decodeint(header[8:12])
-			self.datasize=decodeint(header[12:16])
-			self.indexpos=a.tell()
-			self.index=a.read(self.indexsize)
-			self.datapos=a.tell()
+			self.indexsize = decodeint(header[8:12])
+			self.datasize = decodeint(header[12:16])
+			self.indexpos = a.tell()
+			self.index = a.read(self.indexsize)
+			self.datapos = a.tell()
 			a.close()
 			return 2
 		except SystemExit:
@@ -408,28 +408,28 @@ class tbz2(object):
 			return None
 		return getindex_mem(self.index)
 
-	def getfile(self,myfile,mydefault=None):
+	def getfile(self, myfile, mydefault=None):
 		"""Finds 'myfile' in the data segment and returns it."""
 		if not self.scan():
 			return None
-		myresult=searchindex(self.index,myfile)
+		myresult = searchindex(self.index, myfile)
 		if not myresult:
 			return mydefault
 		a = open(_unicode_encode(self.file,
 			encoding=_encodings['fs'], errors='strict'), 'rb')
-		a.seek(self.datapos+myresult[0],0)
-		myreturn=a.read(myresult[1])
+		a.seek(self.datapos + myresult[0], 0)
+		myreturn = a.read(myresult[1])
 		a.close()
 		return myreturn
 
-	def getelements(self,myfile):
+	def getelements(self, myfile):
 		"""A split/array representation of tbz2.getfile()"""
-		mydat=self.getfile(myfile)
+		mydat = self.getfile(myfile)
 		if not mydat:
 			return []
 		return mydat.split()
 
-	def unpackinfo(self,mydest):
+	def unpackinfo(self, mydest):
 		"""Unpacks all the files from the dataSegment into 'mydest'."""
 		if not self.scan():
 			return 0
@@ -438,12 +438,12 @@ class tbz2(object):
 			encoding=_encodings['fs'], errors='strict'), 'rb')
 		if not os.path.exists(mydest):
 			os.makedirs(mydest)
-		startpos=0
-		while ((startpos+8)<self.indexsize):
-			namelen=decodeint(self.index[startpos:startpos+4])
-			datapos=decodeint(self.index[startpos+4+namelen:startpos+8+namelen]);
-			datalen=decodeint(self.index[startpos+8+namelen:startpos+12+namelen]);
-			myname=self.index[startpos+4:startpos+4+namelen]
+		startpos = 0
+		while ((startpos + 8) < self.indexsize):
+			namelen = decodeint(self.index[startpos:startpos + 4])
+			datapos = decodeint(self.index[startpos + 4 + namelen:startpos + 8 + namelen])
+			datalen = decodeint(self.index[startpos + 8 + namelen:startpos + 12 + namelen])
+			myname = self.index[startpos + 4:startpos + 4 + namelen]
 			myname = _unicode_decode(myname,
 				encoding=_encodings['repo.content'], errors='replace')
 			filename = os.path.join(mydest, myname.lstrip(os.sep))
@@ -457,10 +457,10 @@ class tbz2(object):
 					os.makedirs(dirname)
 			mydat = open(_unicode_encode(filename,
 				encoding=_encodings['fs'], errors='strict'), 'wb')
-			a.seek(self.datapos+datapos)
+			a.seek(self.datapos + datapos)
 			mydat.write(a.read(datalen))
 			mydat.close()
-			startpos=startpos+namelen+12
+			startpos = startpos + namelen + 12
 		a.close()
 		return 1
 
@@ -471,28 +471,27 @@ class tbz2(object):
 		a = open(_unicode_encode(self.file,
 			encoding=_encodings['fs'], errors='strict'), 'rb')
 		mydata = {}
-		startpos=0
-		while ((startpos+8)<self.indexsize):
-			namelen=decodeint(self.index[startpos:startpos+4])
-			datapos=decodeint(self.index[startpos+4+namelen:startpos+8+namelen]);
-			datalen=decodeint(self.index[startpos+8+namelen:startpos+12+namelen]);
-			myname=self.index[startpos+4:startpos+4+namelen]
-			a.seek(self.datapos+datapos)
+		startpos = 0
+		while ((startpos + 8) < self.indexsize):
+			namelen = decodeint(self.index[startpos:startpos + 4])
+			datapos = decodeint(self.index[startpos + 4 + namelen:startpos + 8 + namelen])
+			datalen = decodeint(self.index[startpos + 8 + namelen:startpos + 12 + namelen])
+			myname = self.index[startpos + 4:startpos + 4 + namelen]
+			a.seek(self.datapos + datapos)
 			mydata[myname] = a.read(datalen)
-			startpos=startpos+namelen+12
+			startpos = startpos + namelen + 12
 		a.close()
 		return mydata
 
 	def getboth(self):
-		"""Returns an array [indexSegment,dataSegment]"""
+		"""Returns an array [indexSegment, dataSegment]"""
 		if not self.scan():
 			return None
 
 		a = open(_unicode_encode(self.file,
 			encoding=_encodings['fs'], errors='strict'), 'rb')
 		a.seek(self.datapos)
-		mydata =a.read(self.datasize)
+		mydata = a.read(self.datasize)
 		a.close()
 
 		return self.index, mydata
-



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-03-31 17:22 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-03-31 17:22 UTC (permalink / raw
  To: gentoo-commits

commit:     3f7a3b294dd38c6009d41ce7f40075e2e2645c6e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 31 17:22:13 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Mar 31 17:22:13 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3f7a3b29

dispatch_conf: emulate getstatusoutput with Popen

This will fix bug #410315.

---
 pym/portage/dispatch_conf.py |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index 3d53f64..cc98fad 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -1,5 +1,5 @@
 # archive_conf.py -- functionality common to archive-conf and dispatch-conf
-# Copyright 2003-2011 Gentoo Foundation
+# Copyright 2003-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 
@@ -8,7 +8,7 @@
 
 from __future__ import print_function
 
-import os, sys, shutil
+import os, shutil, subprocess, sys
 
 import portage
 from portage.env.loaders import KeyValuePairFileLoader
@@ -26,17 +26,17 @@ DIFF3_MERGE = "diff3 -mE '%s' '%s' '%s' > '%s'"
 def diffstatusoutput(cmd, file1, file2):
     """
     Execute the string cmd in a shell with getstatusoutput() and return a
-    2-tuple (status, output). If getstatusoutput() raises
-    UnicodeDecodeError (known to happen with python3.1), return a
-    2-tuple (1, 1). This provides a simple way to check for non-zero
-    output length of diff commands, while providing simple handling of
-    UnicodeDecodeError when necessary.
+    2-tuple (status, output).
     """
-    try:
-        status, output = portage.subprocess_getstatusoutput(cmd % (file1, file2))
-        return (status, output)
-    except UnicodeDecodeError:
-        return (1, 1)
+    # Use Popen to emulate getstatusoutput(), since getstatusoutput() may
+    # raise a UnicodeDecodeError which makes the output inaccessible.
+    proc = subprocess.Popen(portage._unicode_encode(cmd % (file1, file2)),
+        stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
+    output = portage._unicode_decode(proc.communicate()[0])
+    if output and output[-1] == "\n":
+        # getstatusoutput strips one newline
+        output = output[:-1]
+    return (proc.wait(), output)
 
 def read_config(mandatory_opts):
     eprefix = portage.const.EPREFIX



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-04-01 16:38 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-04-01 16:38 UTC (permalink / raw
  To: gentoo-commits

commit:     dbb74f7abe050252655b7b4a0c4517e747ac7c08
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Apr  1 16:38:27 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Apr  1 16:38:27 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=dbb74f7a

dispatch_conf: don't pass bytes for Popen cmd

This will fix bug #410417.

---
 pym/portage/dispatch_conf.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index cc98fad..c81153a 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -30,7 +30,7 @@ def diffstatusoutput(cmd, file1, file2):
     """
     # Use Popen to emulate getstatusoutput(), since getstatusoutput() may
     # raise a UnicodeDecodeError which makes the output inaccessible.
-    proc = subprocess.Popen(portage._unicode_encode(cmd % (file1, file2)),
+    proc = subprocess.Popen(cmd % (file1, file2),
         stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
     output = portage._unicode_decode(proc.communicate()[0])
     if output and output[-1] == "\n":



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-04-14  0:56 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-04-14  0:56 UTC (permalink / raw
  To: gentoo-commits

commit:     ef19d0fba35b1fff37257b70b3bd7c77b0b4e845
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 14 00:56:24 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Apr 14 00:56:24 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ef19d0fb

perform_all: fix TypeError for bug #411897

---
 pym/portage/checksum.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 73e01b5..bd416ac 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -186,7 +186,7 @@ def _perform_md5_merge(x, **kwargs):
 def perform_all(x, calc_prelink=0):
 	mydict = {}
 	for k in hashfunc_map:
-		mydict[k] = perform_checksum(x, hashfunc_map[k], calc_prelink)[0]
+		mydict[k] = perform_checksum(x, k, calc_prelink)[0]
 	return mydict
 
 def get_valid_checksum_keys():



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-02 19:55 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-02 19:55 UTC (permalink / raw
  To: gentoo-commits

commit:     15b98eb570a734c9505cb3b82674e7dc36c90b56
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed May  2 19:55:31 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed May  2 19:55:31 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=15b98eb5

dispatch-conf: use shlex to parse diff command

---
 pym/portage/dispatch_conf.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index c81153a..4c68dfc 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -13,7 +13,7 @@ import os, shutil, subprocess, sys
 import portage
 from portage.env.loaders import KeyValuePairFileLoader
 from portage.localization import _
-from portage.util import varexpand
+from portage.util import shlex_split, varexpand
 
 RCS_BRANCH = '1.1.1'
 RCS_LOCK = 'rcs -ko -M -l'
@@ -30,8 +30,12 @@ def diffstatusoutput(cmd, file1, file2):
     """
     # Use Popen to emulate getstatusoutput(), since getstatusoutput() may
     # raise a UnicodeDecodeError which makes the output inaccessible.
-    proc = subprocess.Popen(cmd % (file1, file2),
-        stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
+    args = shlex_split(cmd % (file1, file2))
+    if sys.hexversion < 0x3000000 or sys.hexversion >= 0x3020000:
+        # Python 3.1 does not support bytes in Popen args.
+        args = [portage._unicode_encode(x, errors='strict') for x in args]
+    proc = subprocess.Popen(args,
+        stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
     output = portage._unicode_decode(proc.communicate()[0])
     if output and output[-1] == "\n":
         # getstatusoutput strips one newline



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-12  7:36 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-12  7:36 UTC (permalink / raw
  To: gentoo-commits

commit:     68888b0450b1967cb70673a5f06b04c167ef879c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 12 07:36:15 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 12 07:36:15 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=68888b04

catpkgsplit: don't cache results

The cache has been subtly broken since commit
eb2056631021a04b62c228206e44376f5c7a81ba when the eapi parameter was
added. If necessary, we can add a cpv class (or something like that) in
order to avoid redundant catpkgsplit calls in places like
match_from_list.

---
 pym/portage/versions.py |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index 6cb1566..e2761b5 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -288,7 +288,7 @@ def _pkgsplit(mypkg, eapi=None):
 
 _cat_re = re.compile('^%s$' % _cat)
 _missing_cat = 'null'
-catcache={}
+
 def catpkgsplit(mydata, silent=1, eapi=None):
 	"""
 	Takes a Category/Package-Version-Rev and returns a list of each.
@@ -304,10 +304,6 @@ def catpkgsplit(mydata, silent=1, eapi=None):
 	3.  if rev does not exist it will be '-r0'
 	"""
 
-	try:
-		return catcache[mydata]
-	except KeyError:
-		pass
 	mysplit = mydata.split('/', 1)
 	p_split=None
 	if len(mysplit)==1:
@@ -318,10 +314,8 @@ def catpkgsplit(mydata, silent=1, eapi=None):
 		if _cat_re.match(cat) is not None:
 			p_split = _pkgsplit(mysplit[1], eapi=eapi)
 	if not p_split:
-		catcache[mydata]=None
 		return None
 	retval = (cat, p_split[0], p_split[1], p_split[2])
-	catcache[mydata]=retval
 	return retval
 
 def pkgsplit(mypkg, silent=1, eapi=None):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-12 16:26 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2012-05-12 16:26 UTC (permalink / raw
  To: gentoo-commits

commit:     0252e07f4ddf0dfe843d02160b3853696a02af32
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sat May 12 16:25:16 2012 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Sat May 12 16:25:16 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0252e07f

Add workaround for http://bugs.python.org/issue14007.

---
 pym/portage/__init__.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 31d5807..6ca0445 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -44,6 +44,10 @@ except ImportError as e:
 	sys.stderr.write("    "+str(e)+"\n\n");
 	raise
 
+if sys.hexversion >= 0x3030000:
+	# Workaround for http://bugs.python.org/issue14007
+	sys.modules["_elementtree"] = None
+
 try:
 
 	import portage.proxy.lazyimport



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-12 22:31 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2012-05-12 22:31 UTC (permalink / raw
  To: gentoo-commits

commit:     d5bdc1574b7ac665900cb0769af31c38fa1621c0
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sat May 12 22:30:46 2012 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Sat May 12 22:30:46 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d5bdc157

Check type of xml.etree.ElementTree.TreeBuilder before applying
workaround for http://bugs.python.org/issue14007.

---
 pym/portage/__init__.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 6ca0445..745e06a 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -44,10 +44,6 @@ except ImportError as e:
 	sys.stderr.write("    "+str(e)+"\n\n");
 	raise
 
-if sys.hexversion >= 0x3030000:
-	# Workaround for http://bugs.python.org/issue14007
-	sys.modules["_elementtree"] = None
-
 try:
 
 	import portage.proxy.lazyimport
@@ -339,6 +335,16 @@ _python_interpreter = os.path.realpath(sys.executable)
 _bin_path = PORTAGE_BIN_PATH
 _pym_path = PORTAGE_PYM_PATH
 
+if sys.hexversion >= 0x3030000:
+	# Workaround for http://bugs.python.org/issue14007
+	def _test_xml_etree_ElementTree_TreeBuilder_type():
+		import subprocess
+		p = subprocess.Popen([_python_interpreter, "-c",
+			"import sys, xml.etree.ElementTree; sys.exit(not isinstance(xml.etree.ElementTree.TreeBuilder, type))"])
+		if p.wait() != 0:
+			sys.modules["_elementtree"] = None
+	_test_xml_etree_ElementTree_TreeBuilder_type()
+
 def _shell_quote(s):
 	"""
 	Quote a string in double-quotes and use backslashes to



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-12 22:57 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-12 22:57 UTC (permalink / raw
  To: gentoo-commits

commit:     45de6e3dbea776bba5f9483a9f23fbcc5c2f6520
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 12 22:57:03 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 12 22:57:03 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=45de6e3d

_pkg_str: add cpv attribute for match_from_list

---
 pym/portage/versions.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index de2fe70..ea8d5ae 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -351,6 +351,8 @@ class _pkg_str(_unicode):
 		if self.cpv_split is None:
 			raise InvalidData(cpv)
 		self.__dict__['cp'] = self.cpv_split[0] + '/' + self.cpv_split[1]
+		# for match_from_list introspection
+		self.__dict__['cpv'] = self
 
 	def __setattr__(self, name, value):
 		raise AttributeError("_pkg_str instances are immutable",



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-13  8:44 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-13  8:44 UTC (permalink / raw
  To: gentoo-commits

commit:     cc1527c20877364b654ece5bd1386add479c67d7
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May 13 08:44:07 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 13 08:44:07 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cc1527c2

Don't cache vercmp results.

It's probably not very helpful to cache vercmp results, since identical
version comparisons probably don't recur very often.

---
 pym/portage/versions.py |   15 +--------------
 1 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index 35385e4..f9fb606 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -70,7 +70,6 @@ def ververify(myver, silent=1):
 			print(_("!!! syntax error in version: %s") % myver)
 		return 0
 
-vercmp_cache = {}
 def vercmp(ver1, ver2, silent=1):
 	"""
 	Compare two versions
@@ -97,11 +96,7 @@ def vercmp(ver1, ver2, silent=1):
 
 	if ver1 == ver2:
 		return 0
-	mykey=ver1+":"+ver2
-	try:
-		return vercmp_cache[mykey]
-	except KeyError:
-		pass
+
 	match1 = ver_regexp.match(ver1)
 	match2 = ver_regexp.match(ver2)
 	
@@ -117,10 +112,8 @@ def vercmp(ver1, ver2, silent=1):
 
 	# shortcut for cvs ebuilds (new style)
 	if match1.group(1) and not match2.group(1):
-		vercmp_cache[mykey] = 1
 		return 1
 	elif match2.group(1) and not match1.group(1):
-		vercmp_cache[mykey] = -1
 		return -1
 	
 	# building lists of the version parts before the suffix
@@ -174,16 +167,13 @@ def vercmp(ver1, ver2, silent=1):
 
 	for i in range(0, max(len(list1), len(list2))):
 		if len(list1) <= i:
-			vercmp_cache[mykey] = -1
 			return -1
 		elif len(list2) <= i:
-			vercmp_cache[mykey] = 1
 			return 1
 		elif list1[i] != list2[i]:
 			a = list1[i]
 			b = list2[i]
 			rval = (a > b) - (a < b)
-			vercmp_cache[mykey] = rval
 			return rval
 
 	# main version is equal, so now compare the _suffix part
@@ -204,7 +194,6 @@ def vercmp(ver1, ver2, silent=1):
 			a = suffix_value[s1[0]]
 			b = suffix_value[s2[0]]
 			rval = (a > b) - (a < b)
-			vercmp_cache[mykey] = rval
 			return rval
 		if s1[1] != s2[1]:
 			# it's possible that the s(1|2)[1] == ''
@@ -219,7 +208,6 @@ def vercmp(ver1, ver2, silent=1):
 				r2 = 0
 			rval = (r1 > r2) - (r1 < r2)
 			if rval:
-				vercmp_cache[mykey] = rval
 				return rval
 
 	# the suffix part is equal to, so finally check the revision
@@ -232,7 +220,6 @@ def vercmp(ver1, ver2, silent=1):
 	else:
 		r2 = 0
 	rval = (r1 > r2) - (r1 < r2)
-	vercmp_cache[mykey] = rval
 	return rval
 	
 def pkgcmp(pkg1, pkg2):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-13  9:05 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-13  9:05 UTC (permalink / raw
  To: gentoo-commits

commit:     1564b9b0f549256fe0b8e552ae7bedd10754d61e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May 13 09:05:14 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 13 09:05:14 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1564b9b0

Use _pkg_str.version more.

---
 pym/portage/versions.py |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index f9fb606..85928a8 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -393,6 +393,10 @@ def cpv_getkey(mycpv, eapi=None):
 
 def cpv_getversion(mycpv, eapi=None):
 	"""Returns the v (including revision) from an cpv."""
+	try:
+		return mycpv.version
+	except AttributeError:
+		pass
 	cp = cpv_getkey(mycpv, eapi=eapi)
 	if cp is None:
 		return None
@@ -446,10 +450,16 @@ def best(mymatches, eapi=None):
 	if len(mymatches) == 1:
 		return mymatches[0]
 	bestmatch = mymatches[0]
-	p2 = catpkgsplit(bestmatch, eapi=eapi)[1:]
+	try:
+		v2 = bestmatch.version
+	except AttributeError:
+		v2 = _pkg_str(bestmatch, eapi=eapi).version
 	for x in mymatches[1:]:
-		p1 = catpkgsplit(x, eapi=eapi)[1:]
-		if pkgcmp(p1, p2) > 0:
+		try:
+			v1 = x.version
+		except AttributeError:
+			v1 = _pkg_str(x, eapi=eapi).version
+		if vercmp(v1, v2) > 0:
 			bestmatch = x
-			p2 = catpkgsplit(bestmatch, eapi=eapi)[1:]
+			v2 = v1
 	return bestmatch



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-13 19:52 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-13 19:52 UTC (permalink / raw
  To: gentoo-commits

commit:     603ef0a2301c1d4ca084b5a5a7be77ac83151a09
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May 13 19:49:41 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 13 19:49:41 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=603ef0a2

_pms_eapi_re: require whitespace before comment

See discussion on gentoo-pms mailing list here:
http://archives.gentoo.org/gentoo-pms/msg_1f76a55d04b4f2a3721cddc611434aad.xml

---
 pym/portage/__init__.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 745e06a..bf3fdad 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -446,7 +446,7 @@ def eapi_is_supported(eapi):
 	return eapi <= portage.const.EAPI
 
 # This pattern is specified by PMS section 7.3.1.
-_pms_eapi_re = re.compile(r"^[ \t]*EAPI=(['\"]?)([A-Za-z0-9+_.-]*)\1[ \t]*(#.*)?$")
+_pms_eapi_re = re.compile(r"^[ \t]*EAPI=(['\"]?)([A-Za-z0-9+_.-]*)\1[ \t]*([ \t]#.*)?$")
 _comment_or_blank_line = re.compile(r"^\s*(#.*)?$")
 
 def _parse_eapi_ebuild_head(f):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-13 22:16 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-13 22:16 UTC (permalink / raw
  To: gentoo-commits

commit:     2209b21e0ee6c14f9293d589cf0ddba44ee816f4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May 13 22:15:57 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 13 22:15:57 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2209b21e

cpv_sort_key: use _pkg_str

---
 pym/portage/versions.py |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index 85928a8..50eba56 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -421,22 +421,32 @@ def cpv_sort_key(eapi=None):
 
 		split1 = split_cache.get(cpv1, False)
 		if split1 is False:
-			split1 = catpkgsplit(cpv1, eapi=eapi)
-			if split1 is not None:
-				split1 = (split1[:2], '-'.join(split1[2:]))
+			split1 = None
+			try:
+				split1 = cpv1.cpv
+			except AttributeError:
+				try:
+					split1 = _pkg_str(cpv1, eapi=eapi)
+				except InvalidData:
+					pass
 			split_cache[cpv1] = split1
 
 		split2 = split_cache.get(cpv2, False)
 		if split2 is False:
-			split2 = catpkgsplit(cpv2, eapi=eapi)
-			if split2 is not None:
-				split2 = (split2[:2], '-'.join(split2[2:]))
+			split2 = None
+			try:
+				split2 = cpv2.cpv
+			except AttributeError:
+				try:
+					split2 = _pkg_str(cpv2, eapi=eapi)
+				except InvalidData:
+					pass
 			split_cache[cpv2] = split2
 
-		if split1 is None or split2 is None or split1[0] != split2[0]:
+		if split1 is None or split2 is None or split1.cp != split2.cp:
 			return (cpv1 > cpv2) - (cpv1 < cpv2)
 
-		return vercmp(split1[1], split2[1])
+		return vercmp(split1.version, split2.version)
 
 	return cmp_sort_key(cmp_cpv)
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-13 22:30 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-13 22:30 UTC (permalink / raw
  To: gentoo-commits

commit:     ba307ef1dc5ed986fa79fe732cc8d66820a901ef
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May 13 22:30:31 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 13 22:30:31 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ba307ef1

_pkg_str: make version -r0 consistent with input

---
 pym/portage/versions.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index 50eba56..298b7aa 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -338,7 +338,10 @@ class _pkg_str(_unicode):
 		if self.cpv_split is None:
 			raise InvalidData(cpv)
 		self.__dict__['cp'] = self.cpv_split[0] + '/' + self.cpv_split[1]
-		self.__dict__['version'] = "-".join(self.cpv_split[2:])
+		if self.cpv_split[-1] == "r0" and cpv[-3:] != "-r0":
+			self.__dict__['version'] = "-".join(self.cpv_split[2:-1])
+		else:
+			self.__dict__['version'] = "-".join(self.cpv_split[2:])
 		# for match_from_list introspection
 		self.__dict__['cpv'] = self
 		if slot is not None:



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-14  1:24 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-14  1:24 UTC (permalink / raw
  To: gentoo-commits

commit:     eb1f9aefed672307caa5fc1286f9a35bed3ea9f4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon May 14 01:23:53 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May 14 01:23:53 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=eb1f9aef

glsa: use _pkg_str + vercmp, not pkgcmp

---
 pym/portage/glsa.py |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 16f662f..0e59068 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -13,7 +13,7 @@ from portage import os
 from portage import _encodings
 from portage import _unicode_decode
 from portage import _unicode_encode
-from portage.versions import pkgsplit, catpkgsplit, pkgcmp, best
+from portage.versions import pkgsplit, vercmp, best
 from portage.util import grabfile, urlopen
 from portage.const import CACHE_PATH
 from portage.localization import _
@@ -368,17 +368,14 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 	for u in unaffectedList:
 		mylist = match(u, portdbapi, match_type="match-all")
 		for c in mylist:
-			c_pv = catpkgsplit(c)
-			i_pv = catpkgsplit(best(v_installed))
-			if pkgcmp(c_pv[1:], i_pv[1:]) > 0 \
+			i = best(v_installed)
+			if vercmp(c.version, i.version) > 0 \
 					and (rValue == None \
 						or not match("="+rValue, portdbapi) \
-						or (minimize ^ (pkgcmp(c_pv[1:], catpkgsplit(rValue)[1:]) > 0)) \
+						or (minimize ^ (vercmp(c.version, rValue.version) > 0)) \
 							and match("="+c, portdbapi)) \
 					and portdbapi.aux_get(c, ["SLOT"]) == vardbapi.aux_get(best(v_installed), ["SLOT"]):
-				rValue = c_pv[0]+"/"+c_pv[1]+"-"+c_pv[2]
-				if c_pv[3] != "r0":		# we don't like -r0 for display
-					rValue += "-"+c_pv[3]
+				rValue = c
 	return rValue
 
 def format_date(datestr):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-14  3:18 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-14  3:18 UTC (permalink / raw
  To: gentoo-commits

commit:     a4e23d4b6c4631a8622e72b2c5ab903533615b6b
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon May 14 03:18:08 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May 14 03:18:08 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a4e23d4b

tbz2.scan: use finally to close file

---
 pym/portage/xpak.py |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py
index 8689737..3262326 100644
--- a/pym/portage/xpak.py
+++ b/pym/portage/xpak.py
@@ -360,6 +360,7 @@ class tbz2(object):
 	def scan(self):
 		"""Scans the tbz2 to locate the xpak segment and setup internal values.
 		This function is called by relevant functions already."""
+		a = None
 		try:
 			mystat = os.stat(self.file)
 			if self.filestat:
@@ -378,29 +379,28 @@ class tbz2(object):
 			self.infosize = 0
 			self.xpaksize = 0
 			if trailer[-4:] != b'STOP':
-				a.close()
 				return 0
 			if trailer[0:8] != b'XPAKSTOP':
-				a.close()
 				return 0
 			self.infosize = decodeint(trailer[8:12])
 			self.xpaksize = self.infosize + 8
 			a.seek(-(self.xpaksize), 2)
 			header = a.read(16)
 			if header[0:8] != b'XPAKPACK':
-				a.close()
 				return 0
 			self.indexsize = decodeint(header[8:12])
 			self.datasize = decodeint(header[12:16])
 			self.indexpos = a.tell()
 			self.index = a.read(self.indexsize)
 			self.datapos = a.tell()
-			a.close()
 			return 2
 		except SystemExit:
 			raise
 		except:
 			return 0
+		finally:
+			if a is not None:
+				a.close()
 
 	def filelist(self):
 		"""Return an array of each file listed in the index."""



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-05-14  3:29 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-05-14  3:29 UTC (permalink / raw
  To: gentoo-commits

commit:     28213c0fb01e4c0db62c7fd4d6ffcc1ff5383fa5
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon May 14 03:29:07 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May 14 03:29:07 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=28213c0f

getbinpkg: fix base64 usage for python3

---
 pym/portage/getbinpkg.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 579a46f..7dec20a 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -158,11 +158,16 @@ def create_conn(baseurl,conn=None):
 	http_headers = {}
 	http_params = {}
 	if username and password:
+		try:
+			encodebytes = base64.encodebytes
+		except AttributeError:
+			# Python 2
+			encodebytes = base64.encodestring
 		http_headers = {
-			"Authorization": "Basic %s" %
-			  base64.encodestring("%s:%s" % (username, password)).replace(
-			    "\012",
-			    ""
+			b"Authorization": "Basic %s" % \
+			encodebytes(_unicode_encode("%s:%s" % (username, password))).replace(
+			    b"\012",
+			    b""
 			  ),
 		}
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-06-01 21:28 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-06-01 21:28 UTC (permalink / raw
  To: gentoo-commits

commit:     1ecb54ad4392473130f6ffdab1ba6e7105031c76
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  1 21:27:46 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jun  1 21:27:46 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1ecb54ad

portageexit: skip secpass check

The portdbapi should handle secpass already internally, and access to
secpass here can trigger unnecessary instantiation of a config instance
via the portage.data module.

---
 pym/portage/__init__.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index bf3fdad..ce28c09 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -482,7 +482,7 @@ auxdbkeys = (
 auxdbkeylen=len(auxdbkeys)
 
 def portageexit():
-	if data.secpass > 1 and os.environ.get("SANDBOX_ON") != "1":
+	if os.environ.get("SANDBOX_ON") != "1":
 		close_portdbapi_caches()
 
 class _trees_dict(dict):



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-06-01 21:43 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-06-01 21:43 UTC (permalink / raw
  To: gentoo-commits

commit:     9f782a2c115acbeac863eb1c0ac8ef5e84874d73
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  1 21:43:41 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jun  1 21:43:41 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9f782a2c

portageexit: skip SANDBOX_ON check

This check is redundant, since the portdbapi constructor already has
special SANDBOX_ON / SANDBOX_WRITE handling.

---
 pym/portage/__init__.py |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index ce28c09..56af9e4 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -482,8 +482,7 @@ auxdbkeys = (
 auxdbkeylen=len(auxdbkeys)
 
 def portageexit():
-	if os.environ.get("SANDBOX_ON") != "1":
-		close_portdbapi_caches()
+	close_portdbapi_caches()
 
 class _trees_dict(dict):
 	__slots__ = ('_running_eroot', '_target_eroot',)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-06-03  6:35 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2012-06-03  6:35 UTC (permalink / raw
  To: gentoo-commits

commit:     f75fed63cb0256505d684ce524d65c9086af0879
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sun Jun  3 06:34:34 2012 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Sun Jun  3 06:34:34 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f75fed63

Delete workaround for http://bugs.python.org/issue14007.

---
 pym/portage/__init__.py |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 56af9e4..84cac74 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -335,16 +335,6 @@ _python_interpreter = os.path.realpath(sys.executable)
 _bin_path = PORTAGE_BIN_PATH
 _pym_path = PORTAGE_PYM_PATH
 
-if sys.hexversion >= 0x3030000:
-	# Workaround for http://bugs.python.org/issue14007
-	def _test_xml_etree_ElementTree_TreeBuilder_type():
-		import subprocess
-		p = subprocess.Popen([_python_interpreter, "-c",
-			"import sys, xml.etree.ElementTree; sys.exit(not isinstance(xml.etree.ElementTree.TreeBuilder, type))"])
-		if p.wait() != 0:
-			sys.modules["_elementtree"] = None
-	_test_xml_etree_ElementTree_TreeBuilder_type()
-
 def _shell_quote(s):
 	"""
 	Quote a string in double-quotes and use backslashes to



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-06-10 23:41 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-06-10 23:41 UTC (permalink / raw
  To: gentoo-commits

commit:     0fc39028b10cf6a060c13be888d7ad1a8c488f58
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 10 23:41:25 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jun 10 23:41:25 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0fc39028

_get_pv_re: use _eapi_attrs

---
 pym/portage/versions.py |   33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index db14e99..a838800 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -23,7 +23,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
 	'portage.util:cmp_sort_key',
 )
 from portage import _unicode_decode
-from portage.eapi import eapi_allows_dots_in_PN
+from portage.eapi import _get_eapi_attrs
 from portage.exception import InvalidData
 from portage.localization import _
 
@@ -65,6 +65,24 @@ suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
 suffix_value = {"pre": -2, "p": 0, "alpha": -4, "beta": -3, "rc": -1}
 endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
 
+_pv_re_cache = {}
+
+def _get_pv_re(eapi_attrs):
+	cache_key = eapi_attrs.dots_in_PN
+	pv_re = _pv_re_cache.get(cache_key)
+	if pv_re is not None:
+		return pv_re
+
+	if eapi_attrs.dots_in_PN:
+		pv_re = _pv['dots_allowed_in_PN']
+	else:
+		pv_re = _pv['dots_disallowed_in_PN']
+
+	pv_re = re.compile('^' + pv_re + '$', re.VERBOSE)
+
+	_pv_re_cache[cache_key] = pv_re
+	return pv_re
+
 def ververify(myver, silent=1):
 	if ver_regexp.match(myver):
 		return 1
@@ -251,17 +269,6 @@ def pkgcmp(pkg1, pkg2):
 		return None
 	return vercmp("-".join(pkg1[1:]), "-".join(pkg2[1:]))
 
-_pv_re = {
-	"dots_disallowed_in_PN": re.compile('^' + _pv['dots_disallowed_in_PN'] + '$', re.VERBOSE),
-	"dots_allowed_in_PN":    re.compile('^' + _pv['dots_allowed_in_PN']    + '$', re.VERBOSE),
-}
-
-def _get_pv_re(eapi):
-	if eapi is None or eapi_allows_dots_in_PN(eapi):
-		return _pv_re["dots_allowed_in_PN"]
-	else:
-		return _pv_re["dots_disallowed_in_PN"]
-
 def _pkgsplit(mypkg, eapi=None):
 	"""
 	@param mypkg: pv
@@ -269,7 +276,7 @@ def _pkgsplit(mypkg, eapi=None):
 	1. None if input is invalid.
 	2. (pn, ver, rev) if input is pv
 	"""
-	m = _get_pv_re(eapi).match(mypkg)
+	m = _get_pv_re(_get_eapi_attrs(eapi)).match(mypkg)
 	if m is None:
 		return None
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-02 21:34 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-02 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     f38b58535453a54c4784617da4aca389cc3dedd8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  2 21:34:40 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul  2 21:34:40 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f38b5853

portage.const: tweak preserve-libs conditional

---
 pym/portage/const.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 4a07710..51dcfb0 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -98,7 +98,7 @@ SUPPORTED_FEATURES       = frozenset([
                            "noauto", "noclean", "nodoc", "noinfo", "noman",
                            "nostrip", "notitles", "parallel-fetch", "parallel-install",
                            "parse-eapi-ebuild-head",
-                           "prelink-checksums", "preserve-libs",
+                           "prelink-checksums",
                            "protect-owned", "python-trace", "sandbox",
                            "selinux", "sesandbox", "sfperms",
                            "sign", "skiprocheck", "split-elog", "split-log", "splitdebug",
@@ -173,7 +173,7 @@ _ENABLE_INHERIT_CHECK   = True
 # The definitions above will differ between branches, so it's useful to have
 # common lines of diff context here in order to avoid merge conflicts.
 
-if not _ENABLE_PRESERVE_LIBS:
+if _ENABLE_PRESERVE_LIBS:
 	SUPPORTED_FEATURES = set(SUPPORTED_FEATURES)
-	SUPPORTED_FEATURES.remove("preserve-libs")
+	SUPPORTED_FEATURES.add("preserve-libs")
 	SUPPORTED_FEATURES = frozenset(SUPPORTED_FEATURES)



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-05  0:22 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-05  0:22 UTC (permalink / raw
  To: gentoo-commits

commit:     f9d725d5f5f71e77803c44cc0701c846ae44b2aa
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 00:20:27 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jul  5 00:20:27 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f9d725d5

const: Adjust MANIFEST2_* for new defaults

---
 pym/portage/const.py |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 51dcfb0..ceef5c5 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -114,13 +114,15 @@ HASHING_BLOCKSIZE        = 32768
 MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160")
 MANIFEST1_REQUIRED_HASH  = "MD5"
 
-# Future events:
+# Past events:
 #
-# After WHIRLPOOL is supported in stable portage:
-# - Add SHA256 and WHIRLPOOL to MANIFEST2_HASH_DEFAULTS.
-# - Remove SHA1 and RMD160 from MANIFEST2_HASH_*.
+# 20120704 - After WHIRLPOOL is supported in stable portage:
 # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
 #     manifest-hashes = SHA256 SHA512 WHIRLPOOL
+# - Add SHA512 and WHIRLPOOL to MANIFEST2_HASH_DEFAULTS.
+# - Remove SHA1 and RMD160 from MANIFEST2_HASH_*.
+#
+# Future events:
 #
 # After WHIRLPOOL is supported in stable portage for at least 1 year:
 # - Change MANIFEST2_REQUIRED_HASH to WHIRLPOOL.
@@ -138,8 +140,8 @@ MANIFEST1_REQUIRED_HASH  = "MD5"
 # After layout.conf settings correspond to defaults in stable portage:
 # - Remove redundant settings from gentoo-x86/metadata/layout.conf.
 
-MANIFEST2_HASH_FUNCTIONS = ("RMD160", "SHA1", "SHA256", "SHA512", "WHIRLPOOL")
-MANIFEST2_HASH_DEFAULTS = frozenset(["SHA1", "SHA256", "RMD160"])
+MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL")
+MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"])
 MANIFEST2_REQUIRED_HASH  = "SHA256"
 
 MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-09 20:46 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-09 20:46 UTC (permalink / raw
  To: gentoo-commits

commit:     83b7af059a9b02c868238e829be2f0d18b631ded
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  9 20:34:26 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul  9 20:45:52 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=83b7af05

apply Federico "fox" Scrinzi progressbar additions of title and label display. Fix a couple bugs and add max_desc_length param.

---
 pym/portage/output.py |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 98bec81..fc6f6eb 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -631,11 +631,14 @@ class EOutput(object):
 class ProgressBar(object):
 	"""The interface is copied from the ProgressBar class from the EasyDialogs
 	module (which is Mac only)."""
-	def __init__(self, title=None, maxval=0, label=None):
-		self._title = title
+	def __init__(self, title=None, maxval=0, label=None, max_desc_length=25):
+		self._title = title or ""
 		self._maxval = maxval
-		self._label = maxval
+		self._label = label or ""
 		self._curval = 0
+		self._desc = ""
+		self._desc_max_length = max_desc_length
+		self._set_desc()
 
 	@property
 	def curval(self):
@@ -659,10 +662,23 @@ class ProgressBar(object):
 	def title(self, newstr):
 		"""Sets the text in the title bar of the progress dialog to newstr."""
 		self._title = newstr
+		self._set_desc()
 
 	def label(self, newstr):
 		"""Sets the text in the progress box of the progress dialog to newstr."""
 		self._label = newstr
+		self._set_desc()
+
+	def _set_desc(self):
+		self._desc = "%s%s" % (
+			"%s: " % self._title if self._title else "",
+			"%s" % self._label if self._label else ""
+		)
+		if len(self._desc) > self._desc_max_length:  # truncate if too long
+			self._desc = "%s..." % self._desc[:self._desc_max_length - 3]
+		if len(self._desc):
+			self._desc = self._desc.ljust(self._desc_max_length)
+
 
 	def set(self, value, maxval=None):
 		"""
@@ -722,6 +738,8 @@ class TermProgressBar(ProgressBar):
 		if cols < percentage_str_width:
 			return ""
 		bar_space = cols - percentage_str_width - square_brackets_width
+		if self._desc:
+			bar_space -= self._desc_max_length + 1
 		if maxval == 0:
 			max_bar_width = bar_space-3
 			image = "    "
@@ -751,7 +769,11 @@ class TermProgressBar(ProgressBar):
 				percentage_str_width += 1
 				bar_space -= 1
 			max_bar_width = bar_space - 1
-			image = ("%d%% " % percentage).rjust(percentage_str_width)
+			image = "%s%s" % (
+				self._desc,
+				("%d%%" % percentage).ljust(percentage_str_width),
+			)
+
 			if cols < min_columns:
 				return image
 			offset = float(curval) / maxval



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-09 21:50 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-09 21:50 UTC (permalink / raw
  To: gentoo-commits

commit:     108559b3df8ef31072c53afe07d4005f496caffb
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  9 21:49:55 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul  9 21:49:55 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=108559b3

TermProgressBar: Fix to do 80 chars (not 81)

---
 pym/portage/output.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index fc6f6eb..507adb0 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -737,9 +737,9 @@ class TermProgressBar(ProgressBar):
 		square_brackets_width = 2
 		if cols < percentage_str_width:
 			return ""
-		bar_space = cols - percentage_str_width - square_brackets_width
+		bar_space = cols - percentage_str_width - square_brackets_width - 1
 		if self._desc:
-			bar_space -= self._desc_max_length + 1
+			bar_space -= self._desc_max_length
 		if maxval == 0:
 			max_bar_width = bar_space-3
 			image = "    "



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-10  0:13 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-10  0:13 UTC (permalink / raw
  To: gentoo-commits

commit:     0623e44a500125064525413404948af9179747a9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 10 00:04:14 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jul 10 00:11:02 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0623e44a

fix a couple more inconsistancies in the progessbar title, label changes.

---
 pym/portage/output.py |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 507adb0..7550391 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -733,7 +733,7 @@ class TermProgressBar(ProgressBar):
 		curval = self._curval
 		maxval = self._maxval
 		position = self._position
-		percentage_str_width = 4
+		percentage_str_width = 5
 		square_brackets_width = 2
 		if cols < percentage_str_width:
 			return ""
@@ -742,7 +742,7 @@ class TermProgressBar(ProgressBar):
 			bar_space -= self._desc_max_length
 		if maxval == 0:
 			max_bar_width = bar_space-3
-			image = "    "
+			_percent = "".ljust(percentage_str_width)
 			if cols < min_columns:
 				return image
 			if position <= 0.5:
@@ -760,19 +760,15 @@ class TermProgressBar(ProgressBar):
 				position = 0.5
 			self._position = position
 			bar_width = int(offset * max_bar_width)
-			image = image + "[" + (bar_width * " ") + \
-				"<=>" + ((max_bar_width - bar_width) * " ") + "]"
+			image = "%s%s%s" % (self._desc, _percent,
+				"[" + (bar_width * " ") + \
+				"<=>" + ((max_bar_width - bar_width) * " ") + "]")
 			return image
 		else:
 			percentage = int(100 * float(curval) / maxval)
-			if percentage == 100:
-				percentage_str_width += 1
-				bar_space -= 1
 			max_bar_width = bar_space - 1
-			image = "%s%s" % (
-				self._desc,
-				("%d%%" % percentage).ljust(percentage_str_width),
-			)
+			_percent = ("%d%% " % percentage).rjust(percentage_str_width)
+			image = "%s%s" % (self._desc, _percent)
 
 			if cols < min_columns:
 				return image



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-12 19:54 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-12 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     09fa35229c35f9f93833192cebda38c2949b0392
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 12 19:54:06 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jul 12 19:54:06 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=09fa3522

manifest: remove unused mhashes variable

---
 pym/portage/manifest.py |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index ab91862..a04b717 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -507,7 +507,6 @@ class Manifest(object):
 			self.checkFileHashes(idtype, f, ignoreMissing=ignoreMissingFiles)
 	
 	def checkFileHashes(self, ftype, fname, ignoreMissing=False):
-		myhashes = self.fhashdict[ftype][fname]
 		try:
 			ok, reason = verify_all(self._getAbsname(ftype, fname),
 				_filter_unaccelarated_hashes(self.fhashdict[ftype][fname]))



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-18 22:31 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-18 22:31 UTC (permalink / raw
  To: gentoo-commits

commit:     bed3e06406fd63abc5d37a687494056062129851
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 18 22:31:07 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jul 18 22:31:07 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=bed3e064

slotmove: update comment about EAPI 4-slot-abi

---
 pym/portage/update.py |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/pym/portage/update.py b/pym/portage/update.py
index da8503e..121e957 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -212,9 +212,7 @@ def parse_updates(mycontent):
 					invalid_slot = True
 					break
 				if "/" in slot:
-					# Don't support EAPI 4-slot-abi style SLOT in slotmove
-					# yet, since the relevant code isn't aware of EAPI yet
-					# (see bug #426476).
+					# EAPI 4-slot-abi style SLOT is currently not supported.
 					invalid_slot = True
 					break
 



^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-22 21:53 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-22 21:53 UTC (permalink / raw
  To: gentoo-commits

commit:     b5f4e8956e5b790d5bfcb14b3d9aabe46347e716
Author:     Federico "fox" Scrinzi <fox91 <AT> anche <DOT> no>
AuthorDate: Sun Jul 22 21:52:01 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jul 22 21:52:01 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b5f4e895

get_term_size: check if sys.stderr.isatty()

---
 pym/portage/output.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 7550391..c6a7031 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -434,7 +434,7 @@ def get_term_size():
 	greater than or equal to zero, since a negative COLUMNS variable is
 	known to prevent some commands from working (see bug #394091).
 	"""
-	if not sys.stdout.isatty():
+	if not (sys.stdout.isatty() or sys.stderr.isatty()):
 		return (0, 0)
 	try:
 		import curses


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-22 22:06 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-22 22:06 UTC (permalink / raw
  To: gentoo-commits

commit:     8f9ba227869775cf7f35037283e88e4cee047703
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 22 22:05:53 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jul 22 22:05:53 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8f9ba227

TermProgressBar: fix broken ref to "image" var

Broken since commit 0623e44a500125064525413404948af9179747a9.

---
 pym/portage/output.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index c6a7031..07e25af 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -744,7 +744,7 @@ class TermProgressBar(ProgressBar):
 			max_bar_width = bar_space-3
 			_percent = "".ljust(percentage_str_width)
 			if cols < min_columns:
-				return image
+				return ""
 			if position <= 0.5:
 				offset = 2 * position
 			else:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-23  7:52 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-23  7:52 UTC (permalink / raw
  To: gentoo-commits

commit:     679747aba189dfc0b24bc37ebb23268f799c8a41
Author:     Corentin Chary <corentincj <AT> iksaif <DOT> net>
AuthorDate: Mon Jul 23 07:46:26 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 23 07:50:11 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=679747ab

output: allow to use stderr in TermProgressBar

---
 pym/portage/output.py |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 07e25af..b813a39 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -425,16 +425,16 @@ class StyleWriter(formatter.DumbWriter):
 		if self.style_listener:
 			self.style_listener(styles)
 
-def get_term_size():
+def get_term_size(fd=sys.stdout):
 	"""
 	Get the number of lines and columns of the tty that is connected to
-	stdout.  Returns a tuple of (lines, columns) or (0, 0) if an error
+	fd.  Returns a tuple of (lines, columns) or (0, 0) if an error
 	occurs. The curses module is used if available, otherwise the output of
 	`stty size` is parsed. The lines and columns values are guaranteed to be
 	greater than or equal to zero, since a negative COLUMNS variable is
 	known to prevent some commands from working (see bug #394091).
 	"""
-	if not (sys.stdout.isatty() or sys.stderr.isatty()):
+	if not hasattr(fd, 'isatty') or not fd.isatty():
 		return (0, 0)
 	try:
 		import curses
@@ -707,10 +707,10 @@ class ProgressBar(object):
 
 class TermProgressBar(ProgressBar):
 	"""A tty progress bar similar to wget's."""
-	def __init__(self, **kwargs):
+	def __init__(self, fd=sys.stdout, **kwargs):
 		ProgressBar.__init__(self, **kwargs)
-		lines, self.term_columns = get_term_size()
-		self.file = sys.stdout
+		lines, self.term_columns = get_term_size(fd)
+		self.file = fd
 		self._min_columns = 11
 		self._max_columns = 80
 		# for indeterminate mode, ranges from 0.0 to 1.0


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-27  2:43 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-27  2:43 UTC (permalink / raw
  To: gentoo-commits

commit:     d938c3ff0a4ef92451cf6381aeb23a6c2d9ad8f2
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 27 02:42:51 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jul 27 02:42:51 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d938c3ff

_selinux/spawn_wrapper: setexec *after* fork

This avoids any interference with concurrent threads in the calling
process.

---
 pym/portage/_selinux.py |   40 ++++++++++++++++++++++++++--------------
 1 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py
index 9470978..1737145 100644
--- a/pym/portage/_selinux.py
+++ b/pym/portage/_selinux.py
@@ -95,20 +95,32 @@ def setfscreate(ctx="\n"):
 		raise OSError(
 			_("setfscreate: Failed setting fs create context \"%s\".") % ctx)
 
-def spawn_wrapper(spawn_func, selinux_type):
-
-	selinux_type = _unicode_encode(selinux_type,
-		encoding=_encodings['content'], errors='strict')
-
-	def wrapper_func(*args, **kwargs):
-		con = settype(selinux_type)
-		setexec(con)
-		try:
-			return spawn_func(*args, **kwargs)
-		finally:
-			setexec()
-
-	return wrapper_func
+class spawn_wrapper(object):
+	"""
+	Create a wrapper function for the given spawn function. When the wrapper
+	is called, it will adjust the arguments such that setexec() to be called
+	*after* the fork (thereby avoiding any interference with concurrent
+	threads in the calling process).
+	"""
+	__slots__ = ("_con", "_spawn_func")
+
+	def __init__(self, spawn_func, selinux_type):
+		self._spawn_func = spawn_func
+		selinux_type = _unicode_encode(selinux_type,
+			encoding=_encodings['content'], errors='strict')
+		self._con = settype(selinux_type)
+
+	def __call__(self, *args, **kwargs):
+
+		pre_exec = kwargs.get("pre_exec")
+
+		def _pre_exec():
+			if pre_exec is not None:
+				pre_exec()
+			setexec(self._con)
+
+		kwargs["pre_exec"] = _pre_exec
+		return self._spawn_func(*args, **kwargs)
 
 def symlink(target, link, reflnk):
 	target = _unicode_encode(target, encoding=_encodings['fs'], errors='strict')


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-27 22:10 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-27 22:10 UTC (permalink / raw
  To: gentoo-commits

commit:     d4765af29cbadd1d54beacebab3eaae546d31d18
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 27 22:09:58 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jul 27 22:09:58 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d4765af2

get_term_size: handle temporary stdout overrides

---
 pym/portage/output.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index b813a39..da94377 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -425,7 +425,7 @@ class StyleWriter(formatter.DumbWriter):
 		if self.style_listener:
 			self.style_listener(styles)
 
-def get_term_size(fd=sys.stdout):
+def get_term_size(fd=None):
 	"""
 	Get the number of lines and columns of the tty that is connected to
 	fd.  Returns a tuple of (lines, columns) or (0, 0) if an error
@@ -434,6 +434,8 @@ def get_term_size(fd=sys.stdout):
 	greater than or equal to zero, since a negative COLUMNS variable is
 	known to prevent some commands from working (see bug #394091).
 	"""
+	if fd is None:
+		fd = sys.stdout
 	if not hasattr(fd, 'isatty') or not fd.isatty():
 		return (0, 0)
 	try:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-27 22:22 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-27 22:22 UTC (permalink / raw
  To: gentoo-commits

commit:     eb828d037bb400f11d0b18a75f7c9ab0559ff737
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 27 22:22:47 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jul 27 22:22:47 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=eb828d03

get_term_size: pass fd to curses.setupterm()

---
 pym/portage/output.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index da94377..4642a28 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -441,7 +441,8 @@ def get_term_size(fd=None):
 	try:
 		import curses
 		try:
-			curses.setupterm()
+			curses.setupterm(term=os.environ.get("TERM", "unknown"),
+				fd=fd.fileno())
 			return curses.tigetnum('lines'), curses.tigetnum('cols')
 		except curses.error:
 			pass


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-27 22:40 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-27 22:40 UTC (permalink / raw
  To: gentoo-commits

commit:     50a99bba6cdb2cb97b3e65520a86e1da322460e7
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 27 22:40:16 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jul 27 22:40:16 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=50a99bba

get_term_size: pass fd to stty

---
 pym/portage/output.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 4642a28..5129db7 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -7,6 +7,7 @@ import errno
 import io
 import formatter
 import re
+import subprocess
 import sys
 
 import portage
@@ -448,8 +449,11 @@ def get_term_size(fd=None):
 			pass
 	except ImportError:
 		pass
-	st, out = portage.subprocess_getstatusoutput('stty size')
-	if st == os.EX_OK:
+
+	proc = subprocess.Popen(["stty", "size"],
+		stdout=subprocess.PIPE, stderr=fd)
+	out = _unicode_decode(proc.communicate()[0])
+	if proc.wait() == os.EX_OK:
 		out = out.split()
 		if len(out) == 2:
 			try:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-07-27 22:46 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-07-27 22:46 UTC (permalink / raw
  To: gentoo-commits

commit:     0c46edc9290a459f693c12fbb34a2f361e40e168
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 27 22:46:47 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jul 27 22:46:47 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0c46edc9

get_term_size: handle missing stty command

---
 pym/portage/output.py |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 5129db7..e44375e 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -450,8 +450,15 @@ def get_term_size(fd=None):
 	except ImportError:
 		pass
 
-	proc = subprocess.Popen(["stty", "size"],
-		stdout=subprocess.PIPE, stderr=fd)
+	try:
+		proc = subprocess.Popen(["stty", "size"],
+			stdout=subprocess.PIPE, stderr=fd)
+	except EnvironmentError as e:
+		if e.errno != errno.ENOENT:
+			raise
+		# stty command not found
+		return (0, 0)
+
 	out = _unicode_decode(proc.communicate()[0])
 	if proc.wait() == os.EX_OK:
 		out = out.split()


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-08-26 22:31 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-08-26 22:31 UTC (permalink / raw
  To: gentoo-commits

commit:     fbf6518406ddb79a999b7d1230046ad93adc445d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 26 22:31:01 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Aug 26 22:31:01 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=fbf65184

_get_eapi_attrs: handle unsupported eapi as None

---
 pym/portage/eapi.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index 8b03f83..a5ef301 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -3,6 +3,8 @@
 
 import collections
 
+from portage import eapi_is_supported
+
 def eapi_has_iuse_defaults(eapi):
 	return eapi != "0"
 
@@ -77,11 +79,18 @@ def _get_eapi_attrs(eapi):
 	"""
 	When eapi is None then validation is not as strict, since we want the
 	same to work for multiple EAPIs that may have slightly different rules.
+	An unsupported eapi is handled the same as when eapi is None, which may
+	be helpful for handling of corrupt EAPI metadata in essential functions
+	such as pkgsplit.
 	"""
 	eapi_attrs = _eapi_attrs_cache.get(eapi)
 	if eapi_attrs is not None:
 		return eapi_attrs
 
+	orig_eapi = eapi
+	if eapi is not None and not eapi_is_supported(eapi):
+		eapi = None
+
 	eapi_attrs = _eapi_attrs(
 		dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)),
 		dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
@@ -96,5 +105,5 @@ def _get_eapi_attrs(eapi):
 		use_dep_defaults = (eapi is None or eapi_has_use_dep_defaults(eapi))
 	)
 
-	_eapi_attrs_cache[eapi] = eapi_attrs
+	_eapi_attrs_cache[orig_eapi] = eapi_attrs
 	return eapi_attrs


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-08-29 20:29 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-08-29 20:29 UTC (permalink / raw
  To: gentoo-commits

commit:     40ef0fd75e329b789ae1fd98184b89520e9ee0c3
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 29 20:29:37 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Aug 29 20:29:37 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=40ef0fd7

EAPI 5: enable slot-operator-deps

---
 pym/portage/eapi.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index f13e791..84d1afc 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -15,7 +15,7 @@ def eapi_has_slot_deps(eapi):
 	return eapi != "0"
 
 def eapi_has_slot_operator(eapi):
-	return eapi in ("4-slot-abi",)
+	return eapi not in ("0", "1", "2", "3", "4", "4-python")
 
 def eapi_has_src_uri_arrows(eapi):
 	return eapi not in ("0", "1")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-09-02  0:42 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-09-02  0:42 UTC (permalink / raw
  To: gentoo-commits

commit:     98fbf73ba03a048fca37d409092a14472483b6c0
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Sep  2 00:42:11 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Sep  2 00:42:11 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=98fbf73b

glsa.py: python3: ResourceWarning: unclosed file

---
 pym/portage/glsa.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 1857695..f26dc8b 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -473,7 +473,8 @@ class Glsa:
 			myurl = "file://"+self.nr
 		else:
 			myurl = repository + "glsa-%s.xml" % str(self.nr)
-		self.parse(urllib_request_urlopen(myurl))
+		with urllib_request_urlopen(myurl) as f:
+			self.parse(f)
 		return None
 
 	def parse(self, myfile):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-09-02  2:38 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-09-02  2:38 UTC (permalink / raw
  To: gentoo-commits

commit:     eac1eae58148227731a1d734ca989730d5321d31
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Sep  2 02:37:56 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Sep  2 02:37:56 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=eac1eae5

Enable EAPI 5_pre1 for testing.

---
 pym/portage/__init__.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 46bdc96..b2ce707 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -408,7 +408,7 @@ def abssymlink(symlink, target=None):
 
 _doebuild_manifest_exempt_depend = 0
 
-_testing_eapis = frozenset(["4-python", "4-slot-abi"])
+_testing_eapis = frozenset(["4-python", "4-slot-abi", "5_pre1"])
 _deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1"])
 
 def _eapi_is_deprecated(eapi):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-09-12  6:39 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-09-12  6:39 UTC (permalink / raw
  To: gentoo-commits

commit:     8833d51e37ae152cda3349edf919a2d63b0171f9
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 12 06:38:52 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Sep 12 06:38:52 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8833d51e

chflags: fixed octal flags format breakage

This broke in commit 09de8dc47ec48af2276dfa098dd5e1d3d09ddbdd.

---
 pym/portage/__init__.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 97352b2..8d5793c 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -347,7 +347,7 @@ if platform.system() in ('FreeBSD',):
 
 		@classmethod
 		def chflags(cls, path, flags, opts=""):
-			cmd = ['chflags', opts, flags, path]
+			cmd = ['chflags', opts, '%o' % (flags,), path]
 			encoding = _encodings['fs']
 			if sys.hexversion < 0x3000000 or sys.hexversion >= 0x3020000:
 				# Python 3.1 does not support bytes in Popen args.


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-09-12  8:12 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-09-12  8:12 UTC (permalink / raw
  To: gentoo-commits

commit:     98a5c7ae69499cc94a1d362aafb9bb2c1eb20ee8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 12 08:12:05 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Sep 12 08:12:05 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=98a5c7ae

chflags: fixed empty opts argument

This broke in commit 09de8dc47ec48af2276dfa098dd5e1d3d09ddbdd.

---
 pym/portage/__init__.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 8d5793c..ee51042 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -347,7 +347,11 @@ if platform.system() in ('FreeBSD',):
 
 		@classmethod
 		def chflags(cls, path, flags, opts=""):
-			cmd = ['chflags', opts, '%o' % (flags,), path]
+			cmd = ['chflags']
+			if opts:
+				cmd.append(opts)
+			cmd.append('%o' % (flags,))
+			cmd.append(path)
 			encoding = _encodings['fs']
 			if sys.hexversion < 0x3000000 or sys.hexversion >= 0x3020000:
 				# Python 3.1 does not support bytes in Popen args.


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-09-20  4:17 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-09-20  4:17 UTC (permalink / raw
  To: gentoo-commits

commit:     ff98a555c612958c8b22fc300b54f90aa790df9c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 20 04:17:08 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Sep 20 04:17:08 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ff98a555

update.py: cleanup imports

---
 pym/portage/update.py |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/pym/portage/update.py b/pym/portage/update.py
index fe00b7e..d7ae34a 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import errno
@@ -13,16 +13,13 @@ from portage import _unicode_decode
 from portage import _unicode_encode
 import portage
 portage.proxy.lazyimport.lazyimport(globals(),
-	'portage.dep:Atom,dep_getkey,isvalidatom,' + \
-	'remove_slot',
+	'portage.dep:Atom,dep_getkey,isvalidatom,_get_slot_re',
 	'portage.util:ConfigProtect,new_protect_filename,' + \
 		'normalize_path,write_atomic,writemsg',
 	'portage.util.listdir:_ignorecvs_dirs',
-	'portage.versions:catsplit,ververify'
 )
 
 from portage.const import USER_CONFIG_PATH
-from portage.dep import Atom, _get_slot_re
 from portage.eapi import _get_eapi_attrs
 from portage.exception import DirectoryNotFound, InvalidAtom, PortageException
 from portage.localization import _


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-09-21 22:00 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-09-21 22:00 UTC (permalink / raw
  To: gentoo-commits

commit:     182c8f8ab223481a420ca5184d907f44f069a714
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 21 22:00:08 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Sep 21 22:00:08 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=182c8f8a

Deprecate EAPI 5_pre2.

---
 pym/portage/__init__.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 8366939..30c7e72 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -414,8 +414,8 @@ def abssymlink(symlink, target=None):
 
 _doebuild_manifest_exempt_depend = 0
 
-_testing_eapis = frozenset(["4-python", "4-slot-abi", "5_pre2", "5-progress"])
-_deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1"])
+_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress"])
+_deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1", "5_pre2"])
 
 def _eapi_is_deprecated(eapi):
 	return eapi in _deprecated_eapis


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-09-24 15:19 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-09-24 15:19 UTC (permalink / raw
  To: gentoo-commits

commit:     c4703d79878e4e0eb8e2b36e49c0bdee835b847e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 24 15:17:11 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Sep 24 15:17:11 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c4703d79

_global_updates: scan binarytree only if needed

This will fix bug #436084.

---
 pym/portage/_global_updates.py |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/pym/portage/_global_updates.py b/pym/portage/_global_updates.py
index c0f3df0..9ae734b 100644
--- a/pym/portage/_global_updates.py
+++ b/pym/portage/_global_updates.py
@@ -46,12 +46,6 @@ def _do_global_updates(trees, prev_mtimes, quiet=False, if_mtime_changed=True):
 	portdb = trees[root]["porttree"].dbapi
 	vardb = trees[root]["vartree"].dbapi
 	bindb = trees[root]["bintree"].dbapi
-	if not os.access(bindb.bintree.pkgdir, os.W_OK):
-		bindb = None
-	else:
-		# Call binarytree.populate(), since we want to make sure it's
-		# only populated with local packages here (getbinpkgs=0).
-		bindb.bintree.populate()
 
 	world_file = os.path.join(mysettings['EROOT'], WORLD_FILE)
 	world_list = grabfile(world_file)
@@ -120,6 +114,14 @@ def _do_global_updates(trees, prev_mtimes, quiet=False, if_mtime_changed=True):
 			if myupd:
 				retupd = True
 
+	if retupd:
+		if os.access(bindb.bintree.pkgdir, os.W_OK):
+			# Call binarytree.populate(), since we want to make sure it's
+			# only populated with local packages here (getbinpkgs=0).
+			bindb.bintree.populate()
+		else:
+			bindb = None
+
 	master_repo = portdb.getRepositoryName(portdb.porttree_root)
 	if master_repo in repo_map:
 		repo_map['DEFAULT'] = repo_map[master_repo]


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-10-08 14:54 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-10-08 14:54 UTC (permalink / raw
  To: gentoo-commits

commit:     84ce763b5d397dc836b7132c0961d8f2b1a2d1f1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct  8 14:54:14 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct  8 14:54:14 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=84ce763b

spawn: use finally block for failure os._exit()

Also, use writemsg for unicode safety.

---
 pym/portage/process.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 32e60ac..a3461f4 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -15,7 +15,7 @@ from portage import _encodings
 from portage import _unicode_encode
 import portage
 portage.proxy.lazyimport.lazyimport(globals(),
-	'portage.util:dump_traceback',
+	'portage.util:dump_traceback,writemsg',
 )
 
 from portage.const import BASH_BINARY, SANDBOX_BINARY, FAKEROOT_BINARY
@@ -268,9 +268,12 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 			# We need to catch _any_ exception so that it doesn't
 			# propagate out of this function and cause exiting
 			# with anything other than os._exit()
-			sys.stderr.write("%s:\n   %s\n" % (e, " ".join(mycommand)))
+			writemsg("%s:\n   %s\n" % (e, " ".join(mycommand)), noiselevel=-1)
 			traceback.print_exc()
 			sys.stderr.flush()
+		finally:
+			# Call os._exit() from finally block, in order to suppress any
+			# finally blocks from earlier in the call stack. See bug #345289.
 			os._exit(1)
 
 	if not isinstance(pid, int):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-10-08 15:43 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-10-08 15:43 UTC (permalink / raw
  To: gentoo-commits

commit:     8cab14fe47b3f2d31a193c200644c32c0d403ec7
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct  8 15:43:21 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct  8 15:43:21 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8cab14fe

spawn: setup _exit finally block before fork

This is the most reliable way to handle the race condition.

---
 pym/portage/process.py |   43 ++++++++++++++++++++++++++-----------------
 1 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index a3461f4..fbfbde0 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -256,24 +256,33 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 		fd_pipes[1] = pw
 		fd_pipes[2] = pw
 
-	pid = os.fork()
+	parent_pid = os.getpid()
+	pid = None
+	try:
+		pid = os.fork()
 
-	if pid == 0:
-		try:
-			_exec(binary, mycommand, opt_name, fd_pipes,
-			      env, gid, groups, uid, umask, pre_exec)
-		except SystemExit:
-			raise
-		except Exception as e:
-			# We need to catch _any_ exception so that it doesn't
-			# propagate out of this function and cause exiting
-			# with anything other than os._exit()
-			writemsg("%s:\n   %s\n" % (e, " ".join(mycommand)), noiselevel=-1)
-			traceback.print_exc()
-			sys.stderr.flush()
-		finally:
-			# Call os._exit() from finally block, in order to suppress any
-			# finally blocks from earlier in the call stack. See bug #345289.
+		if pid == 0:
+			try:
+				_exec(binary, mycommand, opt_name, fd_pipes,
+					env, gid, groups, uid, umask, pre_exec)
+			except SystemExit:
+				raise
+			except Exception as e:
+				# We need to catch _any_ exception so that it doesn't
+				# propagate out of this function and cause exiting
+				# with anything other than os._exit()
+				writemsg("%s:\n   %s\n" % (e, " ".join(mycommand)),
+					noiselevel=-1)
+				traceback.print_exc()
+				sys.stderr.flush()
+
+	finally:
+		if pid == 0 or (pid is None and os.getpid() != parent_pid):
+			# Call os._exit() from a finally block in order
+			# to suppress any finally blocks from earlier
+			# in the call stack (see bug #345289). This
+			# finally block has to be setup before the fork
+			# in order to avoid a race condition.
 			os._exit(1)
 
 	if not isinstance(pid, int):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-10-16 19:09 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-10-16 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     77320e7283d5cd89894798b2ec1bbbe546474483
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 16 18:56:13 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 16 18:56:13 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=77320e72

Handle missing mkfifo for Jython.

---
 pym/portage/__init__.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index c7adbd7..667bf6f 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -288,12 +288,17 @@ class _unicode_module_wrapper(object):
 import os as _os
 _os_overrides = {
 	id(_os.fdopen)        : _os.fdopen,
-	id(_os.mkfifo)        : _os.mkfifo,
 	id(_os.popen)         : _os.popen,
 	id(_os.read)          : _os.read,
 	id(_os.system)        : _os.system,
 }
 
+
+try:
+	_os_overrides[id(_os.mkfifo)] = _os.mkfifo
+except AttributeError:
+	pass # Jython
+
 if hasattr(_os, 'statvfs'):
 	_os_overrides[id(_os.statvfs)] = _os.statvfs
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-10-17 22:58 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-10-17 22:58 UTC (permalink / raw
  To: gentoo-commits

commit:     0e5e75ce80bbc9e4dd231c693861fc9b43f677c1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 17 22:57:38 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct 17 22:57:38 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0e5e75ce

glsa.py: use try/finally for urlopen

Fixes this error reported with python 2.7.3:

AttributeError: addinfourl instance has no attribute '__exit__'

---
 pym/portage/glsa.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index f26dc8b..d3c3b3d 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -473,8 +473,13 @@ class Glsa:
 			myurl = "file://"+self.nr
 		else:
 			myurl = repository + "glsa-%s.xml" % str(self.nr)
-		with urllib_request_urlopen(myurl) as f:
+
+		f = urllib_request_urlopen(myurl)
+		try:
 			self.parse(f)
+		finally:
+			f.close()
+
 		return None
 
 	def parse(self, myfile):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-11-14 17:28 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-11-14 17:28 UTC (permalink / raw
  To: gentoo-commits

commit:     cae023ad64e403dd4246eab558bbffa9f611b724
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 14 17:28:16 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Nov 14 17:28:16 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cae023ad

update_dbentry: avoid self-blocker, bug #367215

---
 pym/portage/update.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/pym/portage/update.py b/pym/portage/update.py
index 9d29585..61cb8b6 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -20,6 +20,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
 )
 
 from portage.const import USER_CONFIG_PATH
+from portage.dep import match_from_list
 from portage.eapi import _get_eapi_attrs
 from portage.exception import DirectoryNotFound, InvalidAtom, PortageException
 from portage.localization import _
@@ -57,7 +58,16 @@ def update_dbentry(update_cmd, mycontent, eapi=None, parent=None):
 				if atom.cp != old_value:
 					continue
 
-				split_content[i] = token.replace(old_value, new_value, 1)
+				new_atom = Atom(token.replace(old_value, new_value, 1),
+					eapi=eapi)
+
+				# Avoid creating self-blockers for bug #367215.
+				if new_atom.blocker and parent is not None and \
+					parent.cp == new_atom.cp and \
+					match_from_list(new_atom, [parent]):
+					continue
+
+				split_content[i] = _unicode(new_atom)
 				modified = True
 
 			if modified:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2012-11-15 16:09 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2012-11-15 16:09 UTC (permalink / raw
  To: gentoo-commits

commit:     a6a9b6dd6342a6009097944b38163ccc66908f0e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 15 16:07:59 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Nov 15 16:08:55 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a6a9b6dd

fixdbentries: add deprecation warning

It's unused since commit c974a023882485b8eeae35bac35c1f00d1a0725b.

---
 pym/portage/update.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/pym/portage/update.py b/pym/portage/update.py
index 61cb8b6..3f76030 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -6,6 +6,7 @@ import io
 import re
 import stat
 import sys
+import warnings
 
 from portage import os
 from portage import _encodings
@@ -142,6 +143,10 @@ def fixdbentries(update_iter, dbdir, eapi=None, parent=None):
 	"""Performs update commands which result in search and replace operations
 	for each of the files in dbdir (excluding CONTENTS and environment.bz2).
 	Returns True when actual modifications are necessary and False otherwise."""
+
+	warnings.warn("portage.update.fixdbentries() is deprecated",
+		DeprecationWarning, stacklevel=2)
+
 	mydata = {}
 	for myfile in [f for f in os.listdir(dbdir) if f not in ignored_dbentries]:
 		file_path = os.path.join(dbdir, myfile)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-03 23:45 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-03 23:45 UTC (permalink / raw
  To: gentoo-commits

commit:     9294e9be09f75acbf0ea4b14e9ac2b17962fe122
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  3 23:45:38 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jan  3 23:45:38 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9294e9be

spawn: add close_fds parameter

---
 pym/portage/process.py |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 63c3154..4cf1cec 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -1,5 +1,5 @@
 # portage.py -- core Portage functionality
-# Copyright 1998-2012 Gentoo Foundation
+# Copyright 1998-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 
@@ -164,7 +164,7 @@ atexit_register(cleanup)
 
 def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
           uid=None, gid=None, groups=None, umask=None, logfile=None,
-          path_lookup=True, pre_exec=None):
+          path_lookup=True, pre_exec=None, close_fds=True):
 	"""
 	Spawns a given command.
 	
@@ -175,6 +175,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 	@param opt_name: an optional name for the spawn'd process (defaults to the binary name)
 	@type opt_name: String
 	@param fd_pipes: A dict of mapping for pipes, { '0': stdin, '1': stdout } for example
+		(default is {0:stdin, 1:stdout, 2:stderr})
 	@type fd_pipes: Dictionary
 	@param returnpid: Return the Process IDs for a successful spawn.
 	NOTE: This requires the caller clean up all the PIDs, otherwise spawn will clean them.
@@ -193,6 +194,9 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 	@type path_lookup: Boolean
 	@param pre_exec: A function to be called with no arguments just prior to the exec call.
 	@type pre_exec: callable
+	@param close_fds: If True, then close all file descriptors except those
+		referenced by fd_pipes (default is True).
+	@type close_fds: Boolean
 	
 	logfile requires stdout and stderr to be assigned to this process (ie not pointed
 	   somewhere else.)
@@ -264,7 +268,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 		if pid == 0:
 			try:
 				_exec(binary, mycommand, opt_name, fd_pipes,
-					env, gid, groups, uid, umask, pre_exec)
+					env, gid, groups, uid, umask, pre_exec, close_fds)
 			except SystemExit:
 				raise
 			except Exception as e:
@@ -340,7 +344,7 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 	return 0
 
 def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
-	pre_exec):
+	pre_exec, close_fds):
 
 	"""
 	Execute a given binary with options
@@ -395,7 +399,7 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
 	# the parent process (see bug #289486).
 	signal.signal(signal.SIGQUIT, signal.SIG_DFL)
 
-	_setup_pipes(fd_pipes)
+	_setup_pipes(fd_pipes, close_fds=close_fds)
 
 	# Set requested process permissions.
 	if gid:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-04  4:25 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-04  4:25 UTC (permalink / raw
  To: gentoo-commits

commit:     628048d69acf0fda3adcf89793b1936ab70cad0e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  4 04:25:15 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jan  4 04:25:15 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=628048d6

Enable FD_CLOEXEC for lock fd.

---
 pym/portage/locks.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 59fbc6e..ed9238d 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -1,5 +1,5 @@
 # portage: Lock management code
-# Copyright 2004-2012 Gentoo Foundation
+# Copyright 2004-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \
@@ -207,6 +207,15 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 			waiting_msg=waiting_msg, flags=flags)
 
 	if myfd != HARDLINK_FD:
+
+		try:
+			fcntl.FD_CLOEXEC
+		except AttributeError:
+			pass
+		else:
+			fcntl.fcntl(myfd, fcntl.F_SETFL,
+				fcntl.fcntl(myfd, fcntl.F_GETFL) | fcntl.FD_CLOEXEC)
+
 		_open_fds.add(myfd)
 
 	writemsg(str((lockfilename,myfd,unlinkfile))+"\n",1)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-08  0:56 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-08  0:56 UTC (permalink / raw
  To: gentoo-commits

commit:     bdc4b8b09a249451bc471f1a2f03963559a9fb3a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  8 00:56:12 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jan  8 00:56:12 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=bdc4b8b0

parseManifest2: handle space in name, bug 450736

---
 pym/portage/manifest.py |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index a75c63a..18ec5aa 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -1,8 +1,9 @@
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import errno
 import io
+import re
 import sys
 import warnings
 
@@ -25,8 +26,13 @@ from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS,
 	MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH)
 from portage.localization import _
 
+_manifest_re = re.compile(
+	r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + ') (.*)( \d+( \S+ \S+)+)$',
+	re.UNICODE)
+
 if sys.hexversion >= 0x3000000:
 	_unicode = str
+	basestring = str
 else:
 	_unicode = unicode
 
@@ -66,18 +72,17 @@ def guessThinManifestFileType(filename):
 		return None
 	return "DIST"
 
-def parseManifest2(mysplit):
+def parseManifest2(line):
+	if not isinstance(line, basestring):
+		line = ' '.join(line)
 	myentry = None
-	if len(mysplit) > 4 and mysplit[0] in MANIFEST2_IDENTIFIERS:
-		mytype = mysplit[0]
-		myname = mysplit[1]
-		try:
-			mysize = int(mysplit[2])
-		except ValueError:
-			return None
-		myhashes = dict(zip(mysplit[3::2], mysplit[4::2]))
-		myhashes["size"] = mysize
-		myentry = Manifest2Entry(type=mytype, name=myname, hashes=myhashes)
+	match = _manifest_re.match(line)
+	if match is not None:
+		tokens = match.group(3).split()
+		hashes = dict(zip(tokens[1::2], tokens[2::2]))
+		hashes["size"] = int(tokens[0])
+		myentry = Manifest2Entry(type=match.group(1),
+			name=match.group(2), hashes=hashes)
 	return myentry
 
 class ManifestEntry(object):
@@ -208,9 +213,8 @@ class Manifest(object):
 		"""Parse manifest lines and return a list of manifest entries."""
 		for myline in mylines:
 			myentry = None
-			mysplit = myline.split()
 			for parser in self.parsers:
-				myentry = parser(mysplit)
+				myentry = parser(myline)
 				if myentry is not None:
 					yield myentry
 					break # go to the next line


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-08  1:03 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-08  1:03 UTC (permalink / raw
  To: gentoo-commits

commit:     bcb84e1950401becf7ba24abea7a7165c9ea9edc
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  8 01:03:32 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jan  8 01:03:32 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=bcb84e19

Declare regex literal as such.

---
 pym/portage/manifest.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 18ec5aa..4a60a22 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -27,7 +27,7 @@ from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS,
 from portage.localization import _
 
 _manifest_re = re.compile(
-	r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + ') (.*)( \d+( \S+ \S+)+)$',
+	r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + r') (.*)( \d+( \S+ \S+)+)$',
 	re.UNICODE)
 
 if sys.hexversion >= 0x3000000:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-09 12:20 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-09 12:20 UTC (permalink / raw
  To: gentoo-commits

commit:     97e8df7eaa171d68da6b3e111c419e2a16dfaf4c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jan  9 12:19:57 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jan  9 12:19:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=97e8df7e

Manifest: make distdir argument optional

---
 pym/portage/manifest.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 4a60a22..71837e0 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -122,7 +122,7 @@ class Manifest2Entry(ManifestEntry):
 
 class Manifest(object):
 	parsers = (parseManifest2,)
-	def __init__(self, pkgdir, distdir, fetchlist_dict=None,
+	def __init__(self, pkgdir, distdir=None, fetchlist_dict=None,
 		manifest1_compat=DeprecationWarning, from_scratch=False, thin=False,
 		allow_missing=False, allow_create=True, hashes=None,
 		find_invalid_path_char=None):
@@ -383,7 +383,7 @@ class Manifest(object):
 			distfilehashes = self.fhashdict["DIST"]
 		else:
 			distfilehashes = {}
-		self.__init__(self.pkgdir, self.distdir,
+		self.__init__(self.pkgdir, distdir=self.distdir,
 			fetchlist_dict=self.fetchlist_dict, from_scratch=True,
 			thin=self.thin, allow_missing=self.allow_missing,
 			allow_create=self.allow_create, hashes=self.hashes,


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-14 11:35 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-14 11:35 UTC (permalink / raw
  To: gentoo-commits

commit:     6137290b2bb8353db0df1a7664e435ced37bacfd
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Mon Jan 14 11:35:00 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jan 14 11:35:00 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6137290b

selinux: python3 unicode paths, bug #430488

---
 pym/portage/__init__.py |    4 +++
 pym/portage/_selinux.py |   53 +++++++++++++++++++++++------------------------
 2 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 169c197..6d7b101 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -181,6 +181,8 @@ if sys.hexversion >= 0x3000000:
 		if isinstance(s, bytes):
 			s = str(s, encoding=encoding, errors=errors)
 		return s
+
+	_native_string = _unicode_decode
 else:
 	def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'):
 		if isinstance(s, unicode):
@@ -192,6 +194,8 @@ else:
 			s = unicode(s, encoding=encoding, errors=errors)
 		return s
 
+	_native_string = _unicode_encode
+
 class _unicode_func_wrapper(object):
 	"""
 	Wraps a function, converts arguments from unicode to bytes,

diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py
index 1737145..e4621b1 100644
--- a/pym/portage/_selinux.py
+++ b/pym/portage/_selinux.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # Don't use the unicode-wrapped os and shutil modules here since
@@ -8,18 +8,18 @@ import shutil
 
 import portage
 from portage import _encodings
-from portage import _unicode_decode
-from portage import _unicode_encode
+from portage import _native_string, _unicode_decode
 from portage.localization import _
 portage.proxy.lazyimport.lazyimport(globals(),
 	'selinux')
 
 def copyfile(src, dest):
-	src = _unicode_encode(src, encoding=_encodings['fs'], errors='strict')
-	dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict')
+	src = _native_string(src, encoding=_encodings['fs'], errors='strict')
+	dest = _native_string(dest, encoding=_encodings['fs'], errors='strict')
 	(rc, ctx) = selinux.lgetfilecon(src)
 	if rc < 0:
-		src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace')
+		if sys.hexversion < 0x3000000:
+			src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace')
 		raise OSError(_("copyfile: Failed getting context of \"%s\".") % src)
 
 	setfscreate(ctx)
@@ -39,12 +39,12 @@ def is_selinux_enabled():
 	return selinux.is_selinux_enabled()
 
 def mkdir(target, refdir):
-	target = _unicode_encode(target, encoding=_encodings['fs'], errors='strict')
-	refdir = _unicode_encode(refdir, encoding=_encodings['fs'], errors='strict')
+	target = _native_string(target, encoding=_encodings['fs'], errors='strict')
+	refdir = _native_string(refdir, encoding=_encodings['fs'], errors='strict')
 	(rc, ctx) = selinux.getfilecon(refdir)
 	if rc < 0:
-		refdir = _unicode_decode(refdir, encoding=_encodings['fs'],
-			errors='replace')
+		if sys.hexversion < 0x3000000:
+			refdir = _unicode_decode(refdir, encoding=_encodings['fs'], errors='replace')
 		raise OSError(
 			_("mkdir: Failed getting context of reference directory \"%s\".") \
 			% refdir)
@@ -56,11 +56,12 @@ def mkdir(target, refdir):
 		setfscreate()
 
 def rename(src, dest):
-	src = _unicode_encode(src, encoding=_encodings['fs'], errors='strict')
-	dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict')
+	src = _native_string(src, encoding=_encodings['fs'], errors='strict')
+	dest = _native_string(dest, encoding=_encodings['fs'], errors='strict')
 	(rc, ctx) = selinux.lgetfilecon(src)
 	if rc < 0:
-		src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace')
+		if sys.hexversion < 0x3000000:
+			src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace')
 		raise OSError(_("rename: Failed getting context of \"%s\".") % src)
 
 	setfscreate(ctx)
@@ -75,10 +76,10 @@ def settype(newtype):
 	return ":".join(ret)
 
 def setexec(ctx="\n"):
-	ctx = _unicode_encode(ctx, encoding=_encodings['content'], errors='strict')
+	ctx = _native_string(ctx, encoding=_encodings['content'], errors='strict')
 	if selinux.setexeccon(ctx) < 0:
-		ctx = _unicode_decode(ctx, encoding=_encodings['content'],
-			errors='replace')
+		if sys.hexversion < 0x3000000:
+			ctx = _unicode_decode(ctx, encoding=_encodings['content'], errors='replace')
 		if selinux.security_getenforce() == 1:
 			raise OSError(_("Failed setting exec() context \"%s\".") % ctx)
 		else:
@@ -87,11 +88,10 @@ def setexec(ctx="\n"):
 				noiselevel=-1)
 
 def setfscreate(ctx="\n"):
-	ctx = _unicode_encode(ctx,
-		encoding=_encodings['content'], errors='strict')
+	ctx = _native_string(ctx, encoding=_encodings['content'], errors='strict')
 	if selinux.setfscreatecon(ctx) < 0:
-		ctx = _unicode_decode(ctx,
-			encoding=_encodings['content'], errors='replace')
+		if sys.hexversion < 0x3000000:
+			ctx = _unicode_decode(ctx, encoding=_encodings['content'], errors='replace')
 		raise OSError(
 			_("setfscreate: Failed setting fs create context \"%s\".") % ctx)
 
@@ -106,8 +106,7 @@ class spawn_wrapper(object):
 
 	def __init__(self, spawn_func, selinux_type):
 		self._spawn_func = spawn_func
-		selinux_type = _unicode_encode(selinux_type,
-			encoding=_encodings['content'], errors='strict')
+		selinux_type = _native_string(selinux_type, encoding=_encodings['content'], errors='strict')
 		self._con = settype(selinux_type)
 
 	def __call__(self, *args, **kwargs):
@@ -123,13 +122,13 @@ class spawn_wrapper(object):
 		return self._spawn_func(*args, **kwargs)
 
 def symlink(target, link, reflnk):
-	target = _unicode_encode(target, encoding=_encodings['fs'], errors='strict')
-	link = _unicode_encode(link, encoding=_encodings['fs'], errors='strict')
-	reflnk = _unicode_encode(reflnk, encoding=_encodings['fs'], errors='strict')
+	target = _native_string(target, encoding=_encodings['fs'], errors='strict')
+	link = _native_string(link, encoding=_encodings['fs'], errors='strict')
+	reflnk = _native_string(reflnk, encoding=_encodings['fs'], errors='strict')
 	(rc, ctx) = selinux.lgetfilecon(reflnk)
 	if rc < 0:
-		reflnk = _unicode_decode(reflnk, encoding=_encodings['fs'],
-			errors='replace')
+		if sys.hexversion < 0x3000000:
+			reflnk = _unicode_decode(reflnk, encoding=_encodings['fs'], errors='replace')
 		raise OSError(
 			_("symlink: Failed getting context of reference symlink \"%s\".") \
 			% reflnk)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-17 17:23 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-17 17:23 UTC (permalink / raw
  To: gentoo-commits

commit:     a07a4457765037bf106efcf7f6b3f711474850d8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 17 17:22:56 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jan 17 17:22:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a07a4457

_setup_pipes: close unnecessary duplicate fds

---
 pym/portage/process.py |   55 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 23a9094..d677b9f 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -419,6 +419,13 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
 def _setup_pipes(fd_pipes, close_fds=True):
 	"""Setup pipes for a forked process.
 
+	Even when close_fds is False, file descriptors referenced as
+	values in fd_pipes are automatically closed if they do not also
+	occur as keys in fd_pipes. It is assumed that the caller will
+	explicitely add them to the fd_pipes keys if they are intended
+	to remain open. This allows for convenient elimination of
+	unnecessary duplicate file descriptors.
+
 	WARNING: When not followed by exec, the close_fds behavior
 	can trigger interference from destructors that close file
 	descriptors. This interference happens when the garbage
@@ -445,21 +452,51 @@ def _setup_pipes(fd_pipes, close_fds=True):
 	actually does nothing in this case), which avoids possible
 	interference.
 	"""
-	my_fds = {}
+	reverse_map = {}
 	# To protect from cases where direct assignment could
-	# clobber needed fds ({1:2, 2:1}) we first dupe the fds
-	# into unused fds.
-	for fd in fd_pipes:
-		my_fds[fd] = os.dup(fd_pipes[fd])
-	# Then assign them to what they should be.
-	for fd in my_fds:
-		os.dup2(my_fds[fd], fd)
+	# clobber needed fds ({1:2, 2:1}) we create a reverse map
+	# in order to know when it's necessary to create temporary
+	# backup copies with os.dup().
+	for newfd, oldfd in fd_pipes.items():
+		newfds = reverse_map.get(oldfd)
+		if newfds is None:
+			newfds = []
+			reverse_map[oldfd] = newfds
+		newfds.append(newfd)
+
+	# Assign newfds via dup2(), making temporary backups when
+	# necessary, and closing oldfd if the caller has not
+	# explicitly requested for it to remain open by adding
+	# it to the keys of fd_pipes.
+	while reverse_map:
+
+		oldfd, newfds = reverse_map.popitem()
+
+		for newfd in newfds:
+			if newfd in reverse_map:
+				# Make a temporary backup before re-assignment, assuming
+				# that backup_fd won't collide with a key in reverse_map
+				# (since all of the keys correspond to open file
+				# descriptors, and os.dup() only allocates a previously
+				# unused file discriptors).
+				backup_fd = os.dup(newfd)
+				reverse_map[backup_fd] = reverse_map.pop(newfd)
+			if oldfd != newfd:
+				os.dup2(oldfd, newfd)
+
+		if oldfd not in fd_pipes:
+			# If oldfd is not a key in fd_pipes, then it's safe
+			# to close now, since we've already made all of the
+			# requested duplicates. This also closes every
+			# backup_fd that may have been created on previous
+			# iterations of this loop.
+			os.close(oldfd)
 
 	if close_fds:
 		# Then close _all_ fds that haven't been explicitly
 		# requested to be kept open.
 		for fd in get_open_fds():
-			if fd not in my_fds:
+			if fd not in fd_pipes:
 				try:
 					os.close(fd)
 				except OSError:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-18 19:11 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-18 19:11 UTC (permalink / raw
  To: gentoo-commits

commit:     1e83f9f2eecfce75db535dd5590a37ea9ddd135d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 18 19:10:56 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jan 18 19:10:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1e83f9f2

localization: always return unicode

---
 pym/portage/localization.py |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/pym/portage/localization.py b/pym/portage/localization.py
index d16c4b1..2815ef5 100644
--- a/pym/portage/localization.py
+++ b/pym/portage/localization.py
@@ -1,12 +1,18 @@
 # localization.py -- Code to manage/help portage localization.
-# Copyright 2004 Gentoo Foundation
+# Copyright 2004-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+from portage import _unicode_decode
 
 # We define this to make the transition easier for us.
 def _(mystr):
-	return mystr
-
+	"""
+	Always returns unicode, regardless of the input type. This is
+	helpful for avoiding UnicodeDecodeError from __str__() with
+	Python 2, by ensuring that string format operations invoke
+	__unicode__() instead of __str__().
+	"""
+	return _unicode_decode(mystr)
 
 def localization_example():
 	# Dict references allow translators to rearrange word order.


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-19  2:10 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-19  2:10 UTC (permalink / raw
  To: gentoo-commits

commit:     d038b754d2423e21326939a5fb56564efe9d84bd
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Wed May 20 21:44:13 2009 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 19 02:09:04 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d038b754

Some python tweaks to speed glsa-check

svn path=/trunk/gentoolkit/; revision=646

http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=10e55d71bd5914fc7c9082adadf7bde2bec14ae3

---
 pym/portage/glsa.py |   37 ++++++++++++-------------------------
 1 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 57461f7..514dcc0 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -11,6 +11,7 @@ except ImportError:
 	from urllib import urlopen as urllib_request_urlopen
 import codecs
 import re
+import operator
 import xml.dom.minidom
 from io import StringIO
 
@@ -118,7 +119,7 @@ def get_glsa_list(myconfig):
 	
 	for f in dirlist:
 		try:
-			if f[:len(prefix)] == prefix:
+			if f[:len(prefix)] == prefix and f[-1*len(suffix):] == suffix:
 				rValue.append(f[len(prefix):-1*len(suffix)])
 		except IndexError:
 			pass
@@ -133,13 +134,11 @@ def getListElements(listnode):
 	@rtype:		List of Strings
 	@return:	a list that contains the value of the <li> elements
 	"""
-	rValue = []
 	if not listnode.nodeName in ["ul", "ol"]:
 		raise GlsaFormatException("Invalid function call: listnode is not <ul> or <ol>")
-	for li in listnode.childNodes:
-		if li.nodeType != xml.dom.Node.ELEMENT_NODE:
-			continue
-		rValue.append(getText(li, format="strip"))
+	rValue = [getText(li, format="strip") \
+		for li in listnode.childNodes \
+		if li.nodeType == xml.dom.Node.ELEMENT_NODE]
 	return rValue
 
 def getText(node, format, textfd = None):
@@ -227,9 +226,8 @@ def getMultiTagsText(rootnode, tagname, format):
 	@rtype:		List of Strings
 	@return:	a list containing the text of all I{tagname} childnodes
 	"""
-	rValue = []
-	for e in rootnode.getElementsByTagName(tagname):
-		rValue.append(getText(e, format))
+	rValue = [getText(e, format) \
+		for e in rootnode.getElementsByTagName(tagname)]
 	return rValue
 
 def makeAtom(pkgname, versionNode):
@@ -364,14 +362,9 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 				the installed version.
 	"""
 	rValue = None
-	v_installed = []
-	u_installed = []
-	for v in vulnerableList:
-		v_installed += match(v, vardbapi)
+	v_installed = reduce(operator.add, [match(v, vardbapi) for v in vulnerableList], [])
+	u_installed = reduce(operator.add, [match(u, vardbapi) for u in unaffectedList], [])
 
-	for u in unaffectedList:
-		u_installed += match(u, vardbapi)
-	
 	install_unaffected = True
 	for i in v_installed:
 		if i not in u_installed:
@@ -624,21 +617,15 @@ class Glsa:
 			pass
 		if len(self.bugs) > 0:
 			outstream.write(_("\nRelated bugs:      "))
-			for i in range(0, len(self.bugs)):
-				outstream.write(self.bugs[i])
-				if i < len(self.bugs)-1:
-					outstream.write(", ")
-				else:
-					outstream.write("\n")				
+			outstream.write(", ".join(self.bugs))
+			outstream.write("\n")
 		if self.background:
 			outstream.write("\n"+wrap(self.background, width, caption=_("Background:       ")))
 		outstream.write("\n"+wrap(self.description, width, caption=_("Description:      ")))
 		outstream.write("\n"+wrap(self.impact_text, width, caption=_("Impact:           ")))
 		outstream.write("\n"+wrap(self.workaround, width, caption=_("Workaround:       ")))
 		outstream.write("\n"+wrap(self.resolution, width, caption=_("Resolution:       ")))
-		myreferences = ""
-		for r in self.references:
-			myreferences += (r.replace(" ", SPACE_ESCAPE)+NEWLINE_ESCAPE+" ")
+		myreferences = " ".join(r.replace(" ", SPACE_ESCAPE)+NEWLINE_ESCAPE for r in self.references)
 		outstream.write("\n"+wrap(myreferences, width, caption=_("References:       ")))
 		outstream.write("\n")
 	


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-19  3:43 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-19  3:43 UTC (permalink / raw
  To: gentoo-commits

commit:     6b7ce99b21c85ffe907e52c3f84d3218cd7634a6
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Mon May  4 22:10:26 2009 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 19 03:41:30 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6b7ce99b

Whitespace.

svn path=/; revision=579

http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=bd7392b83238c81f388739533d02cc497f231abb
http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=2bae674de1f2552955b377afa1d72a67d6df5a53

---
 pym/portage/glsa.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 84bf7fd..bd55b0e 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -28,8 +28,8 @@ from portage.dep import _slot_separator
 
 # Note: the space for rgt and rlt is important !!
 # FIXME: use slot deps instead, requires GLSA format versioning
-opMapping = {"le": "<=", "lt": "<", "eq": "=", "gt": ">", "ge": ">=", 
-			 "rge": ">=~", "rle": "<=~", "rgt": " >~", "rlt": " <~"}
+opMapping = {"le": "<=", "lt": "<", "eq": "=", "gt": ">", "ge": ">=",
+		"rge": ">=~", "rle": "<=~", "rgt": " >~", "rlt": " <~"}
 NEWLINE_ESCAPE = "!;\\n"	# some random string to mark newlines that should be preserved
 SPACE_ESCAPE = "!;_"		# some random string to mark spaces that should be preserved
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-19  4:03 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-19  4:03 UTC (permalink / raw
  To: gentoo-commits

commit:     6dc9c3b3c9ff814498663af38227476f59f99033
Author:     Robert Buchholz <rbu <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 18 17:47:32 2009 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 19 04:01:43 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6dc9c3b3

getminupgrade: fix documentation and backtrace

Bug 281101: Fix a backtrace introduced in r647. in getminupgrade the
rValue variable was still leftover and was used in a check when
glsa-check was run in --emergelike mode and more than one upgrade atoms
existed.

Also, update the API documentation to reflect changes back then.

svn path=/trunk/gentoolkit/; revision=671

http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=2419943820ac8fb90bdf9bb5d2064a6ccdfec804

---
 pym/portage/glsa.py |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 84bf7fd..af6e714 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -338,14 +338,17 @@ def revisionMatch(revisionAtom, dbapi, match_type="default"):
 
 def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=True):
 	"""
-	Checks if the systemstate is matching an atom in
-	I{vulnerableList} and returns string describing
-	the lowest version for the package that matches an atom in 
-	I{unaffectedList} and is greater than the currently installed
-	version. It will return an empty list if the system is affected,
-	and no upgrade is possible or None if the system is not affected.
-	Both I{vulnerableList} and I{unaffectedList} should have the
-	same base package.
+	Checks if the state of installed packages matches an atom in
+	I{vulnerableList} and returns an update path.
+
+        Return value is:
+         * None if the system is not affected
+         * a list of tuples (a,b) where
+                  a  is a cpv describing an installed vulnerable atom
+                  b  is a cpv describing an uninstalled unaffected atom
+                       in the same slot as a
+                     OR the empty string ("") which means no upgrade
+                       is possible
 	
 	@type	vulnerableList: List of Strings
 	@param	vulnerableList: atoms matching vulnerable package versions
@@ -358,11 +361,9 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 	@type	minimize:	Boolean
 	@param	minimize:	True for a least-change upgrade, False for emerge-like algorithm
 	
-	@rtype:		String | None
-	@return:	the lowest unaffected version that is greater than
-				the installed version.
+	@rtype:		List | None
+	@return:	None if unaffected or a list of (vuln, upgrade) atoms.
 	"""
-	rValue = ""
 	v_installed = reduce(operator.add, [match(v, vardbapi) for v in vulnerableList], [])
 	u_installed = reduce(operator.add, [match(u, vardbapi) for u in unaffectedList], [])
 
@@ -384,12 +385,17 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 
 	for vuln in v_installed:
 		update = ""
+		# find the best update path for the vuln atom
 		for c in avail_updates:
 			c_pv = portage.catpkgsplit(c)
-			if vercmp(c.version, vuln.version) > 0 \
-					and (update == "" \
-						or (minimize ^ (vercmp(c.version, update.version) > 0))) \
-					and portdbapi._pkg_str(c, None).slot == vardbapi._pkg_str(vuln, None).slot:
+			if vercmp(c.version, vuln.version) <= 0:
+				# c is less or equal than vuln
+				continue
+			if portdbapi._pkg_str(c, None).slot != \
+			   vardbapi._pkg_str(vuln, None).slot:
+				# upgrade to a different slot
+				continue
+			if update == ""	or (minimize ^ (vercmp(c.version, update.version) > 0)):
 				update = c_pv[0]+"/"+c_pv[1]+"-"+c_pv[2]
 				if c_pv[3] != "r0":		# we don't like -r0 for display
 					update += "-"+c_pv[3]


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-19  4:32 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-19  4:32 UTC (permalink / raw
  To: gentoo-commits

commit:     fe876fd67045442ffacdd02f55732a4aa61c62f9
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Tue Dec  8 21:53:45 2009 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 19 04:29:33 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=fe876fd6

Merge rev 113 from djanderson's genscripts repo

svn path=/trunk/gentoolkit/; revision=703

http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=acdf616efa73b77936963eaa8b5c715db97646d2

---
 pym/portage/glsa.py |  146 ++++++++++++++++++++++++--------------------------
 1 files changed, 70 insertions(+), 76 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index af6e714..c312153 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -28,7 +28,7 @@ from portage.dep import _slot_separator
 
 # Note: the space for rgt and rlt is important !!
 # FIXME: use slot deps instead, requires GLSA format versioning
-opMapping = {"le": "<=", "lt": "<", "eq": "=", "gt": ">", "ge": ">=", 
+opMapping = {"le": "<=", "lt": "<", "eq": "=", "gt": ">", "ge": ">=",
 			 "rge": ">=~", "rle": "<=~", "rgt": " >~", "rlt": " <~"}
 NEWLINE_ESCAPE = "!;\\n"	# some random string to mark newlines that should be preserved
 SPACE_ESCAPE = "!;_"		# some random string to mark spaces that should be preserved
@@ -49,15 +49,15 @@ def get_applied_glsas(settings):
 def wrap(text, width, caption=""):
 	"""
 	Wraps the given text at column I{width}, optionally indenting
-	it so that no text is under I{caption}. It's possible to encode 
+	it so that no text is under I{caption}. It's possible to encode
 	hard linebreaks in I{text} with L{NEWLINE_ESCAPE}.
-	
+
 	@type	text: String
 	@param	text: the text to be wrapped
 	@type	width: Integer
 	@param	width: the column at which the text should be wrapped
 	@type	caption: String
-	@param	caption: this string is inserted at the beginning of the 
+	@param	caption: this string is inserted at the beginning of the
 					 return value and the paragraph is indented up to
 					 C{len(caption)}.
 	@rtype:		String
@@ -68,7 +68,7 @@ def wrap(text, width, caption=""):
 	text = text.replace(2*NEWLINE_ESCAPE, NEWLINE_ESCAPE+" "+NEWLINE_ESCAPE)
 	words = text.split()
 	indentLevel = len(caption)+1
-	
+
 	for w in words:
 		if line != "" and line[-1] == "\n":
 			rValue += line
@@ -97,10 +97,10 @@ def get_glsa_list(myconfig):
 	Returns a list of all available GLSAs in the given repository
 	by comparing the filelist there with the pattern described in
 	the config.
-	
+
 	@type	myconfig: portage.config
 	@param	myconfig: Portage settings instance
-	
+
 	@rtype:		List of Strings
 	@return:	a list of GLSA IDs in this repository
 	"""
@@ -116,7 +116,7 @@ def get_glsa_list(myconfig):
 	dirlist = os.listdir(repository)
 	prefix = "glsa-"
 	suffix = ".xml"
-	
+
 	for f in dirlist:
 		try:
 			if f[:len(prefix)] == prefix and f[-1*len(suffix):] == suffix:
@@ -128,7 +128,7 @@ def get_glsa_list(myconfig):
 def getListElements(listnode):
 	"""
 	Get all <li> elements for a given <ol> or <ul> node.
-	
+
 	@type	listnode: xml.dom.Node
 	@param	listnode: <ul> or <ol> list to get the elements for
 	@rtype:		List of Strings
@@ -149,7 +149,7 @@ def getText(node, format, textfd = None):
 	parameter the text might be formatted by adding/removing newlines,
 	tabs and spaces. This function is only useful for the GLSA DTD,
 	it's not applicable for other DTDs.
-	
+
 	@type	node: xml.dom.Node
 	@param	node: the root node to start with the parsing
 	@type	format: String
@@ -216,7 +216,7 @@ def getMultiTagsText(rootnode, tagname, format):
 	"""
 	Returns a list with the text of all subnodes of type I{tagname}
 	under I{rootnode} (which itself is not parsed) using the given I{format}.
-	
+
 	@type	rootnode: xml.dom.Node
 	@param	rootnode: the node to search for I{tagname}
 	@type	tagname: String
@@ -232,9 +232,9 @@ def getMultiTagsText(rootnode, tagname, format):
 
 def makeAtom(pkgname, versionNode):
 	"""
-	creates from the given package name and information in the 
+	creates from the given package name and information in the
 	I{versionNode} a (syntactical) valid portage atom.
-	
+
 	@type	pkgname: String
 	@param	pkgname: the name of the package for this atom
 	@type	versionNode: xml.dom.Node
@@ -257,9 +257,9 @@ def makeAtom(pkgname, versionNode):
 
 def makeVersion(versionNode):
 	"""
-	creates from the information in the I{versionNode} a 
+	creates from the information in the I{versionNode} a
 	version string (format <op><version>).
-	
+
 	@type	versionNode: xml.dom.Node
 	@param	versionNode: a <vulnerable> or <unaffected> Node that
 						 contains the version information for this atom
@@ -279,17 +279,17 @@ def makeVersion(versionNode):
 
 def match(atom, dbapi, match_type="default"):
 	"""
-	wrapper that calls revisionMatch() or portage.dbapi.dbapi.match() depending on 
+	wrapper that calls revisionMatch() or portage.dbapi.dbapi.match() depending on
 	the given atom.
-	
+
 	@type	atom: string
 	@param	atom: a <~ or >~ atom or a normal portage atom that contains the atom to match against
 	@type	dbapi: portage.dbapi.dbapi
 	@param	dbapi: one of the portage databases to use as information source
 	@type	match_type: string
-	@param	match_type: if != "default" passed as first argument to dbapi.xmatch 
+	@param	match_type: if != "default" passed as first argument to dbapi.xmatch
 				to apply the wanted visibility filters
-	
+
 	@rtype:		list of strings
 	@return:	a list with the matching versions
 	"""
@@ -305,15 +305,15 @@ def revisionMatch(revisionAtom, dbapi, match_type="default"):
 	handler for the special >~, >=~, <=~ and <~ atoms that are supposed to behave
 	as > and < except that they are limited to the same version, the range only
 	applies to the revision part.
-	
+
 	@type	revisionAtom: string
 	@param	revisionAtom: a <~ or >~ atom that contains the atom to match against
 	@type	dbapi: portage.dbapi.dbapi
 	@param	dbapi: one of the portage databases to use as information source
 	@type	match_type: string
-	@param	match_type: if != "default" passed as first argument to portdb.xmatch 
+	@param	match_type: if != "default" passed as first argument to portdb.xmatch
 				to apply the wanted visibility filters
-	
+
 	@rtype:		list of strings
 	@return:	a list with the matching versions
 	"""
@@ -334,22 +334,19 @@ def revisionMatch(revisionAtom, dbapi, match_type="default"):
 		if eval(r1+" "+revisionAtom[0:2]+" "+r2):
 			rValue.append(v)
 	return rValue
-		
+
 
 def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=True):
 	"""
-	Checks if the state of installed packages matches an atom in
-	I{vulnerableList} and returns an update path.
-
-        Return value is:
-         * None if the system is not affected
-         * a list of tuples (a,b) where
-                  a  is a cpv describing an installed vulnerable atom
-                  b  is a cpv describing an uninstalled unaffected atom
-                       in the same slot as a
-                     OR the empty string ("") which means no upgrade
-                       is possible
-	
+	Checks if the systemstate is matching an atom in
+	I{vulnerableList} and returns string describing
+	the lowest version for the package that matches an atom in
+	I{unaffectedList} and is greater than the currently installed
+	version. It will return an empty list if the system is affected,
+	and no upgrade is possible or None if the system is not affected.
+	Both I{vulnerableList} and I{unaffectedList} should have the
+	same base package.
+
 	@type	vulnerableList: List of Strings
 	@param	vulnerableList: atoms matching vulnerable package versions
 	@type	unaffectedList: List of Strings
@@ -360,12 +357,14 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 	@param	vardbapi:	Installed package repository
 	@type	minimize:	Boolean
 	@param	minimize:	True for a least-change upgrade, False for emerge-like algorithm
-	
-	@rtype:		List | None
-	@return:	None if unaffected or a list of (vuln, upgrade) atoms.
-	"""
-	v_installed = reduce(operator.add, [match(v, vardbapi) for v in vulnerableList], [])
-	u_installed = reduce(operator.add, [match(u, vardbapi) for u in unaffectedList], [])
+
+	@rtype:		String | None
+	@return:	the lowest unaffected version that is greater than
+				the installed version.
+ 	"""
+	rValue = ""
+	v_installed = reduce(operator.add, [match(v, "vartree") for v in vulnerableList], [])
+	u_installed = reduce(operator.add, [match(u, "vartree") for u in unaffectedList], [])
 
 	# remove all unaffected atoms from vulnerable list
 	v_installed = list(set(v_installed).difference(set(u_installed)))
@@ -385,17 +384,12 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 
 	for vuln in v_installed:
 		update = ""
-		# find the best update path for the vuln atom
 		for c in avail_updates:
 			c_pv = portage.catpkgsplit(c)
-			if vercmp(c.version, vuln.version) <= 0:
-				# c is less or equal than vuln
-				continue
-			if portdbapi._pkg_str(c, None).slot != \
-			   vardbapi._pkg_str(vuln, None).slot:
-				# upgrade to a different slot
-				continue
-			if update == ""	or (minimize ^ (vercmp(c.version, update.version) > 0)):
+			if vercmp(c.version, vuln.version) > 0 \
+					and (update == "" \
+						or (minimize ^ (vercmp(c.version, update.version) > 0))) \
+					and portdbapi._pkg_str(c, None).slot == vardbapi._pkg_str(vuln, None).slot:
 				update = c_pv[0]+"/"+c_pv[1]+"-"+c_pv[2]
 				if c_pv[3] != "r0":		# we don't like -r0 for display
 					update += "-"+c_pv[3]
@@ -407,7 +401,7 @@ def format_date(datestr):
 	"""
 	Takes a date (announced, revised) date from a GLSA and formats
 	it as readable text (i.e. "January 1, 2008").
-	
+
 	@type	date: String
 	@param	date: the date string to reformat
 	@rtype:		String
@@ -417,16 +411,16 @@ def format_date(datestr):
 	splitdate = datestr.split("-", 2)
 	if len(splitdate) != 3:
 		return datestr
-	
+
 	# This cannot raise an error as we use () instead of []
 	splitdate = (int(x) for x in splitdate)
-	
+
 	from datetime import date
 	try:
 		d = date(*splitdate)
 	except ValueError:
 		return datestr
-	
+
 	# TODO We could format to local date format '%x' here?
 	return _unicode_decode(d.strftime("%B %d, %Y"),
 		encoding=_encodings['content'], errors='replace')
@@ -438,7 +432,7 @@ class GlsaTypeException(Exception):
 
 class GlsaFormatException(Exception):
 	pass
-				
+
 class GlsaArgumentException(Exception):
 	pass
 
@@ -450,9 +444,9 @@ class Glsa:
 	"""
 	def __init__(self, myid, myconfig, vardbapi, portdbapi):
 		"""
-		Simple constructor to set the ID, store the config and gets the 
+		Simple constructor to set the ID, store the config and gets the
 		XML data by calling C{self.read()}.
-		
+
 		@type	myid: String
 		@param	myid: String describing the id for the GLSA object (standard
 					  GLSAs have an ID of the form YYYYMM-nn) or an existing
@@ -482,7 +476,7 @@ class Glsa:
 		"""
 		Here we build the filename from the config and the ID and pass
 		it to urllib to fetch it from the filesystem or a remote server.
-		
+
 		@rtype:		None
 		@return:	None
 		"""
@@ -505,10 +499,10 @@ class Glsa:
 
 	def parse(self, myfile):
 		"""
-		This method parses the XML file and sets up the internal data 
+		This method parses the XML file and sets up the internal data
 		structures by calling the different helper functions in this
 		module.
-		
+
 		@type	myfile: String
 		@param	myfile: Filename to grab the XML data from
 		@rtype:		None
@@ -531,7 +525,7 @@ class Glsa:
 		self.title = getText(myroot.getElementsByTagName("title")[0], format="strip")
 		self.synopsis = getText(myroot.getElementsByTagName("synopsis")[0], format="strip")
 		self.announced = format_date(getText(myroot.getElementsByTagName("announced")[0], format="strip"))
-		
+
 		count = 1
 		# Support both formats of revised:
 		# <revised>December 30, 2007: 02</revised>
@@ -543,15 +537,15 @@ class Glsa:
 			count = revisedEl.getAttribute("count")
 		elif (self.revised.find(":") >= 0):
 			(self.revised, count) = self.revised.split(":")
-		
+
 		self.revised = format_date(self.revised)
-		
+
 		try:
 			self.count = int(count)
 		except ValueError:
 			# TODO should this raise a GlsaFormatException?
 			self.count = 1
-		
+
 		# now the optional and 0-n toplevel, #PCDATA tags and references
 		try:
 			self.access = getText(myroot.getElementsByTagName("access")[0], format="strip")
@@ -559,7 +553,7 @@ class Glsa:
 			self.access = ""
 		self.bugs = getMultiTagsText(myroot, "bug", format="strip")
 		self.references = getMultiTagsText(myroot.getElementsByTagName("references")[0], "uri", format="keep")
-		
+
 		# and now the formatted text elements
 		self.description = getText(myroot.getElementsByTagName("description")[0], format="xml")
 		self.workaround = getText(myroot.getElementsByTagName("workaround")[0], format="xml")
@@ -569,7 +563,7 @@ class Glsa:
 		try:
 			self.background = getText(myroot.getElementsByTagName("background")[0], format="xml")
 		except IndexError:
-			self.background = ""					
+			self.background = ""
 
 		# finally the interesting tags (product, affected, package)
 		self.glsatype = myroot.getElementsByTagName("product")[0].getAttribute("type")
@@ -601,10 +595,10 @@ class Glsa:
 
 	def dump(self, outstream=sys.stdout, encoding="utf-8"):
 		"""
-		Dumps a plaintext representation of this GLSA to I{outfile} or 
+		Dumps a plaintext representation of this GLSA to I{outfile} or
 		B{stdout} if it is ommitted. You can specify an alternate
 		I{encoding} if needed (default is utf-8).
-		
+
 		@type	outstream: File
 		@param	outfile: Stream that should be used for writing
 						 (defaults to sys.stdout)
@@ -645,13 +639,13 @@ class Glsa:
 		myreferences = " ".join(r.replace(" ", SPACE_ESCAPE)+NEWLINE_ESCAPE for r in self.references)
 		outstream.write("\n"+wrap(myreferences, width, caption=_("References:       ")))
 		outstream.write("\n")
-	
+
 	def isVulnerable(self):
 		"""
 		Tests if the system is affected by this GLSA by checking if any
 		vulnerable package versions are installed. Also checks for affected
 		architectures.
-		
+
 		@rtype:		Boolean
 		@return:	True if the system is affected, False if not
 		"""
@@ -666,12 +660,12 @@ class Glsa:
 								and None != getMinUpgrade(path["vul_atoms"], path["unaff_atoms"], \
 										self.portdbapi, self.vardbapi))
 		return rValue
-	
+
 	def isInjected(self):
 		"""
 		Looks if the GLSA ID is in the GLSA checkfile to check if this
 		GLSA should be marked as applied.
-		
+
 		@rtype:		Boolean
 		@returns:	True if the GLSA is in the inject file, False if not
 		"""
@@ -683,7 +677,7 @@ class Glsa:
 	def inject(self):
 		"""
 		Puts the ID of this GLSA into the GLSA checkfile, so it won't
-		show up on future checks. Should be called after a GLSA is 
+		show up on future checks. Should be called after a GLSA is
 		applied or on explicit user request.
 
 		@rtype:		None
@@ -698,13 +692,13 @@ class Glsa:
 			checkfile.write(_unicode_decode(self.nr + "\n"))
 			checkfile.close()
 		return None
-	
+
 	def getMergeList(self, least_change=True):
 		"""
 		Returns the list of package-versions that have to be merged to
-		apply this GLSA properly. The versions are as low as possible 
+		apply this GLSA properly. The versions are as low as possible
 		while avoiding downgrades (see L{getMinUpgrade}).
-		
+
 		@type	least_change: Boolean
 		@param	least_change: True if the smallest possible upgrade should be selected,
 					False for an emerge-like algorithm


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-19  4:57 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-19  4:57 UTC (permalink / raw
  To: gentoo-commits

commit:     8b61e83f8f88f035eaea3d0305d565b507cbdc3d
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Tue Dec  8 21:53:45 2009 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 19 04:56:46 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8b61e83f

Merge rev 113 from djanderson's genscripts repo

svn path=/trunk/gentoolkit/; revision=703

http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=acdf616efa73b77936963eaa8b5c715db97646d2

---
 pym/portage/glsa.py |  142 ++++++++++++++++++++++++--------------------------
 1 files changed, 68 insertions(+), 74 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index af6e714..155d3e5 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -28,7 +28,7 @@ from portage.dep import _slot_separator
 
 # Note: the space for rgt and rlt is important !!
 # FIXME: use slot deps instead, requires GLSA format versioning
-opMapping = {"le": "<=", "lt": "<", "eq": "=", "gt": ">", "ge": ">=", 
+opMapping = {"le": "<=", "lt": "<", "eq": "=", "gt": ">", "ge": ">=",
 			 "rge": ">=~", "rle": "<=~", "rgt": " >~", "rlt": " <~"}
 NEWLINE_ESCAPE = "!;\\n"	# some random string to mark newlines that should be preserved
 SPACE_ESCAPE = "!;_"		# some random string to mark spaces that should be preserved
@@ -49,15 +49,15 @@ def get_applied_glsas(settings):
 def wrap(text, width, caption=""):
 	"""
 	Wraps the given text at column I{width}, optionally indenting
-	it so that no text is under I{caption}. It's possible to encode 
+	it so that no text is under I{caption}. It's possible to encode
 	hard linebreaks in I{text} with L{NEWLINE_ESCAPE}.
-	
+
 	@type	text: String
 	@param	text: the text to be wrapped
 	@type	width: Integer
 	@param	width: the column at which the text should be wrapped
 	@type	caption: String
-	@param	caption: this string is inserted at the beginning of the 
+	@param	caption: this string is inserted at the beginning of the
 					 return value and the paragraph is indented up to
 					 C{len(caption)}.
 	@rtype:		String
@@ -68,7 +68,7 @@ def wrap(text, width, caption=""):
 	text = text.replace(2*NEWLINE_ESCAPE, NEWLINE_ESCAPE+" "+NEWLINE_ESCAPE)
 	words = text.split()
 	indentLevel = len(caption)+1
-	
+
 	for w in words:
 		if line != "" and line[-1] == "\n":
 			rValue += line
@@ -97,10 +97,10 @@ def get_glsa_list(myconfig):
 	Returns a list of all available GLSAs in the given repository
 	by comparing the filelist there with the pattern described in
 	the config.
-	
+
 	@type	myconfig: portage.config
 	@param	myconfig: Portage settings instance
-	
+
 	@rtype:		List of Strings
 	@return:	a list of GLSA IDs in this repository
 	"""
@@ -116,7 +116,7 @@ def get_glsa_list(myconfig):
 	dirlist = os.listdir(repository)
 	prefix = "glsa-"
 	suffix = ".xml"
-	
+
 	for f in dirlist:
 		try:
 			if f[:len(prefix)] == prefix and f[-1*len(suffix):] == suffix:
@@ -128,7 +128,7 @@ def get_glsa_list(myconfig):
 def getListElements(listnode):
 	"""
 	Get all <li> elements for a given <ol> or <ul> node.
-	
+
 	@type	listnode: xml.dom.Node
 	@param	listnode: <ul> or <ol> list to get the elements for
 	@rtype:		List of Strings
@@ -149,7 +149,7 @@ def getText(node, format, textfd = None):
 	parameter the text might be formatted by adding/removing newlines,
 	tabs and spaces. This function is only useful for the GLSA DTD,
 	it's not applicable for other DTDs.
-	
+
 	@type	node: xml.dom.Node
 	@param	node: the root node to start with the parsing
 	@type	format: String
@@ -216,7 +216,7 @@ def getMultiTagsText(rootnode, tagname, format):
 	"""
 	Returns a list with the text of all subnodes of type I{tagname}
 	under I{rootnode} (which itself is not parsed) using the given I{format}.
-	
+
 	@type	rootnode: xml.dom.Node
 	@param	rootnode: the node to search for I{tagname}
 	@type	tagname: String
@@ -232,9 +232,9 @@ def getMultiTagsText(rootnode, tagname, format):
 
 def makeAtom(pkgname, versionNode):
 	"""
-	creates from the given package name and information in the 
+	creates from the given package name and information in the
 	I{versionNode} a (syntactical) valid portage atom.
-	
+
 	@type	pkgname: String
 	@param	pkgname: the name of the package for this atom
 	@type	versionNode: xml.dom.Node
@@ -257,9 +257,9 @@ def makeAtom(pkgname, versionNode):
 
 def makeVersion(versionNode):
 	"""
-	creates from the information in the I{versionNode} a 
+	creates from the information in the I{versionNode} a
 	version string (format <op><version>).
-	
+
 	@type	versionNode: xml.dom.Node
 	@param	versionNode: a <vulnerable> or <unaffected> Node that
 						 contains the version information for this atom
@@ -279,17 +279,17 @@ def makeVersion(versionNode):
 
 def match(atom, dbapi, match_type="default"):
 	"""
-	wrapper that calls revisionMatch() or portage.dbapi.dbapi.match() depending on 
+	wrapper that calls revisionMatch() or portage.dbapi.dbapi.match() depending on
 	the given atom.
-	
+
 	@type	atom: string
 	@param	atom: a <~ or >~ atom or a normal portage atom that contains the atom to match against
 	@type	dbapi: portage.dbapi.dbapi
 	@param	dbapi: one of the portage databases to use as information source
 	@type	match_type: string
-	@param	match_type: if != "default" passed as first argument to dbapi.xmatch 
+	@param	match_type: if != "default" passed as first argument to dbapi.xmatch
 				to apply the wanted visibility filters
-	
+
 	@rtype:		list of strings
 	@return:	a list with the matching versions
 	"""
@@ -305,15 +305,15 @@ def revisionMatch(revisionAtom, dbapi, match_type="default"):
 	handler for the special >~, >=~, <=~ and <~ atoms that are supposed to behave
 	as > and < except that they are limited to the same version, the range only
 	applies to the revision part.
-	
+
 	@type	revisionAtom: string
 	@param	revisionAtom: a <~ or >~ atom that contains the atom to match against
 	@type	dbapi: portage.dbapi.dbapi
 	@param	dbapi: one of the portage databases to use as information source
 	@type	match_type: string
-	@param	match_type: if != "default" passed as first argument to portdb.xmatch 
+	@param	match_type: if != "default" passed as first argument to portdb.xmatch
 				to apply the wanted visibility filters
-	
+
 	@rtype:		list of strings
 	@return:	a list with the matching versions
 	"""
@@ -334,22 +334,19 @@ def revisionMatch(revisionAtom, dbapi, match_type="default"):
 		if eval(r1+" "+revisionAtom[0:2]+" "+r2):
 			rValue.append(v)
 	return rValue
-		
+
 
 def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=True):
 	"""
-	Checks if the state of installed packages matches an atom in
-	I{vulnerableList} and returns an update path.
-
-        Return value is:
-         * None if the system is not affected
-         * a list of tuples (a,b) where
-                  a  is a cpv describing an installed vulnerable atom
-                  b  is a cpv describing an uninstalled unaffected atom
-                       in the same slot as a
-                     OR the empty string ("") which means no upgrade
-                       is possible
-	
+	Checks if the systemstate is matching an atom in
+	I{vulnerableList} and returns string describing
+	the lowest version for the package that matches an atom in
+	I{unaffectedList} and is greater than the currently installed
+	version. It will return an empty list if the system is affected,
+	and no upgrade is possible or None if the system is not affected.
+	Both I{vulnerableList} and I{unaffectedList} should have the
+	same base package.
+
 	@type	vulnerableList: List of Strings
 	@param	vulnerableList: atoms matching vulnerable package versions
 	@type	unaffectedList: List of Strings
@@ -360,10 +357,12 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 	@param	vardbapi:	Installed package repository
 	@type	minimize:	Boolean
 	@param	minimize:	True for a least-change upgrade, False for emerge-like algorithm
-	
-	@rtype:		List | None
-	@return:	None if unaffected or a list of (vuln, upgrade) atoms.
-	"""
+
+	@rtype:		String | None
+	@return:	the lowest unaffected version that is greater than
+				the installed version.
+ 	"""
+	rValue = ""
 	v_installed = reduce(operator.add, [match(v, vardbapi) for v in vulnerableList], [])
 	u_installed = reduce(operator.add, [match(u, vardbapi) for u in unaffectedList], [])
 
@@ -385,17 +384,12 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 
 	for vuln in v_installed:
 		update = ""
-		# find the best update path for the vuln atom
 		for c in avail_updates:
 			c_pv = portage.catpkgsplit(c)
-			if vercmp(c.version, vuln.version) <= 0:
-				# c is less or equal than vuln
-				continue
-			if portdbapi._pkg_str(c, None).slot != \
-			   vardbapi._pkg_str(vuln, None).slot:
-				# upgrade to a different slot
-				continue
-			if update == ""	or (minimize ^ (vercmp(c.version, update.version) > 0)):
+			if vercmp(c.version, vuln.version) > 0 \
+					and (update == "" \
+						or (minimize ^ (vercmp(c.version, update.version) > 0))) \
+					and portdbapi._pkg_str(c, None).slot == vardbapi._pkg_str(vuln, None).slot:
 				update = c_pv[0]+"/"+c_pv[1]+"-"+c_pv[2]
 				if c_pv[3] != "r0":		# we don't like -r0 for display
 					update += "-"+c_pv[3]
@@ -407,7 +401,7 @@ def format_date(datestr):
 	"""
 	Takes a date (announced, revised) date from a GLSA and formats
 	it as readable text (i.e. "January 1, 2008").
-	
+
 	@type	date: String
 	@param	date: the date string to reformat
 	@rtype:		String
@@ -417,16 +411,16 @@ def format_date(datestr):
 	splitdate = datestr.split("-", 2)
 	if len(splitdate) != 3:
 		return datestr
-	
+
 	# This cannot raise an error as we use () instead of []
 	splitdate = (int(x) for x in splitdate)
-	
+
 	from datetime import date
 	try:
 		d = date(*splitdate)
 	except ValueError:
 		return datestr
-	
+
 	# TODO We could format to local date format '%x' here?
 	return _unicode_decode(d.strftime("%B %d, %Y"),
 		encoding=_encodings['content'], errors='replace')
@@ -438,7 +432,7 @@ class GlsaTypeException(Exception):
 
 class GlsaFormatException(Exception):
 	pass
-				
+
 class GlsaArgumentException(Exception):
 	pass
 
@@ -450,9 +444,9 @@ class Glsa:
 	"""
 	def __init__(self, myid, myconfig, vardbapi, portdbapi):
 		"""
-		Simple constructor to set the ID, store the config and gets the 
+		Simple constructor to set the ID, store the config and gets the
 		XML data by calling C{self.read()}.
-		
+
 		@type	myid: String
 		@param	myid: String describing the id for the GLSA object (standard
 					  GLSAs have an ID of the form YYYYMM-nn) or an existing
@@ -482,7 +476,7 @@ class Glsa:
 		"""
 		Here we build the filename from the config and the ID and pass
 		it to urllib to fetch it from the filesystem or a remote server.
-		
+
 		@rtype:		None
 		@return:	None
 		"""
@@ -505,10 +499,10 @@ class Glsa:
 
 	def parse(self, myfile):
 		"""
-		This method parses the XML file and sets up the internal data 
+		This method parses the XML file and sets up the internal data
 		structures by calling the different helper functions in this
 		module.
-		
+
 		@type	myfile: String
 		@param	myfile: Filename to grab the XML data from
 		@rtype:		None
@@ -531,7 +525,7 @@ class Glsa:
 		self.title = getText(myroot.getElementsByTagName("title")[0], format="strip")
 		self.synopsis = getText(myroot.getElementsByTagName("synopsis")[0], format="strip")
 		self.announced = format_date(getText(myroot.getElementsByTagName("announced")[0], format="strip"))
-		
+
 		count = 1
 		# Support both formats of revised:
 		# <revised>December 30, 2007: 02</revised>
@@ -543,15 +537,15 @@ class Glsa:
 			count = revisedEl.getAttribute("count")
 		elif (self.revised.find(":") >= 0):
 			(self.revised, count) = self.revised.split(":")
-		
+
 		self.revised = format_date(self.revised)
-		
+
 		try:
 			self.count = int(count)
 		except ValueError:
 			# TODO should this raise a GlsaFormatException?
 			self.count = 1
-		
+
 		# now the optional and 0-n toplevel, #PCDATA tags and references
 		try:
 			self.access = getText(myroot.getElementsByTagName("access")[0], format="strip")
@@ -559,7 +553,7 @@ class Glsa:
 			self.access = ""
 		self.bugs = getMultiTagsText(myroot, "bug", format="strip")
 		self.references = getMultiTagsText(myroot.getElementsByTagName("references")[0], "uri", format="keep")
-		
+
 		# and now the formatted text elements
 		self.description = getText(myroot.getElementsByTagName("description")[0], format="xml")
 		self.workaround = getText(myroot.getElementsByTagName("workaround")[0], format="xml")
@@ -569,7 +563,7 @@ class Glsa:
 		try:
 			self.background = getText(myroot.getElementsByTagName("background")[0], format="xml")
 		except IndexError:
-			self.background = ""					
+			self.background = ""
 
 		# finally the interesting tags (product, affected, package)
 		self.glsatype = myroot.getElementsByTagName("product")[0].getAttribute("type")
@@ -601,10 +595,10 @@ class Glsa:
 
 	def dump(self, outstream=sys.stdout, encoding="utf-8"):
 		"""
-		Dumps a plaintext representation of this GLSA to I{outfile} or 
+		Dumps a plaintext representation of this GLSA to I{outfile} or
 		B{stdout} if it is ommitted. You can specify an alternate
 		I{encoding} if needed (default is utf-8).
-		
+
 		@type	outstream: File
 		@param	outfile: Stream that should be used for writing
 						 (defaults to sys.stdout)
@@ -645,13 +639,13 @@ class Glsa:
 		myreferences = " ".join(r.replace(" ", SPACE_ESCAPE)+NEWLINE_ESCAPE for r in self.references)
 		outstream.write("\n"+wrap(myreferences, width, caption=_("References:       ")))
 		outstream.write("\n")
-	
+
 	def isVulnerable(self):
 		"""
 		Tests if the system is affected by this GLSA by checking if any
 		vulnerable package versions are installed. Also checks for affected
 		architectures.
-		
+
 		@rtype:		Boolean
 		@return:	True if the system is affected, False if not
 		"""
@@ -666,12 +660,12 @@ class Glsa:
 								and None != getMinUpgrade(path["vul_atoms"], path["unaff_atoms"], \
 										self.portdbapi, self.vardbapi))
 		return rValue
-	
+
 	def isInjected(self):
 		"""
 		Looks if the GLSA ID is in the GLSA checkfile to check if this
 		GLSA should be marked as applied.
-		
+
 		@rtype:		Boolean
 		@returns:	True if the GLSA is in the inject file, False if not
 		"""
@@ -683,7 +677,7 @@ class Glsa:
 	def inject(self):
 		"""
 		Puts the ID of this GLSA into the GLSA checkfile, so it won't
-		show up on future checks. Should be called after a GLSA is 
+		show up on future checks. Should be called after a GLSA is
 		applied or on explicit user request.
 
 		@rtype:		None
@@ -698,13 +692,13 @@ class Glsa:
 			checkfile.write(_unicode_decode(self.nr + "\n"))
 			checkfile.close()
 		return None
-	
+
 	def getMergeList(self, least_change=True):
 		"""
 		Returns the list of package-versions that have to be merged to
-		apply this GLSA properly. The versions are as low as possible 
+		apply this GLSA properly. The versions are as low as possible
 		while avoiding downgrades (see L{getMinUpgrade}).
-		
+
 		@type	least_change: Boolean
 		@param	least_change: True if the smallest possible upgrade should be selected,
 					False for an emerge-like algorithm


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-19  6:14 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-19  6:14 UTC (permalink / raw
  To: gentoo-commits

commit:     91aeef92a207cbe6bcc70a6420fe4e78c7c5dc9e
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 19 06:14:16 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 19 06:14:16 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=91aeef92

glsa.py: fix misc breakage

---
 pym/portage/glsa.py |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 1dd8a98..cac0f1a 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -379,7 +379,7 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 	for u in unaffectedList:
 		# TODO: This had match_type="match-all" before. I don't think it should
 		# since we disregarded masked items later anyway (match(=rValue, "porttree"))
-		avail_updates.update(match(u, "porttree"))
+		avail_updates.update(match(u, portdbapi))
 	# if an atom is already installed, we should not consider it for upgrades
 	avail_updates.difference_update(u_installed)
 
@@ -718,7 +718,8 @@ class Glsa:
 		systemAffection = []
 		for pkg in self.packages.keys():
 			for path in self.packages[pkg]:
-				update = getMinUpgrade(path["vul_atoms"], path["unaff_atoms"], minimize=least_change)
+				update = getMinUpgrade(path["vul_atoms"], path["unaff_atoms"],
+					self.portdbapi, self.vardbapi, minimize=least_change)
 				if update:
 					systemAffection.extend(update)
 		return systemAffection


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-25 21:30 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-25 21:30 UTC (permalink / raw
  To: gentoo-commits

commit:     b1e27de54c2ff4b383e5efe62b0ddb785c0573e8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 25 21:30:44 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jan 25 21:30:44 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b1e27de5

Suppress portage group warning for bug #454060.

---
 pym/portage/data.py |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/pym/portage/data.py b/pym/portage/data.py
index b922ff8..29292f5 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -86,19 +86,27 @@ def _get_global(k):
 		elif portage.const.EPREFIX:
 			secpass = 2
 		#Discover the uid and gid of the portage user/group
+		keyerror = False
 		try:
 			portage_uid = pwd.getpwnam(_get_global('_portage_username')).pw_uid
-			_portage_grpname = _get_global('_portage_grpname')
-			if platform.python_implementation() == 'PyPy':
-				# Somehow this prevents "TypeError: expected string" errors
-				# from grp.getgrnam() with PyPy 1.7
-				_portage_grpname = str(_portage_grpname)
-			portage_gid = grp.getgrnam(_portage_grpname).gr_gid
-			if secpass < 1 and portage_gid in os.getgroups():
-				secpass = 1
 		except KeyError:
+			keyerror = True
 			portage_uid = 0
+
+		try:
+			portage_gid = grp.getgrnam(_get_global('_portage_grpname')).gr_gid
+		except KeyError:
+			keyerror = True
 			portage_gid = 0
+
+		if secpass < 1 and portage_gid in os.getgroups():
+			secpass = 1
+
+		# Suppress this error message if both PORTAGE_GRPNAME and
+		# PORTAGE_USERNAME are set to "root", for things like
+		# Android (see bug #454060).
+		if keyerror and not (_get_global('_portage_username') == "root" and
+			_get_global('_portage_grpname') == "root"):
 			writemsg(colorize("BAD",
 				_("portage: 'portage' user or group missing.")) + "\n", noiselevel=-1)
 			writemsg(_(
@@ -224,10 +232,18 @@ def _init(settings):
 	if '_portage_grpname' not in _initialized_globals and \
 		'_portage_username' not in _initialized_globals:
 
+		# Prevents "TypeError: expected string" errors
+		# from grp.getgrnam() with PyPy
+		native_string = platform.python_implementation() == 'PyPy'
+
 		v = settings.get('PORTAGE_GRPNAME', 'portage')
+		if native_string:
+			v = portage._native_string(v)
 		globals()['_portage_grpname'] = v
 		_initialized_globals.add('_portage_grpname')
 
 		v = settings.get('PORTAGE_USERNAME', 'portage')
+		if native_string:
+			v = portage._native_string(v)
 		globals()['_portage_username'] = v
 		_initialized_globals.add('_portage_username')


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-01-28  1:21 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-01-28  1:21 UTC (permalink / raw
  To: gentoo-commits

commit:     4021d5a9723b353823ba52cb5e9080de3acf7b68
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 28 01:18:57 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jan 28 01:18:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4021d5a9

Add chown workaround for python in Fedora 18.

Compatibility workaround for Python 2.7.3 in Fedora 18, which throws
"TypeError: group id must be integer" if we try to pass an ObjectProxy
instance into chown.

---
 pym/portage/__init__.py |   27 ++++++++++++++++++++++++++-
 pym/portage/data.py     |    4 ++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 94ca7b9..a8b692c 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -224,7 +224,7 @@ class _unicode_func_wrapper(object):
 		self._func = func
 		self._encoding = encoding
 
-	def __call__(self, *args, **kwargs):
+	def _process_args(self, args, kwargs):
 
 		encoding = self._encoding
 		wrapped_args = [_unicode_encode(x, encoding=encoding, errors='strict')
@@ -236,6 +236,13 @@ class _unicode_func_wrapper(object):
 		else:
 			wrapped_kwargs = {}
 
+		return (wrapped_args, wrapped_kwargs)
+
+	def __call__(self, *args, **kwargs):
+
+		encoding = self._encoding
+		wrapped_args, wrapped_kwargs = self._process_args(args, kwargs)
+
 		rval = self._func(*wrapped_args, **wrapped_kwargs)
 
 		# Don't use isinstance() since we don't want to convert subclasses
@@ -259,6 +266,23 @@ class _unicode_func_wrapper(object):
 
 		return rval
 
+class _chown_func_wrapper(_unicode_func_wrapper):
+	"""
+	Compatibility workaround for Python 2.7.3 in Fedora 18, which throws
+	"TypeError: group id must be integer" if we try to pass an ObjectProxy
+	instance into chown.
+	"""
+
+	def _process_args(self, args, kwargs):
+
+		wrapped_args, wrapped_kwargs = \
+			_unicode_func_wrapper._process_args(self, args, kwargs)
+
+		for i in (1, 2):
+			wrapped_args[i] = int(wrapped_args[i])
+
+		return (wrapped_args, wrapped_kwargs)
+
 class _unicode_module_wrapper(object):
 	"""
 	Wraps a module and wraps all functions with _unicode_func_wrapper.
@@ -302,6 +326,7 @@ class _unicode_module_wrapper(object):
 
 import os as _os
 _os_overrides = {
+	id(_os.chown)         : _chown_func_wrapper(_os.chown),
 	id(_os.fdopen)        : _os.fdopen,
 	id(_os.popen)         : _os.popen,
 	id(_os.read)          : _os.read,

diff --git a/pym/portage/data.py b/pym/portage/data.py
index 29292f5..422dea2 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -1,5 +1,5 @@
 # data.py -- Calculated/Discovered Data Values
-# Copyright 1998-2012 Gentoo Foundation
+# Copyright 1998-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import os, pwd, grp, platform, sys
@@ -32,7 +32,7 @@ if not lchown:
 				" exist.  Please rebuild python.\n"), noiselevel=-1)
 		lchown()
 
-lchown = portage._unicode_func_wrapper(lchown)
+lchown = portage._chown_func_wrapper(lchown)
 
 def portage_group_warning():
 	warn_prefix = colorize("BAD", "*** WARNING ***  ")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-02-15 22:34 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-02-15 22:34 UTC (permalink / raw
  To: gentoo-commits

commit:     d6dd49ff7fd6308127474064bccec03b3442f9b5
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 15 22:34:36 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Feb 15 22:34:36 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d6dd49ff

abssymlink: clarify docs, bug #225821

---
 pym/portage/__init__.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index bc14bae..f326ecb 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -464,7 +464,15 @@ def getcwd():
 getcwd()
 
 def abssymlink(symlink, target=None):
-	"This reads symlinks, resolving the relative symlinks, and returning the absolute."
+	"""
+	This reads symlinks, resolving the relative symlinks,
+	and returning the absolute.
+	@param symlink: path of symlink (must be absolute)
+	@param target: the target of the symlink (as returned
+		by readlink)
+	@rtype: str
+	@return: the absolute path of the symlink target
+	"""
 	if target is not None:
 		mylink = target
 	else:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-02-17 22:13 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-02-17 22:13 UTC (permalink / raw
  To: gentoo-commits

commit:     2074371c6b3196c4158814587c2d996b281a7abf
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 17 22:12:29 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Feb 17 22:12:29 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2074371c

_exec: avoid UnicodeEncodeError for execve args

---
 pym/portage/process.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 89ebd05..f00775c 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -387,6 +387,10 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
 	myargs = [opt_name]
 	myargs.extend(mycommand[1:])
 
+	# Avoid a potential UnicodeEncodeError from os.execve().
+	myargs = [_unicode_encode(x, encoding=_encodings['fs'],
+		errors='strict') for x in myargs]
+
 	# Use default signal handlers in order to avoid problems
 	# killing subprocesses as reported in bug #353239.
 	signal.signal(signal.SIGINT, signal.SIG_DFL)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-03-17  3:35 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2013-03-17  3:35 UTC (permalink / raw
  To: gentoo-commits

commit:     5ce4a445532de6cb0dba9dbf66e4916cf7e3a68a
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sun Mar 17 03:29:26 2013 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Sun Mar 17 03:29:26 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5ce4a445

portage.update.update_config_files(): Add handling of:
/etc/portage/profile/packages
/etc/portage/profile/package.use.force
/etc/portage/profile/package.use.mask
/etc/portage/profile/package.use.stable.force
/etc/portage/profile/package.use.stable.mask

---
 pym/portage/update.py |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/pym/portage/update.py b/pym/portage/update.py
index 1b45a7a..6317d11 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -282,7 +282,7 @@ def parse_updates(mycontent):
 	return myupd, errors
 
 def update_config_files(config_root, protect, protect_mask, update_iter, match_callback = None):
-	"""Perform global updates on /etc/portage/package.*.
+	"""Perform global updates on /etc/portage/package.*, /etc/portage/profile/packages and /etc/portage/profile/package.*.
 	config_root - location of files to update
 	protect - list of paths from CONFIG_PROTECT
 	protect_mask - list of paths from CONFIG_PROTECT_MASK
@@ -307,7 +307,13 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c
 		"package.mask", "package.properties",
 		"package.unmask", "package.use"
 	]
-	myxfiles += [os.path.join("profile", x) for x in myxfiles]
+	myxfiles += [os.path.join("profile", x) for x in (
+		"packages", "package.accept_keywords",
+		"package.keywords", "package.mask",
+		"package.unmask", "package.use",
+		"package.use.force", "package.use.mask",
+		"package.use.stable.force", "package.use.stable.mask"
+	)]
 	abs_user_config = os.path.join(config_root, USER_CONFIG_PATH)
 	recursivefiles = []
 	for x in myxfiles:
@@ -356,7 +362,6 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c
 			if f is not None:
 				f.close()
 
-	# update /etc/portage/packages.*
 	ignore_line_re = re.compile(r'^#|^\s*$')
 	if repo_dict is None:
 		update_items = [(None, update_iter)]
@@ -376,6 +381,9 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c
 					if atom[:1] == "-":
 						# package.mask supports incrementals
 						atom = atom[1:]
+					if atom[:1] == "*":
+						# packages file supports "*"-prefixed atoms as indication of system packages.
+						atom = atom[1:]
 					if not isvalidatom(atom):
 						continue
 					new_atom = update_dbentry(update_cmd, atom)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-03-17  4:33 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2013-03-17  4:33 UTC (permalink / raw
  To: gentoo-commits

commit:     5262782740f61cc97d1e3269786465c314b2ecfc
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sun Mar 17 04:32:22 2013 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Sun Mar 17 04:32:22 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=52627827

portage.update.update_config_files(): Add handling of /etc/portage/sets.

---
 pym/portage/update.py |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/pym/portage/update.py b/pym/portage/update.py
index 6317d11..be52164 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -282,7 +282,8 @@ def parse_updates(mycontent):
 	return myupd, errors
 
 def update_config_files(config_root, protect, protect_mask, update_iter, match_callback = None):
-	"""Perform global updates on /etc/portage/package.*, /etc/portage/profile/packages and /etc/portage/profile/package.*.
+	"""Perform global updates on /etc/portage/package.*, /etc/portage/profile/package.*,
+	/etc/portage/profile/packages and /etc/portage/sets.
 	config_root - location of files to update
 	protect - list of paths from CONFIG_PROTECT
 	protect_mask - list of paths from CONFIG_PROTECT_MASK
@@ -305,7 +306,7 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c
 		"package.accept_keywords", "package.env",
 		"package.keywords", "package.license",
 		"package.mask", "package.properties",
-		"package.unmask", "package.use"
+		"package.unmask", "package.use", "sets"
 	]
 	myxfiles += [os.path.join("profile", x) for x in (
 		"packages", "package.accept_keywords",


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-03-19 21:57 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-03-19 21:57 UTC (permalink / raw
  To: gentoo-commits

commit:     ce4018f642cec0220ce26d57855754324cdd37fc
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 19 21:56:46 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Mar 19 21:56:46 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ce4018f6

manifest2MiscfileFilter: remove redundant checks

Checks for directory names are not needed since only regular files
are passed in here.

---
 pym/portage/manifest.py |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 5b40826..510e203 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -25,8 +25,7 @@ from portage.exception import DigestException, FileNotFound, \
 	InvalidDataType, MissingParameter, PermissionDenied, \
 	PortageException, PortagePackageException
 from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS,
-	MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH,
-	VCS_DIRS)
+	MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH)
 from portage.localization import _
 
 _manifest_re = re.compile(
@@ -53,8 +52,7 @@ def manifest2AuxfileFilter(filename):
 	return not filename[:7] == 'digest-'
 
 def manifest2MiscfileFilter(filename):
-	filename = filename.strip(os.sep)
-	return not (filename in VCS_DIRS + ("files", "Manifest") or filename.endswith(".ebuild"))
+	return not (filename == "Manifest" or filename.endswith(".ebuild"))
 
 def guessManifestFileType(filename):
 	""" Perform a best effort guess of which type the given filename is, avoid using this if possible """


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-03-22  1:42 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-03-22  1:42 UTC (permalink / raw
  To: gentoo-commits

commit:     ebd93103ea9ad9a95147f21faca01c5d6478eab8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 22 01:42:20 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Mar 22 01:42:20 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ebd93103

portage.const: realpath(__file__.rstrip("co"))

With python2.x, __file__ may refer to the compiled bytcode file, but we
want to follow the symlink of the uncompile py file.

---
 pym/portage/const.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 93556a0..5e960d9 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -60,7 +60,7 @@ GLOBAL_CONFIG_PATH       = "/usr/share/portage/config"
 # these variables are not used with target_root or config_root
 # NOTE: Use realpath(__file__) so that python module symlinks in site-packages
 # are followed back to the real location of the whole portage installation.
-PORTAGE_BASE_PATH        = os.path.join(os.sep, os.sep.join(os.path.realpath(__file__).split(os.sep)[:-3]))
+PORTAGE_BASE_PATH        = os.path.join(os.sep, os.sep.join(os.path.realpath(__file__.rstrip("co")).split(os.sep)[:-3]))
 PORTAGE_BIN_PATH         = PORTAGE_BASE_PATH + "/bin"
 PORTAGE_PYM_PATH         = PORTAGE_BASE_PATH + "/pym"
 LOCALE_DATA_PATH         = PORTAGE_BASE_PATH + "/locale"  # FIXME: not used


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-03-22 15:36 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-03-22 15:36 UTC (permalink / raw
  To: gentoo-commits

commit:     22846f84ec1a8daf6873c67224d78186be1ecce5
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 22 15:36:45 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Mar 22 15:36:45 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=22846f84

Handle ENOLCK with loop for bug #462694.

---
 pym/portage/locks.py |   40 ++++++++++++++++++++++++++++++++--------
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index ed9238d..4b860ac 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -148,7 +148,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 	except IOError as e:
 		if not hasattr(e, "errno"):
 			raise
-		if e.errno in (errno.EACCES, errno.EAGAIN):
+		if e.errno in (errno.EACCES, errno.EAGAIN, errno.ENOLCK):
 			# resource temp unavailable; eg, someone beat us to the lock.
 			if flags & os.O_NONBLOCK:
 				os.close(myfd)
@@ -167,15 +167,39 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 			if out is not None:
 				out.ebegin(waiting_msg)
 			# try for the exclusive lock now.
-			try:
-				locking_method(myfd, fcntl.LOCK_EX)
-			except EnvironmentError as e:
-				if out is not None:
-					out.eend(1, str(e))
-				raise
+			enolock_msg_shown = False
+			while True:
+				try:
+					locking_method(myfd, fcntl.LOCK_EX)
+				except EnvironmentError as e:
+					if e.errno == errno.ENOLCK:
+						# This is known to occur on Solaris NFS (see
+						# bug #462694). Assume that the error is due
+						# to temporary exhaustion of record locks,
+						# and loop until one becomes available.
+						if not enolock_msg_shown:
+							enolock_msg_shown = True
+							if isinstance(mypath, int):
+								context_desc = _("Error while waiting "
+									"to lock fd %i") % myfd
+							else:
+								context_desc = _("Error while waiting "
+									"to lock '%s'") % lockfilename
+							writemsg("\n!!! %s: %s\n" % (context_desc, e),
+								noiselevel=-1)
+
+						time.sleep(_HARDLINK_POLL_LATENCY)
+						continue
+
+					if out is not None:
+						out.eend(1, str(e))
+					raise
+				else:
+					break
+
 			if out is not None:
 				out.eend(os.EX_OK)
-		elif e.errno in (errno.ENOSYS, errno.ENOLCK):
+		elif e.errno in (errno.ENOSYS,):
 			# We're not allowed to lock on this FS.
 			if not isinstance(lockfilename, int):
 				# If a file object was passed in, it's not safe


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-03-22 15:42 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-03-22 15:42 UTC (permalink / raw
  To: gentoo-commits

commit:     6c8f821528155d9771f91b6f4190bc98371805ef
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 22 15:42:23 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Mar 22 15:42:23 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6c8f8215

lockfile: remove newline from ebegin message

---
 pym/portage/locks.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 4b860ac..71bce30 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -163,7 +163,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 				if isinstance(mypath, int):
 					waiting_msg = _("waiting for lock on fd %i") % myfd
 				else:
-					waiting_msg = _("waiting for lock on %s\n") % lockfilename
+					waiting_msg = _("waiting for lock on %s") % lockfilename
 			if out is not None:
 				out.ebegin(waiting_msg)
 			# try for the exclusive lock now.


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-04-28 22:42 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-04-28 22:42 UTC (permalink / raw
  To: gentoo-commits

commit:     154e490e5064733a139eae72ed37192016dcb52f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 28 22:39:24 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Apr 28 22:39:24 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=154e490e

get_open_fds: use /dev/fd or /proc/self/fd

Since /dev/fd is supposed to be a fairly standard unix feature, try
that first.

---
 pym/portage/process.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index f00775c..24e347c 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -30,10 +30,15 @@ except ImportError:
 if sys.hexversion >= 0x3000000:
 	basestring = str
 
-if os.path.isdir("/proc/%i/fd" % os.getpid()):
+for _fd_dir in ("/dev/fd", "/proc/self/fd"):
+	if os.path.isdir(_fd_dir):
+		break
+	else:
+		_fd_dir = None
+
+if _fd_dir is not None:
 	def get_open_fds():
-		return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) \
-			if fd.isdigit())
+		return (int(fd) for fd in os.listdir(_fd_dir) if fd.isdigit())
 
 	if platform.python_implementation() == 'PyPy':
 		# EAGAIN observed with PyPy 1.8.


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-06-22 17:49 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-06-22 17:49 UTC (permalink / raw
  To: gentoo-commits

commit:     30fe6f117ce0350c6b6d1279bae63508a8abbf59
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 17:49:36 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jun 22 17:49:36 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=30fe6f11

find_binary: return bytes when input is bytes

---
 pym/portage/process.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 24e347c..7104552 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -9,6 +9,7 @@ import platform
 import signal
 import sys
 import traceback
+import os as _os
 
 from portage import os
 from portage import _encodings
@@ -520,8 +521,16 @@ def find_binary(binary):
 	@rtype: None or string
 	@return: full path to binary or None if the binary could not be located.
 	"""
-	for path in os.environ.get("PATH", "").split(":"):
-		filename = "%s/%s" % (path, binary)
-		if os.access(filename, os.X_OK) and os.path.isfile(filename):
+	paths = os.environ.get("PATH", "")
+	if sys.hexversion >= 0x3000000 and isinstance(binary, bytes):
+		# return bytes when input is bytes
+		paths = paths.encode(sys.getfilesystemencoding(), 'surrogateescape')
+		paths = paths.split(b':')
+	else:
+		paths = paths.split(':')
+
+	for path in paths:
+		filename = _os.path.join(path, binary)
+		if _os.access(filename, os.X_OK) and _os.path.isfile(filename):
 			return filename
 	return None


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-07-13  9:24 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2013-07-13  9:24 UTC (permalink / raw
  To: gentoo-commits

commit:     527c61310361463b02340b7ddc376c5d61594104
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sat Jul 13 09:23:32 2013 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Sat Jul 13 09:23:32 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=527c6131

Set portage._working_copy bool variable.

---
 pym/portage/__init__.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 85be13e..35bf152 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -386,6 +386,7 @@ except (ImportError, OSError) as e:
 _python_interpreter = os.path.realpath(sys.executable)
 _bin_path = PORTAGE_BIN_PATH
 _pym_path = PORTAGE_PYM_PATH
+_working_copy = VERSION == "HEAD"
 
 # Api consumers included in portage should set this to True.
 _internal_caller = False


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-07-29 18:40 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-07-29 18:40 UTC (permalink / raw
  To: gentoo-commits

commit:     ffc50e4d32706b8962d66cadd21fcd1d0cd58f13
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 29 18:39:49 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 29 18:39:49 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ffc50e4d

FreeBSD: don't use /dev/fd, bug #478446

---
 pym/portage/process.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 728a01d..92f2aba 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -39,6 +39,10 @@ for _fd_dir in ("/proc/self/fd", "/dev/fd"):
 	else:
 		_fd_dir = None
 
+# /dev/fd does not work on FreeBSD, see bug #478446
+if platform.system() in ('FreeBSD',) and _fd_dir == '/dev/fd':
+	_fd_dir = None
+
 if _fd_dir is not None:
 	def get_open_fds():
 		return (int(fd) for fd in os.listdir(_fd_dir) if fd.isdigit())


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-08-18  6:04 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-08-18  6:04 UTC (permalink / raw
  To: gentoo-commits

commit:     e1e256c85dfa3bd4e8b3564fb1391ca0f3d277a4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 18 06:03:47 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Aug 18 06:03:47 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e1e256c8

_exec: close socket

---
 pym/portage/process.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index a7464c7..6a60dec 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -455,6 +455,7 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
 							writemsg("Unable to enable loopback interface: %s\n" % (
 								errno.errorcode.get(e.errno, '?')),
 								noiselevel=-1)
+						sock.close()
 				except AttributeError:
 					# unshare() not supported by libc
 					pass


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-09-01 20:55 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-09-01 20:55 UTC (permalink / raw
  To: gentoo-commits

commit:     850b1c33a04b734d143df3474568cf07e77b4411
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Sep  1 20:23:50 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Sep  1 20:54:43 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=850b1c33

_setup_pipes: os.set_inheritable() for Python 3.4

---
 pym/portage/process.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 20ef97d..3ec6d70 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -437,7 +437,7 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
 	# the parent process (see bug #289486).
 	signal.signal(signal.SIGQUIT, signal.SIG_DFL)
 
-	_setup_pipes(fd_pipes, close_fds=close_fds)
+	_setup_pipes(fd_pipes, close_fds=close_fds, inheritable=True)
 
 	# Add to cgroup
 	# it's better to do it from the child since we can guarantee
@@ -502,7 +502,7 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
 	# And switch to the new process.
 	os.execve(binary, myargs, env)
 
-def _setup_pipes(fd_pipes, close_fds=True):
+def _setup_pipes(fd_pipes, close_fds=True, inheritable=None):
 	"""Setup pipes for a forked process.
 
 	Even when close_fds is False, file descriptors referenced as
@@ -538,6 +538,13 @@ def _setup_pipes(fd_pipes, close_fds=True):
 	actually does nothing in this case), which avoids possible
 	interference.
 	"""
+
+	# Support PEP 446 for Python >=3.4
+	try:
+		set_inheritable = _os.set_inheritable
+	except AttributeError:
+		set_inheritable = None
+
 	reverse_map = {}
 	# To protect from cases where direct assignment could
 	# clobber needed fds ({1:2, 2:1}) we create a reverse map
@@ -570,6 +577,12 @@ def _setup_pipes(fd_pipes, close_fds=True):
 			if oldfd != newfd:
 				os.dup2(oldfd, newfd)
 
+			if set_inheritable is not None:
+				if inheritable is not None:
+					set_inheritable(newfd, inheritable)
+				elif newfd in (0, 1, 2):
+					set_inheritable(newfd, True)
+
 		if oldfd not in fd_pipes:
 			# If oldfd is not a key in fd_pipes, then it's safe
 			# to close now, since we've already made all of the


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-09-01 23:57 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-09-01 23:57 UTC (permalink / raw
  To: gentoo-commits

commit:     bd2128b7a750a68470f857162784e55b8ac39de2
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Sep  1 23:57:02 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Sep  1 23:57:02 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=bd2128b7

_setup_pipes: copy descriptor flags after dup2

---
 pym/portage/process.py | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 3ec6d70..2a2fcac 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -35,6 +35,17 @@ except ImportError:
 if sys.hexversion >= 0x3000000:
 	basestring = str
 
+# Support PEP 446 for Python >=3.4
+try:
+	_set_inheritable = _os.set_inheritable
+except AttributeError:
+	_set_inheritable = None
+
+try:
+	_FD_CLOEXEC = fcntl.FD_CLOEXEC
+except AttributeError:
+	_FD_CLOEXEC = None
+
 # Prefer /proc/self/fd if available (/dev/fd
 # doesn't work on solaris, see bug #474536).
 for _fd_dir in ("/proc/self/fd", "/dev/fd"):
@@ -539,12 +550,6 @@ def _setup_pipes(fd_pipes, close_fds=True, inheritable=None):
 	interference.
 	"""
 
-	# Support PEP 446 for Python >=3.4
-	try:
-		set_inheritable = _os.set_inheritable
-	except AttributeError:
-		set_inheritable = None
-
 	reverse_map = {}
 	# To protect from cases where direct assignment could
 	# clobber needed fds ({1:2, 2:1}) we create a reverse map
@@ -564,6 +569,7 @@ def _setup_pipes(fd_pipes, close_fds=True, inheritable=None):
 	while reverse_map:
 
 		oldfd, newfds = reverse_map.popitem()
+		old_fdflags = None
 
 		for newfd in newfds:
 			if newfd in reverse_map:
@@ -574,14 +580,26 @@ def _setup_pipes(fd_pipes, close_fds=True, inheritable=None):
 				# unused file discriptors).
 				backup_fd = os.dup(newfd)
 				reverse_map[backup_fd] = reverse_map.pop(newfd)
+
 			if oldfd != newfd:
 				os.dup2(oldfd, newfd)
+				if old_fdflags is None:
+					old_fdflags = fcntl.fcntl(oldfd, fcntl.F_GETFD)
+				fcntl.fcntl(newfd, fcntl.F_SETFD, old_fdflags)
+
+			if _set_inheritable is not None:
+
+				inheritable_state = None
+				if not (old_fdflags is None or _FD_CLOEXEC is None):
+					inheritable_state = not bool(old_fdflags & _FD_CLOEXEC)
 
-			if set_inheritable is not None:
 				if inheritable is not None:
-					set_inheritable(newfd, inheritable)
+					if inheritable_state is not inheritable:
+						_set_inheritable(newfd, inheritable)
+
 				elif newfd in (0, 1, 2):
-					set_inheritable(newfd, True)
+					if inheritable_state is not True:
+						_set_inheritable(newfd, True)
 
 		if oldfd not in fd_pipes:
 			# If oldfd is not a key in fd_pipes, then it's safe


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-09-02  0:55 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2013-09-02  0:55 UTC (permalink / raw
  To: gentoo-commits

commit:     617c0ebf31f09e424442e0bc2e7e5b1c6407a056
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Sep  2 00:55:21 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Sep  2 00:55:21 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=617c0ebf

_setup_pipes: fix for Python 3.1 to 3.3

This fixes a case where /dev/null stdin fails to inherit since commit
bd2128b7a750a68470f857162784e55b8ac39de2.

---
 pym/portage/process.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index 2a2fcac..9ae7a55 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -583,9 +583,14 @@ def _setup_pipes(fd_pipes, close_fds=True, inheritable=None):
 
 			if oldfd != newfd:
 				os.dup2(oldfd, newfd)
-				if old_fdflags is None:
-					old_fdflags = fcntl.fcntl(oldfd, fcntl.F_GETFD)
-				fcntl.fcntl(newfd, fcntl.F_SETFD, old_fdflags)
+				if _set_inheritable is not None:
+					# Don't do this unless _set_inheritable is available,
+					# since it's used below to ensure correct state, and
+					# otherwise /dev/null stdin fails to inherit (at least
+					# with Python versions from 3.1 to 3.3).
+					if old_fdflags is None:
+						old_fdflags = fcntl.fcntl(oldfd, fcntl.F_GETFD)
+					fcntl.fcntl(newfd, fcntl.F_SETFD, old_fdflags)
 
 			if _set_inheritable is not None:
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-11-30  5:35 Mike Frysinger
  0 siblings, 0 replies; 248+ messages in thread
From: Mike Frysinger @ 2013-11-30  5:35 UTC (permalink / raw
  To: gentoo-commits

commit:     55740921ed61c5cf23cefe819bf4997f10574bbf
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 30 05:35:35 2013 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 30 05:35:35 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=55740921

portage.const: tweak style

Makes pylint happy, and makes the code much easier to modify.

---
 pym/portage/const.py | 147 ++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 111 insertions(+), 36 deletions(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index e51bd3f..a19728b 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -60,7 +60,8 @@ GLOBAL_CONFIG_PATH       = "/usr/share/portage/config"
 # these variables are not used with target_root or config_root
 # NOTE: Use realpath(__file__) so that python module symlinks in site-packages
 # are followed back to the real location of the whole portage installation.
-PORTAGE_BASE_PATH        = os.path.join(os.sep, os.sep.join(os.path.realpath(__file__.rstrip("co")).split(os.sep)[:-3]))
+PORTAGE_BASE_PATH        = os.path.join(os.sep, os.sep.join(os.path.realpath(
+                               __file__.rstrip("co")).split(os.sep)[:-3]))
 PORTAGE_BIN_PATH         = PORTAGE_BASE_PATH + "/bin"
 PORTAGE_PYM_PATH         = PORTAGE_BASE_PATH + "/pym"
 LOCALE_DATA_PATH         = PORTAGE_BASE_PATH + "/locale"  # FIXME: not used
@@ -83,41 +84,115 @@ CVS_PACKAGE_ATOM         = "dev-vcs/cvs"
 GIT_PACKAGE_ATOM         = "dev-vcs/git"
 RSYNC_PACKAGE_ATOM       = "net-misc/rsync"
 
-INCREMENTALS             = ("USE", "USE_EXPAND", "USE_EXPAND_HIDDEN",
-                           "FEATURES", "ACCEPT_KEYWORDS",
-                           "CONFIG_PROTECT_MASK", "CONFIG_PROTECT",
-                           "IUSE_IMPLICIT",
-                           "PRELINK_PATH", "PRELINK_PATH_MASK",
-                           "PROFILE_ONLY_VARIABLES",
-                           "USE_EXPAND_IMPLICIT", "USE_EXPAND_UNPREFIXED")
-EBUILD_PHASES            = ("pretend", "setup", "unpack", "prepare", "configure",
-                           "compile", "test", "install",
-                           "package", "preinst", "postinst","prerm", "postrm",
-                           "nofetch", "config", "info", "other")
+INCREMENTALS             = (
+	"ACCEPT_KEYWORDS",
+	"CONFIG_PROTECT",
+	"CONFIG_PROTECT_MASK",
+	"FEATURES",
+	"IUSE_IMPLICIT",
+	"PRELINK_PATH",
+	"PRELINK_PATH_MASK",
+	"PROFILE_ONLY_VARIABLES",
+	"USE",
+	"USE_EXPAND",
+	"USE_EXPAND_HIDDEN",
+	"USE_EXPAND_IMPLICIT",
+	"USE_EXPAND_UNPREFIXED",
+)
+EBUILD_PHASES            = (
+	"pretend",
+	"setup",
+	"unpack",
+	"prepare",
+	"configure",
+	"compile",
+	"test",
+	"install",
+	"package",
+	"preinst",
+	"postinst",
+	"prerm",
+	"postrm",
+	"nofetch",
+	"config",
+	"info",
+	"other",
+)
 SUPPORTED_FEATURES       = frozenset([
-                           "assume-digests", "binpkg-logs", "buildpkg", "buildsyspkg", "candy",
-                           "ccache", "cgroup", "chflags", "clean-logs",
-                           "collision-protect", "compress-build-logs", "compressdebug",
-                           "compress-index", "config-protect-if-modified",
-                           "digest", "distcc", "distcc-pump", "distlocks",
-                           "downgrade-backup", "ebuild-locks", "fakeroot",
-                           "fail-clean", "force-mirror", "force-prefix", "getbinpkg",
-                           "installsources", "ipc-sandbox",
-                           "keeptemp", "keepwork", "fixlafiles", "lmirror",
-                           "merge-sync",
-                           "metadata-transfer", "mirror", "multilib-strict",
-                           "network-sandbox", "news",
-                           "noauto", "noclean", "nodoc", "noinfo", "noman",
-                           "nostrip", "notitles", "parallel-fetch", "parallel-install",
-                           "prelink-checksums", "preserve-libs",
-                           "protect-owned", "python-trace", "sandbox",
-                           "selinux", "sesandbox", "sfperms",
-                           "sign", "skiprocheck", "split-elog", "split-log", "splitdebug",
-                           "strict", "stricter", "suidctl", "test", "test-fail-continue",
-                           "unknown-features-filter", "unknown-features-warn",
-                           "unmerge-backup",
-                           "unmerge-logs", "unmerge-orphans", "userfetch", "userpriv",
-                           "usersandbox", "usersync", "webrsync-gpg", "xattr"])
+	"assume-digests",
+	"binpkg-logs",
+	"buildpkg",
+	"buildsyspkg",
+	"candy",
+	"ccache",
+	"cgroup",
+	"chflags",
+	"clean-logs",
+	"collision-protect",
+	"compress-build-logs",
+	"compressdebug",
+	"compress-index",
+	"config-protect-if-modified",
+	"digest",
+	"distcc",
+	"distcc-pump",
+	"distlocks",
+	"downgrade-backup",
+	"ebuild-locks",
+	"fail-clean",
+	"fakeroot",
+	"fixlafiles",
+	"force-mirror",
+	"force-prefix",
+	"getbinpkg",
+	"installsources",
+	"ipc-sandbox",
+	"keeptemp",
+	"keepwork",
+	"lmirror",
+	"metadata-transfer",
+	"mirror",
+	"multilib-strict",
+	"network-sandbox",
+	"news",
+	"noauto",
+	"noclean",
+	"nodoc",
+	"noinfo",
+	"noman",
+	"nostrip",
+	"notitles",
+	"parallel-fetch",
+	"parallel-install",
+	"prelink-checksums",
+	"preserve-libs",
+	"protect-owned",
+	"python-trace",
+	"sandbox",
+	"selinux",
+	"sesandbox",
+	"sfperms",
+	"sign",
+	"skiprocheck",
+	"splitdebug",
+	"split-elog",
+	"split-log",
+	"strict",
+	"stricter",
+	"suidctl",
+	"test",
+	"test-fail-continue",
+	"unknown-features-filter",
+	"unknown-features-warn",
+	"unmerge-logs",
+	"unmerge-orphans",
+	"userfetch",
+	"userpriv",
+	"usersandbox",
+	"usersync",
+	"webrsync-gpg",
+	"xattr",
+])
 
 EAPI                     = 5
 
@@ -162,7 +237,7 @@ MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")
 # a config instance (since it's possible to contruct a config instance with
 # a different EPREFIX). Therefore, the EPREFIX constant should *NOT* be used
 # in the definition of any other constants within this file.
-EPREFIX=""
+EPREFIX = ""
 
 # pick up EPREFIX from the environment if set
 if "PORTAGE_OVERRIDE_EPREFIX" in os.environ:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2013-11-30 18:15 Mike Frysinger
  0 siblings, 0 replies; 248+ messages in thread
From: Mike Frysinger @ 2013-11-30 18:15 UTC (permalink / raw
  To: gentoo-commits

commit:     86efbac7054388819a873ee8783439ca1226c5e8
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 30 18:15:33 2013 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 30 18:15:33 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=86efbac7

portage.const: restore two dropped features

The script used to clean this up accidentally dropped two features.

Reported-by: Sebastian Luther <SebastianLuther <AT> gmx.de>

---
 pym/portage/const.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index a19728b..1785bff 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -150,6 +150,7 @@ SUPPORTED_FEATURES       = frozenset([
 	"keeptemp",
 	"keepwork",
 	"lmirror",
+	"merge-sync",
 	"metadata-transfer",
 	"mirror",
 	"multilib-strict",
@@ -184,6 +185,7 @@ SUPPORTED_FEATURES       = frozenset([
 	"test-fail-continue",
 	"unknown-features-filter",
 	"unknown-features-warn",
+	"unmerge-backup",
 	"unmerge-logs",
 	"unmerge-orphans",
 	"userfetch",


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-01-02 22:53 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2014-01-02 22:53 UTC (permalink / raw
  To: gentoo-commits

commit:     a01ac6b7baef29a30cabb08ea619c9c0948df4d6
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Thu Jan  2 22:52:29 2014 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
CommitDate: Thu Jan  2 22:52:29 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a01ac6b7

portage.exception.PortageException: Improve performance (at least with Python 3).

---
 pym/portage/exception.py | 45 +++++++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 5ccd750..1388c49 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2011 Gentoo Foundation
+# Copyright 1998-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import signal
@@ -11,26 +11,35 @@ if sys.hexversion >= 0x3000000:
 
 class PortageException(Exception):
 	"""General superclass for portage exceptions"""
-	def __init__(self,value):
-		self.value = value[:]
-		if isinstance(self.value, basestring):
-			self.value = _unicode_decode(self.value,
-				encoding=_encodings['content'], errors='replace')
+	if sys.hexversion >= 0x3000000:
+		def __init__(self,value):
+			self.value = value[:]
 
-	def __str__(self):
-		if isinstance(self.value, basestring):
-			return self.value
-		else:
-			return _unicode_decode(repr(self.value),
-				encoding=_encodings['content'], errors='replace')
-
-	if sys.hexversion < 0x3000000:
-
-		__unicode__ = __str__
+		def __str__(self):
+			if isinstance(self.value, str):
+				return self.value
+			else:
+				return repr(self.value)
+	else:
+		def __init__(self,value):
+			self.value = value[:]
+			if isinstance(self.value, basestring):
+				self.value = _unicode_decode(self.value,
+					encoding=_encodings['content'], errors='replace')
+
+		def __unicode__(self):
+			if isinstance(self.value, unicode):
+				return self.value
+			else:
+				return _unicode_decode(repr(self.value),
+					encoding=_encodings['content'], errors='replace')
 
 		def __str__(self):
-			return _unicode_encode(self.__unicode__(),
-				encoding=_encodings['content'], errors='backslashreplace')
+			if isinstance(self.value, unicode):
+				return _unicode_encode(self.value,
+					encoding=_encodings['content'], errors='backslashreplace')
+			else:
+				return repr(self.value)
 
 class CorruptionError(PortageException):
 	"""Corruption indication"""


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-01-07 23:42 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2014-01-07 23:42 UTC (permalink / raw
  To: gentoo-commits

commit:     3a2a504777054e69efb705afa94d8584105d9604
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Tue Jan  7 23:40:39 2014 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
CommitDate: Tue Jan  7 23:40:39 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3a2a5047

portage.versions.ververify(): Return an instance of bool (which is a subclass of int anyway) for better __repr__.

---
 pym/portage/versions.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index 3bfc388..615d522 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -1,5 +1,5 @@
 # versions.py -- core Portage functionality
-# Copyright 1998-2013 Gentoo Foundation
+# Copyright 1998-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
@@ -109,11 +109,11 @@ def _get_pv_re(eapi_attrs):
 
 def ververify(myver, silent=1):
 	if ver_regexp.match(myver):
-		return 1
+		return True
 	else:
 		if not silent:
 			print(_("!!! syntax error in version: %s") % myver)
-		return 0
+		return False
 
 def vercmp(ver1, ver2, silent=1):
 	"""


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-01-19  8:45 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 248+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2014-01-19  8:45 UTC (permalink / raw
  To: gentoo-commits

commit:     8055cf4272b55262e26d3fcd96ef0402c7a48456
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sun Jan 19 08:42:08 2014 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> apache <DOT> org>
CommitDate: Sun Jan 19 08:42:08 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8055cf42

portage.eclass_cache.cache.__init__(): Deprecate overlays parameter.
(This parameter has been unused in Portage since commit 2bd2620142d15344f32ef67896c4fa88e5386953.)

---
 pym/portage/eclass_cache.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py
index 8c209c8..e1778f7 100644
--- a/pym/portage/eclass_cache.py
+++ b/pym/portage/eclass_cache.py
@@ -1,4 +1,4 @@
-# Copyright 2005-2013 Gentoo Foundation
+# Copyright 2005-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # Author(s): Nicholas Carpaski (carpaski@gentoo.org), Brian Harring (ferringb@gentoo.org)
 
@@ -9,6 +9,7 @@ __all__ = ["cache"]
 import stat
 import sys
 import operator
+import warnings
 from portage.util import normalize_path
 import errno
 from portage.exception import FileNotFound, PermissionDenied
@@ -59,7 +60,10 @@ class cache(object):
 	"""
 	Maintains the cache information about eclasses used in ebuild.
 	"""
-	def __init__(self, porttree_root, overlays=[]):
+	def __init__(self, porttree_root, overlays=None):
+		if overlays is not None:
+			warnings.warn("overlays parameter of portage.eclass_cache.cache constructor is deprecated and no longer used",
+			DeprecationWarning, stacklevel=2)
 
 		self.eclasses = {} # {"Name": hashed_path}
 		self._eclass_locations = {}
@@ -69,8 +73,7 @@ class cache(object):
 		# ~harring
 		if porttree_root:
 			self.porttree_root = porttree_root
-			self.porttrees = [self.porttree_root] + overlays
-			self.porttrees = tuple(map(normalize_path, self.porttrees))
+			self.porttrees = (normalize_path(self.porttree_root),)
 			self._master_eclass_root = os.path.join(self.porttrees[0], "eclass")
 			self.update_eclasses()
 		else:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-02-04  2:53 Mike Frysinger
  0 siblings, 0 replies; 248+ messages in thread
From: Mike Frysinger @ 2014-02-04  2:53 UTC (permalink / raw
  To: gentoo-commits

commit:     ad8c10bccb3ba732692579ff004346abf3a4ef45
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Feb  3 19:35:02 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Feb  3 19:35:02 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ad8c10bc

_do_global_updates: unify duplicated message header

---
 pym/portage/_global_updates.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/pym/portage/_global_updates.py b/pym/portage/_global_updates.py
index 9ae734b..8ab6bf8 100644
--- a/pym/portage/_global_updates.py
+++ b/pym/portage/_global_updates.py
@@ -86,14 +86,10 @@ def _do_global_updates(trees, prev_mtimes, quiet=False, if_mtime_changed=True):
 				if not update_notice_printed:
 					update_notice_printed = True
 					writemsg_stdout("\n")
-					if quiet:
-						writemsg_stdout(colorize("GOOD",
-							_("Performing Global Updates\n")))
-						writemsg_stdout(_("(Could take a couple of minutes if you have a lot of binary packages.)\n"))
-					else:
-						writemsg_stdout(colorize("GOOD",
-							_("Performing Global Updates:\n")))
-						writemsg_stdout(_("(Could take a couple of minutes if you have a lot of binary packages.)\n"))
+					writemsg_stdout(colorize("GOOD",
+						_("Performing Global Updates\n")))
+					writemsg_stdout(_("(Could take a couple of minutes if you have a lot of binary packages.)\n"))
+					if not quiet:
 						writemsg_stdout(_("  %s='update pass'  %s='binary update'  "
 							"%s='/var/db update'  %s='/var/db move'\n"
 							"  %s='/var/db SLOT move'  %s='binary move'  "


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-04-05 20:44 Sebastian Luther
  0 siblings, 0 replies; 248+ messages in thread
From: Sebastian Luther @ 2014-04-05 20:44 UTC (permalink / raw
  To: gentoo-commits

commit:     9c0c186905469884f38801a2afaa1586b7ddd806
Author:     Sebastian Luther <SebastianLuther <AT> gmx <DOT> de>
AuthorDate: Sat Apr  5 20:43:52 2014 +0000
Commit:     Sebastian Luther <SebastianLuther <AT> gmx <DOT> de >
CommitDate: Sat Apr  5 20:43:52 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9c0c1869

Fix crash with @security (bug 488820)

---
 pym/portage/glsa.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 834572a..1b19fb1 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -394,6 +394,7 @@ def getMinUpgrade(vulnerableList, unaffectedList, portdbapi, vardbapi, minimize=
 				update = c_pv[0]+"/"+c_pv[1]+"-"+c_pv[2]
 				if c_pv[3] != "r0":		# we don't like -r0 for display
 					update += "-"+c_pv[3]
+				update = portdbapi._pkg_str(update, None)
 		vuln_update.append([vuln, update])
 
 	return vuln_update


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-06-12 15:47 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2014-06-12 15:47 UTC (permalink / raw
  To: gentoo-commits

commit:     f55ab6a98e4042f570a8a56b13926fef66cbf22b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 12 15:45:30 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 15:45:56 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f55ab6a9

portage/dispatch_conf.py: Fix bug 512690

This bug happened when a /etc/portage/package.* file was changed into a directory.
  File "/usr/lib64/portage/pym/portage/dispatch_conf.py", line 210, in file_archive_post_process
    os.rename(archive + '.dist.new', archive + '.dist')
NotADirectoryError: [Errno 20] Not a directory: '/etc/config-archive/etc/portage/package.unmask/unmask.dist'

---
 pym/portage/dispatch_conf.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index f975ccd..113d965 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -207,4 +207,5 @@ def rcs_archive_post_process(archive):
 
 def file_archive_post_process(archive):
 	"""Rename the archive file with the .dist.new suffix to a .dist suffix"""
-	os.rename(archive + '.dist.new', archive + '.dist')
+	if os.path.exists(archive + '.dist.new'):
+		os.rename(archive + '.dist.new', archive + '.dist')


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
  2014-08-19  7:01 Michał Górny
@ 2014-08-06 20:54 ` Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2014-08-06 20:54 UTC (permalink / raw
  To: gentoo-commits

commit:     b316391ba0eface61fea6a0615f74738ad36b886
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  6 16:32:17 2014 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug  6 20:52:47 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b316391b

localization: properly decode formatted number for localized_size().

Fixes: https://bugs.gentoo.org/show_bug.cgi?id=519124

---
 pym/portage/localization.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pym/portage/localization.py b/pym/portage/localization.py
index e4d87b6..7d30b59 100644
--- a/pym/portage/localization.py
+++ b/pym/portage/localization.py
@@ -5,7 +5,7 @@
 import locale
 import math
 
-from portage import _unicode_decode
+from portage import _encodings, _unicode_decode
 
 # We define this to make the transition easier for us.
 def _(mystr):
@@ -36,4 +36,5 @@ def localized_size(num_bytes):
 
 	# always round up, so that small files don't end up as '0 KiB'
 	num_kib = math.ceil(num_bytes / 1024)
-	return locale.format('%d', num_kib, grouping=True) + ' KiB'
+	formatted_num = locale.format('%d', num_kib, grouping=True)
+	return (_unicode_decode(formatted_num, encoding=_encodings['stdio']) + ' KiB')


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-08-19  7:01 Michał Górny
  2014-08-06 20:54 ` Michał Górny
  0 siblings, 1 reply; 248+ messages in thread
From: Michał Górny @ 2014-08-19  7:01 UTC (permalink / raw
  To: gentoo-commits

commit:     b316391ba0eface61fea6a0615f74738ad36b886
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  6 16:32:17 2014 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug  6 20:52:47 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b316391b

localization: properly decode formatted number for localized_size().

Fixes: https://bugs.gentoo.org/show_bug.cgi?id=519124

---
 pym/portage/localization.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pym/portage/localization.py b/pym/portage/localization.py
index e4d87b6..7d30b59 100644
--- a/pym/portage/localization.py
+++ b/pym/portage/localization.py
@@ -5,7 +5,7 @@
 import locale
 import math
 
-from portage import _unicode_decode
+from portage import _encodings, _unicode_decode
 
 # We define this to make the transition easier for us.
 def _(mystr):
@@ -36,4 +36,5 @@ def localized_size(num_bytes):
 
 	# always round up, so that small files don't end up as '0 KiB'
 	num_kib = math.ceil(num_bytes / 1024)
-	return locale.format('%d', num_kib, grouping=True) + ' KiB'
+	formatted_num = locale.format('%d', num_kib, grouping=True)
+	return (_unicode_decode(formatted_num, encoding=_encodings['stdio']) + ' KiB')


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-09-11 23:04 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2014-09-11 23:04 UTC (permalink / raw
  To: gentoo-commits

commit:     7204b87040edfcf0924f2d3647d5a00e1de7a170
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 11 22:51:21 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 23:01:14 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7204b870

portage/mail.py: Make email date, timestamp RFC-compliant Bug 520752

Apply patch from Florent Bondoux f.bondoux <AT> free.fr
Remove no longer used time import.
Wrap the fromatedate() call with _unicode_encode() to prevent any encoding issues.

X-Gentoo-Bug: 520752
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=520752
Reviewed-by: Zac Medico

---
 pym/portage/mail.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/pym/portage/mail.py b/pym/portage/mail.py
index 723da04..2efcbba 100644
--- a/pym/portage/mail.py
+++ b/pym/portage/mail.py
@@ -12,7 +12,6 @@
 
 import socket
 import sys
-import time
 
 from portage import os
 from portage import _encodings
@@ -49,6 +48,7 @@ def create_message(sender, recipient, subject, body, attachments=None):
 	from email.header import Header
 	from email.mime.base import MIMEBase as BaseMessage
 	from email.mime.multipart import MIMEMultipart as MultipartMessage
+	from email.utils import formatdate
 
 	if sys.hexversion < 0x3000000:
 		sender = _unicode_encode(sender,
@@ -91,8 +91,9 @@ def create_message(sender, recipient, subject, body, attachments=None):
 	#    input_bytes = s.encode(input_charset, errors)
 	#UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-9: ordinal not in range(128)
 	mymessage["Subject"] = Header(_force_ascii_if_necessary(subject))
-	mymessage["Date"] = time.strftime("%a, %d %b %Y %H:%M:%S %z")
-	
+	mymessage["Date"] = _unicode_encode(formatdate(localtime=True),
+		encoding=_encodings['content'], errors='backslashreplace')
+
 	return mymessage
 
 def send_mail(mysettings, message):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-09-11 23:04 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2014-09-11 23:04 UTC (permalink / raw
  To: gentoo-commits

commit:     f144a470f67a00506dcd33eb2c8f5b444e6860d3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 11 22:52:12 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 23:01:31 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f144a470

portage/mail.py: Whitespace cleanup

---
 pym/portage/mail.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/portage/mail.py b/pym/portage/mail.py
index 2efcbba..945cccd 100644
--- a/pym/portage/mail.py
+++ b/pym/portage/mail.py
@@ -105,7 +105,7 @@ def send_mail(mysettings, message):
 	mymailuser = ""
 	mymailpasswd = ""
 	myrecipient = "root@localhost"
-	
+
 	# Syntax for PORTAGE_ELOG_MAILURI (if defined):
 	# address [[user:passwd@]mailserver[:port]]
 	# where address:    recipient address
@@ -130,7 +130,7 @@ def send_mail(mysettings, message):
 			mymailhost = myconndata
 	else:
 		myrecipient = mysettings.get("PORTAGE_ELOG_MAILURI", "")
-	
+
 	myfrom = message.get("From")
 
 	if sys.hexversion < 0x3000000:
@@ -175,4 +175,4 @@ def send_mail(mysettings, message):
 		except socket.error as e:
 			raise portage.exception.PortageException(_("!!! A network error occurred while trying to send logmail:\n%s\nSure you configured PORTAGE_ELOG_MAILURI correctly?") % str(e))
 	return
-	
+


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-09-11 23:45 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2014-09-11 23:45 UTC (permalink / raw
  To: gentoo-commits

commit:     aacdef7f8eb1dfa38fd6da46d3fd77a2c66462f4
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 18:33:21 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 23:44:25 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=aacdef7f

Fix off-by-one error in supported EAPI list

Fix the off-by-one error in construction of supported EAPI list that
resulted in EAPI 5 being considered unsupported.

---
 pym/portage/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index fdbc4a8..18b2599 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -493,7 +493,7 @@ _doebuild_manifest_exempt_depend = 0
 
 _testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend"])
 _deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1", "5_pre2"])
-_supported_eapis = frozenset([str(x) for x in range(portage.const.EAPI)] + list(_testing_eapis) + list(_deprecated_eapis))
+_supported_eapis = frozenset([str(x) for x in range(portage.const.EAPI + 1)] + list(_testing_eapis) + list(_deprecated_eapis))
 
 def _eapi_is_deprecated(eapi):
 	return eapi in _deprecated_eapis


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-09-11 23:45 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2014-09-11 23:45 UTC (permalink / raw
  To: gentoo-commits

commit:     6cde2a4d4232d92cb42490784d7798bc56767967
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 18:58:42 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 23:44:25 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6cde2a4d

Make eapi_is_supported() reuse _supported_eapis list

Make the eapi_is_supported() function use the generated list of
supported EAPIs rather than partial lists and integer comparison.

---
 pym/portage/__init__.py | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 18b2599..66bfeb0 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -505,19 +505,7 @@ def eapi_is_supported(eapi):
 		eapi = str(eapi)
 	eapi = eapi.strip()
 
-	if _eapi_is_deprecated(eapi):
-		return True
-
-	if eapi in _testing_eapis:
-		return True
-
-	try:
-		eapi = int(eapi)
-	except ValueError:
-		eapi = -1
-	if eapi < 0:
-		return False
-	return eapi <= portage.const.EAPI
+	return eapi in _supported_eapis
 
 # This pattern is specified by PMS section 7.3.1.
 _pms_eapi_re = re.compile(r"^[ \t]*EAPI=(['\"]?)([A-Za-z0-9+_.-]*)\1[ \t]*([ \t]#.*)?$")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-09-11 23:45 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2014-09-11 23:45 UTC (permalink / raw
  To: gentoo-commits

commit:     4ef4774b1e50753c9313d365f52927e21c486b96
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug  8 22:58:35 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 11 23:44:25 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4ef4774b

portage.const: Make PORTAGE_PYM_PATH point to the real package tree

Change PORTAGE_PYM_PATH to use real package tree path rather than one
based on PORTAGE_BASE_PATH.

---
 pym/portage/const.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 4b01ff9..f518b47 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -63,7 +63,7 @@ GLOBAL_CONFIG_PATH       = "/usr/share/portage/config"
 PORTAGE_BASE_PATH        = os.path.join(os.sep, os.sep.join(os.path.realpath(
                                __file__.rstrip("co")).split(os.sep)[:-3]))
 PORTAGE_BIN_PATH         = PORTAGE_BASE_PATH + "/bin"
-PORTAGE_PYM_PATH         = PORTAGE_BASE_PATH + "/pym"
+PORTAGE_PYM_PATH         = os.path.realpath(os.path.join(__file__, '../..'))
 LOCALE_DATA_PATH         = PORTAGE_BASE_PATH + "/locale"  # FIXME: not used
 EBUILD_SH_BINARY         = PORTAGE_BIN_PATH + "/ebuild.sh"
 MISC_SH_BINARY           = PORTAGE_BIN_PATH + "/misc-functions.sh"


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-09-12 21:26 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2014-09-12 21:26 UTC (permalink / raw
  To: gentoo-commits

commit:     a14d1493716ee0b026dc56ef6c6c1f24169fd880
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 12 21:24:08 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Sep 12 21:24:08 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a14d1493

portage/mail.py: don't encode Date header to bytes

As reported in bug #520752 comment #4, the _unicode_encode usage
triggers the following error with python 3.3.5:

	'bytes' object has no attribute 'encode'"

The _unicode_encode call is not needed for python2.x, since formatdate
returns bytes for python2.x.

Fixes: 7204b87040ed ("portage/mail.py: Make email date, timestamp RFC-compliant Bug 520752")
X-Gentoo-Bug: 520752
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=520752

---
 pym/portage/mail.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/pym/portage/mail.py b/pym/portage/mail.py
index 945cccd..11923ee 100644
--- a/pym/portage/mail.py
+++ b/pym/portage/mail.py
@@ -91,8 +91,7 @@ def create_message(sender, recipient, subject, body, attachments=None):
 	#    input_bytes = s.encode(input_charset, errors)
 	#UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-9: ordinal not in range(128)
 	mymessage["Subject"] = Header(_force_ascii_if_necessary(subject))
-	mymessage["Date"] = _unicode_encode(formatdate(localtime=True),
-		encoding=_encodings['content'], errors='backslashreplace')
+	mymessage["Date"] = formatdate(localtime=True)
 
 	return mymessage
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-10-23 18:18 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2014-10-23 18:18 UTC (permalink / raw
  To: gentoo-commits

commit:     b26d3aad771a6ca177228ba984c3c98130e3c60a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 23 18:17:54 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Oct 23 18:17:54 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b26d3aad

portage.data._get_global: fix UnboundLocalError

Since commit 1364fcd89384c9f60e6d72d7057dc00d8caba175, an
UnboundLocalError was triggered for portage_gid when userpriv was
enabled. This is fixed by using _get_global('portage_gid') to access
the variable value.

Fixes: 1364fcd89384 ("Support unprivileged mode for bug #433453.")
X-Gentoo-Bug: 433453
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=433453

---
 pym/portage/data.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/data.py b/pym/portage/data.py
index 3d91e48..3e03eef 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -157,7 +157,7 @@ def _get_global(k):
 			raise AssertionError('unknown name: %s' % k)
 
 	elif k == 'userpriv_groups':
-		v = [portage_gid]
+		v = [_get_global('portage_gid')]
 		if secpass >= 2:
 			# Get a list of group IDs for the portage user. Do not use
 			# grp.getgrall() since it is known to trigger spurious


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-11-11 22:30 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2014-11-11 22:30 UTC (permalink / raw
  To: gentoo-commits

commit:     a2b958f6af818816b2207b3e66836ee8e7683f12
Author:     Sven Vermeulen <swift <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 11 21:43:41 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Nov 11 22:27:49 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a2b958f6

_selinux.setexec: improve failure message (525726)

This converts "OSError: [Errno 22] Invalid argument" into a more
meaningful error message that is designed to guide users in the
right direction. Also, add an import that was missing for the "sys"
module, since it is referenced in the error paths of many functions
in this module.

X-Gentoo-Bug: 525726
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=525726
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
Acked-by: Zac Medico <zmedico <AT> gentoo.org>

---
 pym/portage/_selinux.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py
index 2a7194c..c5e8b2c 100644
--- a/pym/portage/_selinux.py
+++ b/pym/portage/_selinux.py
@@ -5,6 +5,7 @@
 # the whole _selinux module itself will be wrapped.
 import os
 import shutil
+import sys
 
 import portage
 from portage import _encodings
@@ -77,7 +78,18 @@ def settype(newtype):
 
 def setexec(ctx="\n"):
 	ctx = _native_string(ctx, encoding=_encodings['content'], errors='strict')
-	if selinux.setexeccon(ctx) < 0:
+	rc = 0
+	try:
+		rc = selinux.setexeccon(ctx)
+	except OSError:
+		msg = _("Failed to set new SELinux execution context. " + \
+			"Is your current SELinux context allowed to run Portage?")
+		if selinux.security_getenforce() == 1:
+			raise OSError(msg)
+		else:
+			portage.writemsg("!!! %s\n" % msg, noiselevel=-1)
+
+	if rc < 0:
 		if sys.hexversion < 0x3000000:
 			ctx = _unicode_decode(ctx, encoding=_encodings['content'], errors='replace')
 		if selinux.security_getenforce() == 1:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-11-18  1:04 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2014-11-18  1:04 UTC (permalink / raw
  To: gentoo-commits

commit:     e6121d92e586c0f9b75998eca2d1fbb46db7c821
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 10 06:25:10 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Nov 18 01:02:03 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e6121d92

NewsManager.getUnreadItems: handle EROFS (490732)

When getUnreadItems tries to lock the news.unread file, it's safe to
ignore EROFS. This is handled with a ReadOnlyFileSystem exception
raised from the portage.locks.lockfile function.

X-Gentoo-Bug: 490732
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=490732
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

---
 pym/portage/exception.py | 1 +
 pym/portage/locks.py     | 9 +++++++--
 pym/portage/news.py      | 9 +++++----
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index ef62e7a..857a727 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -133,6 +133,7 @@ class AlarmSignal(TimeoutException):
 
 class ReadOnlyFileSystem(PortageException):
 	"""Read-only file system"""
+	from errno import EROFS as errno
 
 class CommandNotFound(PortageException):
 	"""A required binary was not available or executable"""

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 0789f89..fdfe4a5 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -15,8 +15,9 @@ import warnings
 
 import portage
 from portage import os, _encodings, _unicode_decode
-from portage.exception import DirectoryNotFound, FileNotFound, \
-	InvalidData, TryAgain, OperationNotPermitted, PermissionDenied
+from portage.exception import (DirectoryNotFound, FileNotFound,
+	InvalidData, TryAgain, OperationNotPermitted, PermissionDenied,
+	ReadOnlyFileSystem)
 from portage.util import writemsg
 from portage.localization import _
 
@@ -110,6 +111,8 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 					raise OperationNotPermitted(func_call)
 				elif e.errno == PermissionDenied.errno:
 					raise PermissionDenied(func_call)
+				elif e.errno == ReadOnlyFileSystem.errno:
+					raise ReadOnlyFileSystem(func_call)
 				else:
 					raise
 
@@ -404,6 +407,8 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
 				raise OperationNotPermitted(func_call)
 			elif e.errno == PermissionDenied.errno:
 				raise PermissionDenied(func_call)
+			elif e.errno == ReadOnlyFileSystem.errno:
+				raise ReadOnlyFileSystem(func_call)
 			else:
 				raise
 		else:

diff --git a/pym/portage/news.py b/pym/portage/news.py
index 0d72b00..2c45f85 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -1,5 +1,5 @@
 # portage: news management code
-# Copyright 2006-2013 Gentoo Foundation
+# Copyright 2006-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function, unicode_literals
@@ -27,8 +27,8 @@ from portage.dep import isvalidatom
 from portage.localization import _
 from portage.locks import lockfile, unlockfile
 from portage.output import colorize
-from portage.exception import InvalidLocation, OperationNotPermitted, \
-	PermissionDenied
+from portage.exception import (InvalidLocation, OperationNotPermitted,
+	PermissionDenied, ReadOnlyFileSystem)
 
 class NewsManager(object):
 	"""
@@ -180,7 +180,8 @@ class NewsManager(object):
 		unread_lock = None
 		try:
 			unread_lock = lockfile(unread_filename, wantnewlockfile=1)
-		except (InvalidLocation, OperationNotPermitted, PermissionDenied):
+		except (InvalidLocation, OperationNotPermitted, PermissionDenied,
+			ReadOnlyFileSystem):
 			pass
 		try:
 			try:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-12-03 18:30 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2014-12-03 18:30 UTC (permalink / raw
  To: gentoo-commits

commit:     7c70eea2f607baffcbb9d465c03578d69b09decf
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec  3 08:44:40 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec  3 18:29:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7c70eea2

portage.os.waitpid: handle EINTR for bug #525552

Use a new _eintr_func_wrapper class to wrap waitpid calls and handle
EINTR by calling the function as many times as necessary (until it
returns without raising EINTR).

X-Gentoo-Bug: 525552
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=525552
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org>

---
 pym/portage/__init__.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d8046f3..4ce92f5 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -320,12 +320,36 @@ class _unicode_module_wrapper(object):
 			cache[attr] = result
 		return result
 
+class _eintr_func_wrapper(object):
+	"""
+	Wraps a function and handles EINTR by calling the function as
+	many times as necessary (until it returns without raising EINTR).
+	"""
+
+	__slots__ = ('_func',)
+
+	def __init__(self, func):
+		self._func = func
+
+	def __call__(self, *args, **kwargs):
+
+		while True:
+			try:
+				rval = self._func(*args, **kwargs)
+				break
+			except OSError as e:
+				if e.errno != errno.EINTR:
+					raise
+
+		return rval
+
 import os as _os
 _os_overrides = {
 	id(_os.fdopen)        : _os.fdopen,
 	id(_os.popen)         : _os.popen,
 	id(_os.read)          : _os.read,
 	id(_os.system)        : _os.system,
+	id(_os.waitpid)       : _eintr_func_wrapper(_os.waitpid)
 }
 
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-12-04 14:01 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2014-12-04 14:01 UTC (permalink / raw
  To: gentoo-commits

commit:     591d3e9dabdb2a4ca3899ebb0c9f584e527cbe06
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 18:26:12 2014 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Dec  4 14:01:34 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=591d3e9d

Support EAPI=6_pre1 for testing EAPI6 features

---
 pym/portage/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 4ce92f5..d96d733 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -515,7 +515,7 @@ def abssymlink(symlink, target=None):
 
 _doebuild_manifest_exempt_depend = 0
 
-_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend"])
+_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend", "6_pre1"])
 _deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1", "5_pre2"])
 _supported_eapis = frozenset([str(x) for x in range(portage.const.EAPI + 1)] + list(_testing_eapis) + list(_deprecated_eapis))
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2014-12-04 14:01 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2014-12-04 14:01 UTC (permalink / raw
  To: gentoo-commits

commit:     9553d0a53baa471411637deb8b63a42fbeccbd12
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 18 07:51:03 2014 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Dec  4 14:01:35 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9553d0a5

Enable tentative support for EAPI6 profile-level directories

Enable the support for package.* and use.* directories on profile and
repository level.

---
 pym/portage/eapi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index 4f77910..7217d23 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -81,7 +81,7 @@ def eapi_supports_stable_use_forcing_and_masking(eapi):
 	return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi")
 
 def eapi_allows_directories_on_profile_level_and_repository_level(eapi):
-	return eapi in ("4-python", "5-progress")
+	return eapi not in ("0", "1", "2", "3", "4", "4-slot-abi", "5")
 
 def eapi_has_use_aliases(eapi):
 	return eapi in ("4-python", "5-progress")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-01-12  9:13 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2015-01-12  9:13 UTC (permalink / raw
  To: gentoo-commits

commit:     27d929c4543e27e7db2c823610f05866f4b228f4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 12 05:14:54 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jan 12 09:12:17 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=27d929c4

dispatch_conf: factor out _archive_copy

This eliminates 4 instances of duplicate code from the rcs_archive and
file_archive functions.

Suggested-by: Brian Dolbec <dolsen <AT> gentoo.org>
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

---
 pym/portage/dispatch_conf.py | 92 +++++++++++++++++---------------------------
 1 file changed, 36 insertions(+), 56 deletions(-)

diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index 7d55182..790eacb 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -158,6 +158,38 @@ def read_config(mandatory_opts):
 
 	return opts
 
+def _archive_copy(src_st, src_path, dest_path):
+	"""
+	Copy file from src_path to dest_path. Regular files and symlinks
+	are supported. If an EnvironmentError occurs, then it is logged
+	to stderr.
+
+	@param src_st: source file lstat result
+	@type src_st: posix.stat_result
+	@param src_path: source file path
+	@type src_path: str
+	@param dest_path: destination file path
+	@type dest_path: str
+	"""
+	# Remove destination file in order to ensure that the following
+	# symlink or copy2 call won't fail (see bug #535850).
+	try:
+		os.unlink(dest_path)
+	except OSError:
+		pass
+	try:
+		if stat.S_ISLNK(src_st.st_mode):
+			os.symlink(os.readlink(src_path), dest_path)
+		else:
+			shutil.copy2(src_path, dest_path)
+	except EnvironmentError as e:
+		portage.util.writemsg(
+			_('dispatch-conf: Error copying %(src_path)s to '
+			'%(dest_path)s: %(reason)s\n') % {
+				"src_path": src_path,
+				"dest_path": dest_path,
+				"reason": e
+			}, noiselevel=-1)
 
 def rcs_archive(archive, curconf, newconf, mrgconf):
 	"""Archive existing config in rcs (on trunk). Then, if mrgconf is
@@ -179,20 +211,7 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
 	if curconf_st is not None and \
 		(stat.S_ISREG(curconf_st.st_mode) or
 		stat.S_ISLNK(curconf_st.st_mode)):
-		# Remove destination file in order to ensure that the following
-		# symlink or copy2 call won't fail (see bug #535850).
-		try:
-			os.unlink(archive)
-		except OSError:
-			pass
-		try:
-			if stat.S_ISLNK(curconf_st.st_mode):
-				os.symlink(os.readlink(curconf), archive)
-			else:
-				shutil.copy2(curconf, archive)
-		except(IOError, os.error) as why:
-			print(_('dispatch-conf: Error copying %(curconf)s to %(archive)s: %(reason)s; fatal') % \
-				{"curconf": curconf, "archive": archive, "reason": str(why)}, file=sys.stderr)
+		_archive_copy(curconf_st, curconf, archive)
 
 	if os.path.lexists(archive + ',v'):
 		os.system(RCS_LOCK + ' ' + archive)
@@ -214,20 +233,7 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
 		if has_branch:
 			os.rename(archive, archive + '.dist')
 
-		# Remove destination file in order to ensure that the following
-		# symlink or copy2 call won't fail (see bug #535850).
-		try:
-			os.unlink(archive)
-		except OSError:
-			pass
-		try:
-			if stat.S_ISLNK(mystat.st_mode):
-				os.symlink(os.readlink(newconf), archive)
-			else:
-				shutil.copy2(newconf, archive)
-		except(IOError, os.error) as why:
-			print(_('dispatch-conf: Error copying %(newconf)s to %(archive)s: %(reason)s; fatal') % \
-				{"newconf": newconf, "archive": archive, "reason": str(why)}, file=sys.stderr)
+		_archive_copy(mystat, newconf, archive)
 
 		if has_branch:
 			if mrgconf and os.path.isfile(archive) and \
@@ -276,20 +282,7 @@ def file_archive(archive, curconf, newconf, mrgconf):
 	if curconf_st is not None and \
 		(stat.S_ISREG(curconf_st.st_mode) or
 		stat.S_ISLNK(curconf_st.st_mode)):
-		# Remove destination file in order to ensure that the following
-		# symlink or copy2 call won't fail (see bug #535850).
-		try:
-			os.unlink(archive)
-		except OSError:
-			pass
-		try:
-			if stat.S_ISLNK(curconf_st.st_mode):
-				os.symlink(os.readlink(curconf), archive)
-			else:
-				shutil.copy2(curconf, archive)
-		except(IOError, os.error) as why:
-			print(_('dispatch-conf: Error copying %(curconf)s to %(archive)s: %(reason)s; fatal') % \
-				{"curconf": curconf, "archive": archive, "reason": str(why)}, file=sys.stderr)
+		_archive_copy(curconf_st, curconf, archive)
 
 	mystat = None
 	if newconf:
@@ -303,20 +296,7 @@ def file_archive(archive, curconf, newconf, mrgconf):
 		stat.S_ISLNK(mystat.st_mode)):
 		# Save off new config file in the archive dir with .dist.new suffix
 		newconf_archive = archive + '.dist.new'
-		# Remove destination file in order to ensure that the following
-		# symlink or copy2 call won't fail (see bug #535850).
-		try:
-			os.unlink(newconf_archive)
-		except OSError:
-			pass
-		try:
-			if stat.S_ISLNK(mystat.st_mode):
-				os.symlink(os.readlink(newconf), newconf_archive)
-			else:
-				shutil.copy2(newconf, newconf_archive)
-		except(IOError, os.error) as why:
-			print(_('dispatch-conf: Error copying %(newconf)s to %(archive)s: %(reason)s; fatal') % \
-				{"newconf": newconf, "archive": archive + '.dist.new', "reason": str(why)}, file=sys.stderr)
+		_archive_copy(mystat, newconf, newconf_archive)
 
 		ret = 0
 		if mrgconf and os.path.isfile(curconf) and \


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-01-12  9:13 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2015-01-12  9:13 UTC (permalink / raw
  To: gentoo-commits

commit:     79eb7417454220f04def35e428b876b97fdaabf4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 11 08:46:19 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jan 12 09:12:06 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=79eb7417

dispatch-conf: avoid symlink "File exists" error (535850)

Since commit f17448317166bfac42dc279b8795cd581c189582, an existing
symlink in /etc/config-archive could trigger a fatal "File exists"
error. Handle this by removing the destination file if it exists. This
was not necessary when dispatch-conf only supported regular files,
since shutil.copy2 would simply overwrite the regular destination file.

Fixes: f17448317166 ("dispatch-conf: symlink support for bug #485598")
X-Gentoo-Bug: 535850
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=535850
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

---
 pym/portage/dispatch_conf.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index b27e68b..7d55182 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -179,6 +179,12 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
 	if curconf_st is not None and \
 		(stat.S_ISREG(curconf_st.st_mode) or
 		stat.S_ISLNK(curconf_st.st_mode)):
+		# Remove destination file in order to ensure that the following
+		# symlink or copy2 call won't fail (see bug #535850).
+		try:
+			os.unlink(archive)
+		except OSError:
+			pass
 		try:
 			if stat.S_ISLNK(curconf_st.st_mode):
 				os.symlink(os.readlink(curconf), archive)
@@ -208,6 +214,12 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
 		if has_branch:
 			os.rename(archive, archive + '.dist')
 
+		# Remove destination file in order to ensure that the following
+		# symlink or copy2 call won't fail (see bug #535850).
+		try:
+			os.unlink(archive)
+		except OSError:
+			pass
 		try:
 			if stat.S_ISLNK(mystat.st_mode):
 				os.symlink(os.readlink(newconf), archive)
@@ -264,6 +276,12 @@ def file_archive(archive, curconf, newconf, mrgconf):
 	if curconf_st is not None and \
 		(stat.S_ISREG(curconf_st.st_mode) or
 		stat.S_ISLNK(curconf_st.st_mode)):
+		# Remove destination file in order to ensure that the following
+		# symlink or copy2 call won't fail (see bug #535850).
+		try:
+			os.unlink(archive)
+		except OSError:
+			pass
 		try:
 			if stat.S_ISLNK(curconf_st.st_mode):
 				os.symlink(os.readlink(curconf), archive)
@@ -285,6 +303,12 @@ def file_archive(archive, curconf, newconf, mrgconf):
 		stat.S_ISLNK(mystat.st_mode)):
 		# Save off new config file in the archive dir with .dist.new suffix
 		newconf_archive = archive + '.dist.new'
+		# Remove destination file in order to ensure that the following
+		# symlink or copy2 call won't fail (see bug #535850).
+		try:
+			os.unlink(newconf_archive)
+		except OSError:
+			pass
 		try:
 			if stat.S_ISLNK(mystat.st_mode):
 				os.symlink(os.readlink(newconf), newconf_archive)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-01-30 20:32 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2015-01-30 20:32 UTC (permalink / raw
  To: gentoo-commits

commit:     4efd7e93ac70b44639fbb324ac3fdd189f563fb3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 30 20:23:43 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Jan 30 20:31:18 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4efd7e93

portage/news.py: Whitespace cleanup

---
 pym/portage/news.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/news.py b/pym/portage/news.py
index ec10feb..54d4dc9 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -35,12 +35,12 @@ class NewsManager(object):
 	This object manages GLEP 42 style news items.  It will cache news items
 	that have previously shown up and notify users when there are relevant news
 	items that apply to their packages that the user has not previously read.
-	
+
 	Creating a news manager requires:
 	root - typically ${ROOT} see man make.conf and man emerge for details
 	news_path - path to news items; usually $REPODIR/metadata/news
 	unread_path - path to the news.repoid.unread file; this helps us track news items
-	
+
 	"""
 
 	def __init__(self, portdb, vardb, news_path, unread_path, language_id='en'):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-01-30 20:32 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2015-01-30 20:32 UTC (permalink / raw
  To: gentoo-commits

commit:     ee4b23f8d711e531e454d5d2948e49862363eb59
Author:     Toralf Förster <toralf.foerster <AT> gmx <DOT> de>
AuthorDate: Thu Jan 29 15:02:33 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Jan 30 20:30:24 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ee4b23f8

pym/portage/news.py: let slackers copy+paste the news read command

Signed-off-by: Toralf Förster <toralf.foerster <AT> gmx.de>
Brian Dolbec: Edited and changed it as suggested in the review emails.

---
 pym/portage/news.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/news.py b/pym/portage/news.py
index 2c45f85..ec10feb 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -421,5 +421,5 @@ def display_news_notifications(news_counts):
 
 	if newsReaderDisplay:
 		print(colorize("WARN", " *"), end=' ')
-		print("Use " + colorize("GOOD", "eselect news") + " to read news items.")
+		print("Use " + colorize("GOOD", "eselect news read") + " to view new items.")
 		print()


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-01-31 23:13 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2015-01-31 23:13 UTC (permalink / raw
  To: gentoo-commits

commit:     664684f0f17c0f3570ffd9382037994db1ec66bd
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 31 20:23:15 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 31 23:12:12 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=664684f0

lockfile: handle EINTR for bug #538314

Use portage._eintr_func_wrapper to handle EINTR from fcntl.lockf. Since
fcntl.lockf raises IOError, make _eintr_func_wrapper handle
EnvironmentError (which both OSError and IOError inherit from).

X-Gentoo-Bug: 538314
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=538314
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

---
 pym/portage/__init__.py | 2 +-
 pym/portage/locks.py    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d96d733..1c85042 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -337,7 +337,7 @@ class _eintr_func_wrapper(object):
 			try:
 				rval = self._func(*args, **kwargs)
 				break
-			except OSError as e:
+			except EnvironmentError as e:
 				if e.errno != errno.EINTR:
 					raise
 

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index fdfe4a5..42ff1e3 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -146,7 +146,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 
 	# try for a non-blocking lock, if it's held, throw a message
 	# we're waiting on lockfile and use a blocking attempt.
-	locking_method = _default_lock_fn
+	locking_method = portage._eintr_func_wrapper(_default_lock_fn)
 	try:
 		if "__PORTAGE_TEST_HARDLINK_LOCKS" in os.environ:
 			raise IOError(errno.ENOSYS, "Function not implemented")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-05-11  0:47 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2015-05-11  0:47 UTC (permalink / raw
  To: gentoo-commits

commit:     757beccdd058eb9ce9884a7c5e766e24c881ec8d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May 10 09:39:05 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May 11 00:40:18 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=757beccd

dispatch-conf: handle file/directory collisions (bug 256376)

Whenever a file/directory collision would have previously caused a
problem, the colliding file or directory will now be renamed.

X-Gentoo-Bug: 256376
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=256376
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/dispatch_conf.py | 97 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 83 insertions(+), 14 deletions(-)

diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index 98939fd..ed9a64a 100644
--- a/pym/portage/dispatch_conf.py
+++ b/pym/portage/dispatch_conf.py
@@ -8,6 +8,7 @@
 
 from __future__ import print_function, unicode_literals
 
+import errno
 import io
 import functools
 import stat
@@ -20,6 +21,7 @@ from portage import _encodings, os, shutil
 from portage.env.loaders import KeyValuePairFileLoader
 from portage.localization import _
 from portage.util import shlex_split, varexpand
+from portage.util.path import iter_parents
 
 RCS_BRANCH = '1.1.1'
 RCS_LOCK = 'rcs -ko -M -l'
@@ -28,6 +30,7 @@ RCS_GET = 'co'
 RCS_MERGE = "rcsmerge -p -r" + RCS_BRANCH + " '%s' > '%s'"
 
 DIFF3_MERGE = "diff3 -mE '%s' '%s' '%s' > '%s'"
+_ARCHIVE_ROTATE_MAX = 9
 
 def diffstatusoutput(cmd, file1, file2):
 	"""
@@ -244,6 +247,77 @@ def rcs_archive(archive, curconf, newconf, mrgconf):
 
 	return ret
 
+def _file_archive_rotate(archive):
+	"""
+	Rename archive to archive + '.1', and perform similar rotation
+	for files up to archive + '.9'.
+
+	@param archive: file path to archive
+	@type archive: str
+	"""
+
+	max_suf = 0
+	try:
+		for max_suf, max_st, max_path in (
+			(suf, os.lstat(path), path) for suf, path in (
+			(suf, "%s.%s" % (archive, suf)) for suf in range(
+			1, _ARCHIVE_ROTATE_MAX + 1))):
+			pass
+	except OSError as e:
+		if e.errno not in (errno.ENOENT, errno.ESTALE):
+			raise
+		# There's already an unused suffix.
+	else:
+		# Free the max suffix in order to avoid possible problems
+		# when we rename another file or directory to the same
+		# location (see bug 256376).
+		if stat.S_ISDIR(max_st.st_mode):
+			# Removing a directory might destroy something important,
+			# so rename it instead.
+			head, tail = os.path.split(archive)
+			placeholder = tempfile.NamedTemporaryFile(
+				prefix="%s." % tail,
+				dir=head)
+			placeholder.close()
+			os.rename(max_path, placeholder.name)
+		else:
+			os.unlink(max_path)
+
+		# The max suffix is now unused.
+		max_suf -= 1
+
+	for suf in range(max_suf + 1, 1, -1):
+		os.rename("%s.%s" % (archive, suf - 1), "%s.%s" % (archive, suf))
+
+	os.rename(archive, "%s.1" % (archive,))
+
+def _file_archive_ensure_dir(parent_dir):
+	"""
+	Ensure that the parent directory for an archive exists.
+	If a file exists where a directory is needed, then rename
+	it (see bug 256376).
+
+	@param parent_dir: path of parent directory
+	@type parent_dir: str
+	"""
+
+	for parent in iter_parents(parent_dir):
+		# Use lstat because a symlink to a directory might point
+		# to a directory outside of the config archive, making
+		# it an unsuitable parent.
+		try:
+			parent_st = os.lstat(parent)
+		except OSError:
+			pass
+		else:
+			if not stat.S_ISDIR(parent_st.st_mode):
+				_file_archive_rotate(parent)
+			break
+
+	try:
+		os.makedirs(parent_dir)
+	except OSError:
+		pass
 
 def file_archive(archive, curconf, newconf, mrgconf):
 	"""Archive existing config to the archive-dir, bumping old versions
@@ -253,24 +327,13 @@ def file_archive(archive, curconf, newconf, mrgconf):
 	if newconf was specified, archive it as a .dist.new version (which
 	gets moved to the .dist version at the end of the processing)."""
 
-	try:
-		os.makedirs(os.path.dirname(archive))
-	except OSError:
-		pass
+	_file_archive_ensure_dir(os.path.dirname(archive))
 
 	# Archive the current config file if it isn't already saved
 	if (os.path.lexists(archive) and
 		len(diffstatusoutput_mixed(
 		"diff -aq '%s' '%s'", curconf, archive)[1]) != 0):
-		suf = 1
-		while suf < 9 and os.path.lexists(archive + '.' + str(suf)):
-			suf += 1
-
-		while suf > 1:
-			os.rename(archive + '.' + str(suf-1), archive + '.' + str(suf))
-			suf -= 1
-
-		os.rename(archive, archive + '.1')
+		_file_archive_rotate(archive)
 
 	try:
 		curconf_st = os.lstat(curconf)
@@ -294,6 +357,9 @@ def file_archive(archive, curconf, newconf, mrgconf):
 		stat.S_ISLNK(mystat.st_mode)):
 		# Save off new config file in the archive dir with .dist.new suffix
 		newconf_archive = archive + '.dist.new'
+		if os.path.isdir(newconf_archive
+			) and not os.path.islink(newconf_archive):
+			_file_archive_rotate(newconf_archive)
 		_archive_copy(mystat, newconf, newconf_archive)
 
 		ret = 0
@@ -325,4 +391,7 @@ def rcs_archive_post_process(archive):
 def file_archive_post_process(archive):
 	"""Rename the archive file with the .dist.new suffix to a .dist suffix"""
 	if os.path.lexists(archive + '.dist.new'):
-		os.rename(archive + '.dist.new', archive + '.dist')
+		dest = "%s.dist" % archive
+		if os.path.isdir(dest) and not os.path.islink(dest):
+			_file_archive_rotate(dest)
+		os.rename(archive + '.dist.new', dest)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-08-17  3:39 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2015-08-17  3:39 UTC (permalink / raw
  To: gentoo-commits

commit:     6dacd0ed9f6dc206f4932d42bbb36300f56e71f7
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 17 02:56:43 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Aug 17 03:35:08 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=6dacd0ed

Manifest.write: stable/predictable Manifest mtime for rsync (bug 557962)

Use the max mtime of the existing Manifest and the files that the updated
Manifest contains.

X-Gentoo-Bug: 557962
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=557962
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/manifest.py | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 3936b9a..f5cf0f5 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
 import errno
 import io
 import re
+import stat
 import sys
 import warnings
 
@@ -281,6 +282,7 @@ class Manifest(object):
 		try:
 			myentries = list(self._createManifestEntries())
 			update_manifest = True
+			existing_st = None
 			if myentries and not force:
 				try:
 					f = io.open(_unicode_encode(self.getFullname(),
@@ -288,6 +290,7 @@ class Manifest(object):
 						mode='r', encoding=_encodings['repo.content'],
 						errors='replace')
 					oldentries = list(self._parseManifestLines(f))
+					existing_st = os.fstat(f.fileno())
 					f.close()
 					if len(oldentries) == len(myentries):
 						update_manifest = False
@@ -309,6 +312,7 @@ class Manifest(object):
 					# non-empty for all currently known use cases.
 					write_atomic(self.getFullname(), "".join("%s\n" %
 						_unicode(myentry) for myentry in myentries))
+					self._apply_max_mtime(existing_st, myentries)
 					rval = True
 				else:
 					# With thin manifest, there's no need to have
@@ -328,6 +332,37 @@ class Manifest(object):
 			raise
 		return rval
 
+	def _apply_max_mtime(self, existing_st, entries):
+		"""
+		Set the Manifest mtime to the max mtime of all relevant files
+		(the existing Manifest mtime is included in order to account for
+		eclass modifications that change DIST entries). This results in a
+		stable/predictable mtime, which is useful when converting thin
+		manifests to thick manifests for distribution via rsync. For
+		portability, the mtime is set with 1 second resolution.
+
+		@param existing_st: stat result for existing Manifest
+		@type existing_st: posix.stat_result
+		@param entries: list of current Manifest2Entry instances
+		@type entries: list
+		"""
+		# Use stat_result[stat.ST_MTIME] for 1 second resolution, since
+		# it always rounds down. Note that stat_result.st_mtime will round
+		# up from 0.999999999 to 1.0 when precision is lost during conversion
+		# from nanosecond resolution to float.
+		max_mtime = None if existing_st is None else existing_st[stat.ST_MTIME]
+		for entry in entries:
+			if entry.type == 'DIST':
+				continue
+			abs_path = (os.path.join(self.pkgdir, 'files', entry.name) if
+				entry.type == 'AUX' else os.path.join(self.pkgdir, entry.name))
+			mtime = os.stat(abs_path)[stat.ST_MTIME]
+			if max_mtime is None or mtime > max_mtime:
+				max_mtime = mtime
+
+		if max_mtime is not None:
+			os.utime(self.getFullname(), (max_mtime, max_mtime))
+
 	def sign(self):
 		""" Sign the Manifest """
 		raise NotImplementedError()


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-10-02  5:08 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2015-10-02  5:08 UTC (permalink / raw
  To: gentoo-commits

commit:     ee0ac6e6b18438098070d9162d6939832f2d14ed
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Oct  1 20:53:15 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Oct  2 05:05:54 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ee0ac6e6

checksum._open_file: fix BytesWarning

Fix the following warning message:

pym/portage/checksum.py:25: BytesWarning: str() on a bytes instance
  func_call = "open('%s')" % filename

Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/checksum.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 642602e..cdf4670 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -7,7 +7,7 @@ from portage.const import PRELINK_BINARY, HASHING_BLOCKSIZE
 from portage.localization import _
 from portage import os
 from portage import _encodings
-from portage import _unicode_encode
+from portage import _unicode_decode, _unicode_encode
 import errno
 import stat
 import subprocess
@@ -22,7 +22,7 @@ def _open_file(filename):
 		return open(_unicode_encode(filename,
 			encoding=_encodings['fs'], errors='strict'), 'rb')
 	except IOError as e:
-		func_call = "open('%s')" % filename
+		func_call = "open('%s')" % _unicode_decode(filename)
 		if e.errno == errno.EPERM:
 			raise portage.exception.OperationNotPermitted(func_call)
 		elif e.errno == errno.EACCES:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-11-12 19:32 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2015-11-12 19:32 UTC (permalink / raw
  To: gentoo-commits

commit:     7fa01035846b24c94768906b18fac17ab17a6f8a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  8 23:41:57 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Nov 12 19:32:37 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7fa01035

EAPI 6: Revert support for profile- and repo-level directories

Revert the support for profile- and repository-level directories that
has been voted out of EAPI 6.

 pym/portage/eapi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index 7217d23..4f77910 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -81,7 +81,7 @@ def eapi_supports_stable_use_forcing_and_masking(eapi):
 	return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi")
 
 def eapi_allows_directories_on_profile_level_and_repository_level(eapi):
-	return eapi not in ("0", "1", "2", "3", "4", "4-slot-abi", "5")
+	return eapi in ("4-python", "5-progress")
 
 def eapi_has_use_aliases(eapi):
 	return eapi in ("4-python", "5-progress")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-11-15 22:54 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2015-11-15 22:54 UTC (permalink / raw
  To: gentoo-commits

commit:     f3e993df697611e32012093ce9d3fd140e870476
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 15 13:09:51 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Nov 15 21:18:48 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=f3e993df

Enable EAPI 6

 pym/portage/const.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 6c4f613..814d7f4 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -202,7 +202,7 @@ SUPPORTED_FEATURES       = frozenset([
 	"xattr",
 ])
 
-EAPI                     = 5
+EAPI                     = 6
 
 HASHING_BLOCKSIZE        = 32768
 MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-12-15 16:18 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2015-12-15 16:18 UTC (permalink / raw
  To: gentoo-commits

commit:     3c2cce57700e8a2be4774d653cd632d9e59aab78
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 15 07:29:36 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Dec 15 16:10:53 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3c2cce57

Manifest._apply_max_mtime: account for removals and renames (bug 567920)

Include directory mtimes in the max mtime calculation, in order
to account for removals and renames.

Fixes: 6dacd0ed9f6d ("Manifest.write: stable/predictable Manifest mtime for rsync (bug 557962)")
X-Gentoo-Bug: 567920
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=567920
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org>

 pym/portage/manifest.py | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index f5cf0f5..818515f 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -282,7 +282,8 @@ class Manifest(object):
 		try:
 			myentries = list(self._createManifestEntries())
 			update_manifest = True
-			existing_st = None
+			preserved_stats = {}
+			preserved_stats[self.pkgdir.rstrip(os.sep)] = os.stat(self.pkgdir)
 			if myentries and not force:
 				try:
 					f = io.open(_unicode_encode(self.getFullname(),
@@ -290,7 +291,7 @@ class Manifest(object):
 						mode='r', encoding=_encodings['repo.content'],
 						errors='replace')
 					oldentries = list(self._parseManifestLines(f))
-					existing_st = os.fstat(f.fileno())
+					preserved_stats[self.getFullname()] = os.fstat(f.fileno())
 					f.close()
 					if len(oldentries) == len(myentries):
 						update_manifest = False
@@ -312,7 +313,7 @@ class Manifest(object):
 					# non-empty for all currently known use cases.
 					write_atomic(self.getFullname(), "".join("%s\n" %
 						_unicode(myentry) for myentry in myentries))
-					self._apply_max_mtime(existing_st, myentries)
+					self._apply_max_mtime(preserved_stats, myentries)
 					rval = True
 				else:
 					# With thin manifest, there's no need to have
@@ -332,17 +333,21 @@ class Manifest(object):
 			raise
 		return rval
 
-	def _apply_max_mtime(self, existing_st, entries):
+	def _apply_max_mtime(self, preserved_stats, entries):
 		"""
 		Set the Manifest mtime to the max mtime of all relevant files
-		(the existing Manifest mtime is included in order to account for
-		eclass modifications that change DIST entries). This results in a
+		and directories. Directory mtimes account for file renames and
+		removals. The existing Manifest mtime accounts for eclass
+		modifications that change DIST entries. This results in a
 		stable/predictable mtime, which is useful when converting thin
 		manifests to thick manifests for distribution via rsync. For
 		portability, the mtime is set with 1 second resolution.
 
 		@param existing_st: stat result for existing Manifest
 		@type existing_st: posix.stat_result
+		@param preserved_stats: maps paths to preserved stat results
+			that should be used instead of os.stat() calls
+		@type preserved_stats: dict
 		@param entries: list of current Manifest2Entry instances
 		@type entries: list
 		"""
@@ -350,18 +355,31 @@ class Manifest(object):
 		# it always rounds down. Note that stat_result.st_mtime will round
 		# up from 0.999999999 to 1.0 when precision is lost during conversion
 		# from nanosecond resolution to float.
-		max_mtime = None if existing_st is None else existing_st[stat.ST_MTIME]
+		max_mtime = None
+		_update_max = (lambda st: max_mtime if max_mtime is not None
+			and max_mtime > st[stat.ST_MTIME] else st[stat.ST_MTIME])
+		_stat = (lambda path: preserved_stats[path] if path in preserved_stats
+			else os.stat(path))
+
+		for stat_result in preserved_stats.values():
+			max_mtime = _update_max(stat_result)
+
+		dirs = set()
 		for entry in entries:
 			if entry.type == 'DIST':
 				continue
 			abs_path = (os.path.join(self.pkgdir, 'files', entry.name) if
 				entry.type == 'AUX' else os.path.join(self.pkgdir, entry.name))
-			mtime = os.stat(abs_path)[stat.ST_MTIME]
-			if max_mtime is None or mtime > max_mtime:
-				max_mtime = mtime
+			max_mtime = _update_max(_stat(abs_path))
+
+			parent_dir = os.path.dirname(abs_path)
+			if parent_dir not in dirs:
+				dirs.add(parent_dir)
+				max_mtime = _update_max(_stat(parent_dir))
 
 		if max_mtime is not None:
-			os.utime(self.getFullname(), (max_mtime, max_mtime))
+			for path in preserved_stats:
+				os.utime(path, (max_mtime, max_mtime))
 
 	def sign(self):
 		""" Sign the Manifest """


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-12-16 18:58 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2015-12-16 18:58 UTC (permalink / raw
  To: gentoo-commits

commit:     d14b51d888ead52c841783c10e1d8d36c63e9e35
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 16 18:56:30 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Dec 16 18:56:30 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d14b51d8

Manifest._apply_max_mtime: remove existing_st from docstring

Fixes: 3c2cce57700e ("Manifest._apply_max_mtime: account for removals and renames (bug 567920)")
Reported-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>

 pym/portage/manifest.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 818515f..3a6bc7e 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -343,8 +343,6 @@ class Manifest(object):
 		manifests to thick manifests for distribution via rsync. For
 		portability, the mtime is set with 1 second resolution.
 
-		@param existing_st: stat result for existing Manifest
-		@type existing_st: posix.stat_result
 		@param preserved_stats: maps paths to preserved stat results
 			that should be used instead of os.stat() calls
 		@type preserved_stats: dict


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2015-12-21 16:17 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2015-12-21 16:17 UTC (permalink / raw
  To: gentoo-commits

commit:     7d7248470d42f034184249f96995762b3b27f227
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 17 17:43:38 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Dec 21 16:10:42 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7d724847

Manifest._apply_max_mtime: include all dirs (bug 567920)

Commit 3c2cce57700e8a2be4774d653cd632d9e59aab78 only included direct
parent directories of files listed in the manifest. In order to account
for changes to directories that only contain directories, include all
directories in the max mtime calculation for thick manifests.

Fixes: 3c2cce57700e ("Manifest._apply_max_mtime: account for removals and renames (bug 567920)")
X-Gentoo-Bug: 567920
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=567920
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org>

 pym/portage/manifest.py | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 3a6bc7e..f696f84 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -362,7 +362,6 @@ class Manifest(object):
 		for stat_result in preserved_stats.values():
 			max_mtime = _update_max(stat_result)
 
-		dirs = set()
 		for entry in entries:
 			if entry.type == 'DIST':
 				continue
@@ -370,10 +369,21 @@ class Manifest(object):
 				entry.type == 'AUX' else os.path.join(self.pkgdir, entry.name))
 			max_mtime = _update_max(_stat(abs_path))
 
-			parent_dir = os.path.dirname(abs_path)
-			if parent_dir not in dirs:
-				dirs.add(parent_dir)
-				max_mtime = _update_max(_stat(parent_dir))
+		if not self.thin:
+			# Account for changes to all relevant nested directories.
+			# This is not necessary for thin manifests because
+			# self.pkgdir is already included via preserved_stats.
+			for parent_dir, dirs, files in os.walk(self.pkgdir.rstrip(os.sep)):
+				try:
+					parent_dir = _unicode_decode(parent_dir,
+						encoding=_encodings['fs'], errors='strict')
+				except UnicodeDecodeError:
+					# If an absolute path cannot be decoded, then it is
+					# always excluded from the manifest (repoman will
+					# report such problems).
+					pass
+				else:
+					max_mtime = _update_max(_stat(parent_dir))
 
 		if max_mtime is not None:
 			for path in preserved_stats:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-04-29 23:16 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2016-04-29 23:16 UTC (permalink / raw
  To: gentoo-commits

commit:     75fbbcf58f244717712602a83765bcdc6f07ddcf
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 29 23:14:28 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Apr 29 23:14:28 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=75fbbcf5

portage/module.py: Restore backaward compatibilty for previous module_spec.

If the module_spec is missing the 'sourcefile' key and value it will fall back to the previous
code.  It will also print a warning message.

 pym/portage/module.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pym/portage/module.py b/pym/portage/module.py
index 1a10996..b7967ba 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -4,9 +4,12 @@
 
 from __future__ import print_function
 
+import warnings
+
 from portage import os
 from portage.exception import PortageException
 from portage.cache.mappings import ProtectedDict
+from portage.localization import _
 
 
 class InvalidModuleName(PortageException):
@@ -46,7 +49,14 @@ class Module(object):
 		for submodule in self.module_spec['provides']:
 			kid = self.module_spec['provides'][submodule]
 			kidname = kid['name']
-			kid['module_name'] = '.'.join([mod_name, kid['sourcefile']])
+			try:
+				kid['module_name'] = '.'.join([mod_name, kid['sourcefile']])
+			except KeyError:
+				kid['module_name'] = '.'.join([mod_name, self.name])
+				warnings.warn(
+					_("%s module's module_spec is old and needs updating. "
+						"Backward compatibility may be removed in the future.")
+					% (self.name), UserWarning, stacklevel=2)
 			kid['is_imported'] = False
 			self.kids[kidname] = kid
 			self.kids_names.append(kidname)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-04-30  0:12 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2016-04-30  0:12 UTC (permalink / raw
  To: gentoo-commits

commit:     83baf60851c023fd985eab8a119f52a781c9be74
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 30 00:11:35 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Apr 30 00:11:35 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=83baf608

portage/modules.py: Change warnings output to writemsg()

Add the missing attribute and filepath to the output for best clarity, bug reporting.

 pym/portage/module.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/pym/portage/module.py b/pym/portage/module.py
index b7967ba..f9828a5 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -4,12 +4,11 @@
 
 from __future__ import print_function
 
-import warnings
-
 from portage import os
 from portage.exception import PortageException
 from portage.cache.mappings import ProtectedDict
 from portage.localization import _
+from portage.util import writemsg
 
 
 class InvalidModuleName(PortageException):
@@ -53,10 +52,10 @@ class Module(object):
 				kid['module_name'] = '.'.join([mod_name, kid['sourcefile']])
 			except KeyError:
 				kid['module_name'] = '.'.join([mod_name, self.name])
-				warnings.warn(
-					_("%s module's module_spec is old and needs updating. "
-						"Backward compatibility may be removed in the future.")
-					% (self.name), UserWarning, stacklevel=2)
+				msg = ("%s module's module_spec is old, missing attribute: "
+						"'sourcefile'.  Backward compatibility may be "
+						"removed in the future.\nFile: %s\n")
+				writemsg(_(msg) % (self.name, self._module.__file__))
 			kid['is_imported'] = False
 			self.kids[kidname] = kid
 			self.kids_names.append(kidname)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-05-16  9:47 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2016-05-16  9:47 UTC (permalink / raw
  To: gentoo-commits

commit:     9ba1bea5e24fe839ef5bd833c3974a55d5333bf1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon May 16 09:45:45 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon May 16 09:45:45 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9ba1bea5

portage.const.py: Remove repoman from PORTAGE_PYM_PACKAGES

Decca (in IRC) got a traceback due to the missing repoman install

sysresccd / # emerge -e @system
Calculating dependencies... done!
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.5/emerge", line 50, in <module>
    retval = emerge_main()
  File "/usr/lib64/python3.5/site-packages/_emerge/main.py", line 1185, in emerge_main
    return run_action(emerge_config)
  File "/usr/lib64/python3.5/site-packages/_emerge/actions.py", line 3236, in run_action
    emerge_config.args, spinner)
  File "/usr/lib64/python3.5/site-packages/_emerge/actions.py", line 505, in action_build
    retval = mergetask.merge()
  File "/usr/lib64/python3.5/site-packages/_emerge/Scheduler.py", line 958, in merge
    rval = self._handle_self_update()
  File "/usr/lib64/python3.5/site-packages/_emerge/Scheduler.py", line 323, in _handle_self_update
    _prepare_self_update(self.settings)
  File "/usr/lib64/python3.5/site-packages/portage/package/ebuild/doebuild.py", line 2489, in _prepare_self_update
    symlinks=True)
  File "/usr/lib64/python3.5/site-packages/portage/__init__.py", line 259, in __call__
    rval = self._func(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib64/python3.5/shutil.py", line 303, in copytree
    names = os.listdir(src)
FileNotFoundError: [Errno 2] No such file or directory: b'/usr/lib64/python3.5/site-packages/repoman'

Dirkjan <djc> found  repoman was still included in the PORTAGE_PYM_PACKAGES which
caused the traceback.

 pym/portage/const.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 814d7f4..179efce 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -278,7 +278,7 @@ SUPPORTED_XPAK_EXTENSIONS = (".tbz2", ".xpak")
 TIMESTAMP_FORMAT = "%a, %d %b %Y %H:%M:%S +0000"	# to be used with time.gmtime()
 
 # Top-level names of Python packages installed by Portage.
-PORTAGE_PYM_PACKAGES = ("_emerge", "portage", "repoman")
+PORTAGE_PYM_PACKAGES = ("_emerge", "portage")
 
 RETURNCODE_POSTINST_FAILURE = 5
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-05-18 16:42 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2016-05-18 16:42 UTC (permalink / raw
  To: gentoo-commits

commit:     33c8d30cc10cb11cb098d4dfe92f7187b20eefaf
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 21 04:09:54 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed May 18 16:41:22 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=33c8d30c

localized_size: handle UnicodeDecodeError (bug 577862)

Fix localized_size to handle UnicodeDecodeError, which is necessary
if the locale data is corrupt or has an unexpected encoding.

X-Gentoo-bug: 577862
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=577862
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/localization.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pym/portage/localization.py b/pym/portage/localization.py
index 2db4b7a..90202fb 100644
--- a/pym/portage/localization.py
+++ b/pym/portage/localization.py
@@ -38,5 +38,9 @@ def localized_size(num_bytes):
 
 	# always round up, so that small files don't end up as '0 KiB'
 	num_kib = math.ceil(num_bytes / 1024)
-	formatted_num = locale.format('%d', num_kib, grouping=True)
+	try:
+		formatted_num = locale.format('%d', num_kib, grouping=True)
+	except UnicodeDecodeError:
+		# failure to decode locale data
+		formatted_num = str(num_kib)
 	return (_unicode_decode(formatted_num, encoding=_encodings['stdio']) + ' KiB')


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-05-18 16:45 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2016-05-18 16:45 UTC (permalink / raw
  To: gentoo-commits

commit:     a4e532cee124926c63db74c5af21b4529798f2dd
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May  8 21:50:18 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed May 18 16:44:33 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a4e532ce

Manifest._apply_max_mtime: handle EPERM from utime (bug 582388)

Only warn if utime fails due to the Manifest parent directory
being owned by a different user, since it's not a problem
unless the repo is being prepared for distribution via rsync.

X-Gentoo-bug: 582388
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=582388
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/manifest.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index f696f84..fe4166c 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -1,10 +1,11 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
 
 import errno
 import io
+import logging
 import re
 import stat
 import sys
@@ -15,7 +16,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
 	'portage.checksum:hashfunc_map,perform_multiple_checksums,' + \
 		'verify_all,_apply_hash_filter,_filter_unaccelarated_hashes',
 	'portage.repository.config:_find_invalid_path_char',
-	'portage.util:write_atomic',
+	'portage.util:write_atomic,writemsg_level',
 )
 
 from portage import os
@@ -387,7 +388,17 @@ class Manifest(object):
 
 		if max_mtime is not None:
 			for path in preserved_stats:
-				os.utime(path, (max_mtime, max_mtime))
+				try:
+					os.utime(path, (max_mtime, max_mtime))
+				except OSError as e:
+					# Even though we have write permission, utime fails
+					# with EPERM if path is owned by a different user.
+					# Only warn in this case, since it's not a problem
+					# unless this repo is being prepared for distribution
+					# via rsync.
+					writemsg_level('!!! utime(\'%s\', (%s, %s)): %s\n' %
+						(path, max_mtime, max_mtime, e),
+						level=logging.WARNING, noiselevel=-1)
 
 	def sign(self):
 		""" Sign the Manifest """


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-05-20  9:01 Alexander Berntsen
  0 siblings, 0 replies; 248+ messages in thread
From: Alexander Berntsen @ 2016-05-20  9:01 UTC (permalink / raw
  To: gentoo-commits

commit:     68ad3c50221023f6919d66a1d07d4976da037552
Author:     Alexander Berntsen <bernalex <AT> gentoo <DOT> org>
AuthorDate: Wed May 18 08:24:13 2016 +0000
Commit:     Alexander Berntsen <bernalex <AT> gentoo <DOT> org>
CommitDate: Fri May 20 09:00:20 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=68ad3c50

news.py: Check only for major version when parsing

Only check the major version of news items, as GLEP 42 specifies an
upgrade path for them. Future revisions to news item formats may yield
minor number increments. GLEP 42 further ensures that only
forwards-compatible changes may incur, as incompatible changes demand a
major version increment.

X-Gentoo-Bug: 583560
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=583560
Suggested-by:  Ulrich Müller      <ulm <AT> gentoo.org>
Signed-off-by: Alexander Berntsen <bernalex <AT> gentoo.org>
Acked-by:      Zac Medico         <zmedico <AT> gentoo.org>

 pym/portage/news.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pym/portage/news.py b/pym/portage/news.py
index 784ba70..ea1b947 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -9,6 +9,7 @@ __all__ = ["NewsManager", "NewsItem", "DisplayRestriction",
 	"DisplayInstalledRestriction",
 	"count_unread_news", "display_news_notifications"]
 
+import fnmatch
 import io
 import logging
 import os as _os
@@ -270,7 +271,8 @@ class NewsItem(object):
 			# Optimization to ignore regex matchines on lines that
 			# will never match
 			format_match = _formatRE.match(line)
-			if format_match is not None and format_match.group(1) != '1.0':
+			if (format_match is not None and
+					not fnmatch.fnmatch(format_match.group(1), '1.*')):
 				invalids.append((i + 1, line.rstrip('\n')))
 				break
 			if not line.startswith('D'):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-05-31  1:05 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2016-05-31  1:05 UTC (permalink / raw
  To: gentoo-commits

commit:     bc9cbe9c22531df871abb1991819fdf46736ac93
Author:     Tobias Klausmann <klausman <AT> gentoo <DOT> org>
AuthorDate: Tue May 31 00:59:34 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue May 31 01:04:47 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=bc9cbe9c

xtermTitle: support tmux (bug 584530)

Tmux recently gained its own (optional) terminfo entry,
tmux/tmux-256color. Make Portage recognize that as a term
it can set titles on.

X-Gentoo-bug: 584530
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=584530
Acked-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/output.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index bb7542b..6d8c632 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -234,7 +234,7 @@ def nc_len(mystr):
 	tmp = re.sub(esc_seq + "^m]+m", "", mystr);
 	return len(tmp)
 
-_legal_terms_re = re.compile(r'^(xterm|xterm-color|Eterm|aterm|rxvt|screen|kterm|rxvt-unicode|gnome|interix)')
+_legal_terms_re = re.compile(r'^(xterm|xterm-color|Eterm|aterm|rxvt|screen|kterm|rxvt-unicode|gnome|interix|tmux)')
 _disable_xtermTitle = None
 _max_xtermTitle_len = 253
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-06-29  3:04 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2016-06-29  3:04 UTC (permalink / raw
  To: gentoo-commits

commit:     36a7f18dcbea9072cd6e2d7d923a9c7b4638aab9
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 28 23:56:44 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jun 29 02:57:36 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=36a7f18d

portage.VERSION: compensate for new git tag format

 pym/portage/__init__.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 427f79b..057dc6b 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -645,12 +645,12 @@ if VERSION == 'HEAD':
 					output_lines = output.splitlines()
 					if output_lines:
 						version_split = output_lines[0].split('-')
-						if version_split:
-							VERSION = version_split[0].lstrip('v')
+						if len(version_split) > 1:
+							VERSION = version_split[1]
 							patchlevel = False
-							if len(version_split) > 1:
+							if len(version_split) > 2:
 								patchlevel = True
-								VERSION = "%s_p%s" % (VERSION, version_split[1])
+								VERSION = "%s_p%s" % (VERSION, version_split[2])
 							if len(output_lines) > 1 and output_lines[1] == 'modified':
 								head_timestamp = None
 								if len(output_lines) > 3:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-07-23 23:09 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2016-07-23 23:09 UTC (permalink / raw
  To: gentoo-commits

commit:     bb2f061345fa487061e90922707aab2ddb4b1687
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 23 22:57:23 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jul 23 22:57:23 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=bb2f0613

action_metadata: handle missing _md5_ key (bug 568934)

Since commit 9abbda7d054761ae6c333d3e6d420632b9658b6d, users with
FEATURES=metadata-transfer enabled would receive a KeyError when
an existing cache entry contained _mtime_ instead of _md5_. Fix
it to simply overwrite the cache entry in this case.

Fixes: 9abbda7d0547 ("portage.cache: write md5 instead of mtime (bug 568934)")
X-Gentoo-Bug: 568934
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=568934

 pym/portage/metadata.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/metadata.py b/pym/portage/metadata.py
index 017a838..1abec5a 100644
--- a/pym/portage/metadata.py
+++ b/pym/portage/metadata.py
@@ -149,7 +149,7 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
 					src[dest_chf_key] = dest_chf_getter(ebuild_hash)
 
 				if dest is not None:
-					if not (dest[dest_chf_key] == src[dest_chf_key] and \
+					if not (dest.get(dest_chf_key) == src[dest_chf_key] and \
 						tree_data.eclass_db.validate_and_rewrite_cache(
 							dest['_eclasses_'], tree_data.dest_db.validation_chf,
 							tree_data.dest_db.store_eclass_paths) is not None and \


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-09-15  2:03 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2016-09-15  2:03 UTC (permalink / raw
  To: gentoo-commits

commit:     67fcbccd1b60b599e4e5dcc97f2959164ba6a7eb
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 15 01:30:38 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Sep 15 01:43:42 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=67fcbccd

news: Support News-Item-Format 2.0

Validate Display-If-Installed with EAPI 0 or 5.
Add support for trailing wildcard matching for Display-If-Profile.

Bug: https://bugs.gentoo.org/577372

 pym/portage/news.py | 50 ++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 12 deletions(-)

diff --git a/pym/portage/news.py b/pym/portage/news.py
index 177f9db..28faf83 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -197,6 +197,7 @@ _formatRE = re.compile("News-Item-Format:\s*([^\s]*)\s*$")
 _installedRE = re.compile("Display-If-Installed:(.*)\n")
 _profileRE = re.compile("Display-If-Profile:(.*)\n")
 _keywordRE = re.compile("Display-If-Keyword:(.*)\n")
+_valid_profile_RE = re.compile(r'^[^*]+(/\*)?$')
 
 class NewsItem(object):
 	"""
@@ -266,14 +267,24 @@ class NewsItem(object):
 		f.close()
 		self.restrictions = {}
 		invalids = []
+		news_format = None
+
+		# Look for News-Item-Format
 		for i, line in enumerate(lines):
-			# Optimization to ignore regex matchines on lines that
-			# will never match
 			format_match = _formatRE.match(line)
-			if (format_match is not None and
-					not fnmatch.fnmatch(format_match.group(1), '1.*')):
+			if format_match is not None:
+				news_format = format_match.group(1)
+				if fnmatch.fnmatch(news_format, '[12].*'):
+					break
 				invalids.append((i + 1, line.rstrip('\n')))
-				break
+
+		if news_format is None:
+			invalids.append((0, 'News-Item-Format unspecified'))
+
+		# Parse the rest
+		for i, line in enumerate(lines):
+			# Optimization to ignore regex matches on lines that
+			# will never match
 			if not line.startswith('D'):
 				continue
 			restricts = {  _installedRE : DisplayInstalledRestriction,
@@ -282,13 +293,14 @@ class NewsItem(object):
 			for regex, restriction in restricts.items():
 				match = regex.match(line)
 				if match:
-					restrict = restriction(match.groups()[0].strip())
+					restrict = restriction(match.groups()[0].strip(), news_format)
 					if not restrict.isValid():
 						invalids.append((i + 1, line.rstrip("\n")))
 					else:
 						self.restrictions.setdefault(
 							id(restriction), []).append(restrict)
 					continue
+
 		if invalids:
 			self._valid = False
 			msg = []
@@ -321,13 +333,21 @@ class DisplayProfileRestriction(DisplayRestriction):
 	if the user is running a specific profile.
 	"""
 
-	def __init__(self, profile):
+	def __init__(self, profile, news_format):
 		self.profile = profile
+		self.format = news_format
+
+	def isValid(self):
+		if fnmatch.fnmatch(self.format, '1.*') and '*' in self.profile:
+			return False
+		if fnmatch.fnmatch(self.format, '2.*') and not _valid_profile_RE.match(self.profile):
+			return False
+		return True
 
 	def checkRestriction(self, **kwargs):
-		if self.profile == kwargs['profile']:
-			return True
-		return False
+		if fnmatch.fnmatch(self.format, '2.*') and self.profile.endswith('/*'):
+			return (kwargs['profile'].startswith(self.profile[:-1]))
+		return (kwargs['profile'] == self.profile)
 
 class DisplayKeywordRestriction(DisplayRestriction):
 	"""
@@ -335,8 +355,9 @@ class DisplayKeywordRestriction(DisplayRestriction):
 	if the user is running a specific keyword.
 	"""
 
-	def __init__(self, keyword):
+	def __init__(self, keyword, news_format):
 		self.keyword = keyword
+		self.format = news_format
 
 	def checkRestriction(self, **kwargs):
 		if kwargs['config'].get('ARCH', '') == self.keyword:
@@ -349,10 +370,15 @@ class DisplayInstalledRestriction(DisplayRestriction):
 	if the user has that item installed.
 	"""
 
-	def __init__(self, atom):
+	def __init__(self, atom, news_format):
 		self.atom = atom
+		self.format = news_format
 
 	def isValid(self):
+		if fnmatch.fnmatch(self.format, '1.*'):
+			return isvalidatom(self.atom, eapi='0')
+		if fnmatch.fnmatch(self.format, '2.*'):
+			return isvalidatom(self.atom, eapi='5')
 		return isvalidatom(self.atom)
 
 	def checkRestriction(self, **kwargs):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-09-15  2:03 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2016-09-15  2:03 UTC (permalink / raw
  To: gentoo-commits

commit:     0cb7426796b2fb082f9176b7b08d08b21b5c86bb
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 15 01:30:39 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Sep 15 01:43:42 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=0cb74267

news: skip parsing if News-Item-Format is unspecified

 pym/portage/news.py | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/pym/portage/news.py b/pym/portage/news.py
index 28faf83..6020074 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -280,26 +280,26 @@ class NewsItem(object):
 
 		if news_format is None:
 			invalids.append((0, 'News-Item-Format unspecified'))
-
-		# Parse the rest
-		for i, line in enumerate(lines):
-			# Optimization to ignore regex matches on lines that
-			# will never match
-			if not line.startswith('D'):
-				continue
-			restricts = {  _installedRE : DisplayInstalledRestriction,
-					_profileRE : DisplayProfileRestriction,
-					_keywordRE : DisplayKeywordRestriction }
-			for regex, restriction in restricts.items():
-				match = regex.match(line)
-				if match:
-					restrict = restriction(match.groups()[0].strip(), news_format)
-					if not restrict.isValid():
-						invalids.append((i + 1, line.rstrip("\n")))
-					else:
-						self.restrictions.setdefault(
-							id(restriction), []).append(restrict)
+		else:
+			# Parse the rest
+			for i, line in enumerate(lines):
+				# Optimization to ignore regex matches on lines that
+				# will never match
+				if not line.startswith('D'):
 					continue
+				restricts = {  _installedRE : DisplayInstalledRestriction,
+						_profileRE : DisplayProfileRestriction,
+						_keywordRE : DisplayKeywordRestriction }
+				for regex, restriction in restricts.items():
+					match = regex.match(line)
+					if match:
+						restrict = restriction(match.groups()[0].strip(), news_format)
+						if not restrict.isValid():
+							invalids.append((i + 1, line.rstrip("\n")))
+						else:
+							self.restrictions.setdefault(
+								id(restriction), []).append(restrict)
+						continue
 
 		if invalids:
 			self._valid = False


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-09-15 21:42 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2016-09-15 21:42 UTC (permalink / raw
  To: gentoo-commits

commit:     5c46a42710067d2605ceb00df795d8879feb0471
Author:     Jason Zaman <perfinion <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 29 01:25:05 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Sep 15 19:56:07 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5c46a427

selinux: fix crash for invalid context

When selinux is not fully installed yet the getcon call can sometimes return
"kernel" instead of a correct triple (eg "root:sysadm_r:sysadm_t"). Catch the
IndexError and skip selinux initialization.

Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/portage/util/_async/ForkProcess.py", line 45, in _spawn
    rval = self._run()
  File "/usr/lib64/python2.7/site-packages/_emerge/EbuildFetcher.py", line 172, in _run
    allow_missing_digests=allow_missing):
  File "/usr/lib64/python2.7/site-packages/portage/package/ebuild/fetch.py", line 520, in fetch
    if _userpriv_test_write_file(mysettings, write_test_file):
  File "/usr/lib64/python2.7/site-packages/portage/package/ebuild/fetch.py", line 134, in _userpriv_test_write_file
    returncode = _spawn_fetch(settings, args)
  File "/usr/lib64/python2.7/site-packages/portage/package/ebuild/fetch.py", line 87, in _spawn_fetch
    settings["PORTAGE_FETCH_T"])
  File "/usr/lib64/python2.7/site-packages/portage/_selinux.py", line 122, in __init__
    self._con = settype(selinux_type)
  File "/usr/lib64/python2.7/site-packages/portage/_selinux.py", line 76, in settype
    ret[2] = newtype
IndexError: list assignment index out of range

Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org>

 pym/portage/_selinux.py | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py
index c5e8b2c..985e966 100644
--- a/pym/portage/_selinux.py
+++ b/pym/portage/_selinux.py
@@ -6,6 +6,7 @@
 import os
 import shutil
 import sys
+import warnings
 
 import portage
 from portage import _encodings
@@ -72,9 +73,13 @@ def rename(src, dest):
 		setfscreate()
 
 def settype(newtype):
-	ret = getcontext().split(":")
-	ret[2] = newtype
-	return ":".join(ret)
+	try:
+		ret = getcontext().split(":")
+		ret[2] = newtype
+		return ":".join(ret)
+	except IndexError:
+		warnings.warn("Invalid SELinux context: %s" % getcontext())
+		return None
 
 def setexec(ctx="\n"):
 	ctx = _native_string(ctx, encoding=_encodings['content'], errors='strict')
@@ -122,15 +127,16 @@ class spawn_wrapper(object):
 		self._con = settype(selinux_type)
 
 	def __call__(self, *args, **kwargs):
+		if self._con is not None:
+			pre_exec = kwargs.get("pre_exec")
 
-		pre_exec = kwargs.get("pre_exec")
+			def _pre_exec():
+				if pre_exec is not None:
+					pre_exec()
+				setexec(self._con)
 
-		def _pre_exec():
-			if pre_exec is not None:
-				pre_exec()
-			setexec(self._con)
+			kwargs["pre_exec"] = _pre_exec
 
-		kwargs["pre_exec"] = _pre_exec
 		return self._spawn_func(*args, **kwargs)
 
 def symlink(target, link, reflnk):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-10-02  4:46 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2016-10-02  4:46 UTC (permalink / raw
  To: gentoo-commits

commit:     5ef5fbaab88de47d4dbab333661d3525261d7633
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 26 06:26:35 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 04:33:35 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5ef5fbaa

locks: use fcntl.flock if fcntl.lockf is broken (bug 595146)

This is needed for Windows Subsystem for Linux (WSL), as well as
older versions of PyPy.

X-Gentoo-bug: 595146
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=595146
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/locks.py | 59 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 52 insertions(+), 7 deletions(-)

diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 42ff1e3..f61e181 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -8,8 +8,9 @@ __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \
 
 import errno
 import fcntl
-import platform
+import multiprocessing
 import sys
+import tempfile
 import time
 import warnings
 
@@ -27,17 +28,61 @@ if sys.hexversion >= 0x3000000:
 
 HARDLINK_FD = -2
 _HARDLINK_POLL_LATENCY = 3 # seconds
-_default_lock_fn = fcntl.lockf
-
-if platform.python_implementation() == 'PyPy':
-	# workaround for https://bugs.pypy.org/issue747
-	_default_lock_fn = fcntl.flock
 
 # Used by emerge in order to disable the "waiting for lock" message
 # so that it doesn't interfere with the status display.
 _quiet = False
 
 
+_lock_fn = None
+
+
+def _get_lock_fn():
+	"""
+	Returns fcntl.lockf if proven to work, and otherwise returns fcntl.flock.
+	On some platforms fcntl.lockf is known to be broken.
+	"""
+	global _lock_fn
+	if _lock_fn is not None:
+		return _lock_fn
+
+	def _test_lock(fd, lock_path):
+		os.close(fd)
+		try:
+			with open(lock_path, 'a') as f:
+				fcntl.lockf(f.fileno(), fcntl.LOCK_EX|fcntl.LOCK_NB)
+		except EnvironmentError as e:
+			if e.errno == errno.EAGAIN:
+				# Parent process holds lock, as expected.
+				sys.exit(0)
+
+		# Something went wrong.
+		sys.exit(1)
+
+	fd, lock_path = tempfile.mkstemp()
+	try:
+		try:
+			fcntl.lockf(fd, fcntl.LOCK_EX)
+		except EnvironmentError:
+			pass
+		else:
+			proc = multiprocessing.Process(target=_test_lock,
+				args=(fd, lock_path))
+			proc.start()
+			proc.join()
+			if proc.exitcode == os.EX_OK:
+				# Use fcntl.lockf because the test passed.
+				_lock_fn = fcntl.lockf
+				return _lock_fn
+	finally:
+		os.close(fd)
+		os.unlink(lock_path)
+
+	# Fall back to fcntl.flock.
+	_lock_fn = fcntl.flock
+	return _lock_fn
+
+
 _open_fds = set()
 
 def _close_fds():
@@ -146,7 +191,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
 
 	# try for a non-blocking lock, if it's held, throw a message
 	# we're waiting on lockfile and use a blocking attempt.
-	locking_method = portage._eintr_func_wrapper(_default_lock_fn)
+	locking_method = portage._eintr_func_wrapper(_get_lock_fn())
 	try:
 		if "__PORTAGE_TEST_HARDLINK_LOCKS" in os.environ:
 			raise IOError(errno.ENOSYS, "Function not implemented")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-12-05  5:14 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2016-12-05  5:14 UTC (permalink / raw
  To: gentoo-commits

commit:     0473d6bc3b879fa5ce8182c7e241122cb93887d3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 30 02:58:28 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Dec  5 05:13:15 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=0473d6bc

portage/versions.py: Pyflakes and Whitespace cleanup

 pym/portage/versions.py | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index 1ca9a36..a028d93 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -127,7 +127,7 @@ def vercmp(ver1, ver2, silent=1):
 		positive number
 		>>> vercmp('1.0_p3','1.0_p3')
 		0
-	
+
 	@param pkg1: version to compare with (see ver_regexp in portage.versions.py)
 	@type pkg1: string (example: "2.1.2-r3")
 	@param pkg2: version to compare againts (see ver_regexp in portage.versions.py)
@@ -135,7 +135,7 @@ def vercmp(ver1, ver2, silent=1):
 	@rtype: None or float
 	@return:
 	1. positive if ver1 is greater than ver2
-	2. negative if ver1 is less than ver2 
+	2. negative if ver1 is less than ver2
 	3. 0 if ver1 equals ver2
 	4. None if ver1 or ver2 are invalid (see ver_regexp in portage.versions.py)
 	"""
@@ -145,7 +145,7 @@ def vercmp(ver1, ver2, silent=1):
 
 	match1 = ver_regexp.match(ver1)
 	match2 = ver_regexp.match(ver2)
-	
+
 	# checking that the versions are valid
 	if not match1 or not match1.groups():
 		if not silent:
@@ -161,7 +161,7 @@ def vercmp(ver1, ver2, silent=1):
 		return 1
 	elif match2.group(1) and not match1.group(1):
 		return -1
-	
+
 	# building lists of the version parts before the suffix
 	# first part is simple
 	list1 = [int(match1.group(2))]
@@ -225,7 +225,7 @@ def vercmp(ver1, ver2, silent=1):
 	# main version is equal, so now compare the _suffix part
 	list1 = match1.group(6).split("_")[1:]
 	list2 = match2.group(6).split("_")[1:]
-	
+
 	for i in range(0, max(len(list1), len(list2))):
 		# Implicit _p0 is given a value of -1, so that 1 < 1_p0
 		if len(list1) <= i:
@@ -267,7 +267,7 @@ def vercmp(ver1, ver2, silent=1):
 		r2 = 0
 	rval = (r1 > r2) - (r1 < r2)
 	return rval
-	
+
 def pkgcmp(pkg1, pkg2):
 	"""
 	Compare 2 package versions created in pkgsplit format.
@@ -284,10 +284,10 @@ def pkgcmp(pkg1, pkg2):
 	@param pkg2: package to compare againts
 	@type pkg2: list (example: ['test', '1.0', 'r1'])
 	@rtype: None or integer
-	@return: 
+	@return:
 		1. None if package names are not the same
 		2. 1 if pkg1 is greater than pkg2
-		3. -1 if pkg1 is less than pkg2 
+		3. -1 if pkg1 is less than pkg2
 		4. 0 if pkg1 equals pkg2
 	"""
 	if pkg1[0] != pkg2[0]:
@@ -314,7 +314,7 @@ def _pkgsplit(mypkg, eapi=None):
 		rev = '0'
 	rev = 'r' + rev
 
-	return  (m.group('pn'), m.group('ver'), rev) 
+	return  (m.group('pn'), m.group('ver'), rev)
 
 _cat_re = re.compile('^%s$' % _cat, re.UNICODE)
 _missing_cat = 'null'
@@ -322,9 +322,9 @@ _missing_cat = 'null'
 def catpkgsplit(mydata, silent=1, eapi=None):
 	"""
 	Takes a Category/Package-Version-Rev and returns a list of each.
-	
+
 	@param mydata: Data to split
-	@type mydata: string 
+	@type mydata: string
 	@param silent: suppress error messages
 	@type silent: Boolean (integer)
 	@rype: list
@@ -449,7 +449,6 @@ class _pkg_str(_unicode):
 			return self._stable
 		except AttributeError:
 			try:
-				metadata = self._metadata
 				settings = self._settings
 			except AttributeError:
 				raise AttributeError('stable')


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-12-06  3:54 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2016-12-06  3:54 UTC (permalink / raw
  To: gentoo-commits

commit:     1540d5eb4d8ab7f6a4813462acf9774f1e7ecc0e
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  5 19:56:02 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Dec  5 20:35:36 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=1540d5eb

portage/__init__.py: Fix live versioning to look for portage tags only

 pym/portage/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 057dc6b..c8e8b56 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -631,7 +631,7 @@ if VERSION == 'HEAD':
 				return VERSION
 			if os.path.isdir(os.path.join(PORTAGE_BASE_PATH, '.git')):
 				encoding = _encodings['fs']
-				cmd = [BASH_BINARY, "-c", ("cd %s ; git describe --tags || exit $? ; " + \
+				cmd = [BASH_BINARY, "-c", ("cd %s ; git describe --match 'portage-*' || exit $? ; " + \
 					"if [ -n \"`git diff-index --name-only --diff-filter=M HEAD`\" ] ; " + \
 					"then echo modified ; git rev-list --format=%%ct -n 1 HEAD ; fi ; " + \
 					"exit 0") % _shell_quote(PORTAGE_BASE_PATH)]


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2016-12-06  3:54 Brian Dolbec
  0 siblings, 0 replies; 248+ messages in thread
From: Brian Dolbec @ 2016-12-06  3:54 UTC (permalink / raw
  To: gentoo-commits

commit:     1aae3773185d4338f12b4305b6b5abcd501e7a4a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  5 19:56:27 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Dec  5 20:35:36 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=1aae3773

portage/__init__.py: Whitespace cleanup

 pym/portage/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index c8e8b56..0e036b1 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -217,7 +217,7 @@ class _unicode_func_wrapper(object):
 	and return values to unicode from bytes. Function calls
 	will raise UnicodeEncodeError if an argument fails to be
 	encoded with the required encoding. Return values that
-	are single strings are decoded with errors='replace'. Return 
+	are single strings are decoded with errors='replace'. Return
 	values that are lists of strings are decoded with errors='strict'
 	and elements that fail to be decoded are omitted from the returned
 	list.


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-01-17 17:43 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2017-01-17 17:43 UTC (permalink / raw
  To: gentoo-commits

commit:     9a506b4d7429a589416eee48d02ca7ed42ef1898
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 10 00:48:59 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jan 17 17:42:51 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9a506b4d

glsa: Separate "Vulnerable" and "Unaffected" by comma/space

 pym/portage/glsa.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 1b19fb1..5e6662d 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -617,8 +617,8 @@ class Glsa:
 			for k in self.packages:
 				pkg = self.packages[k]
 				for path in pkg:
-					vul_vers = "".join(path["vul_vers"])
-					unaff_vers = "".join(path["unaff_vers"])
+					vul_vers = ", ".join(path["vul_vers"])
+					unaff_vers = ", ".join(path["unaff_vers"])
 					outstream.write(_("Affected package:  %s\n") % k)
 					outstream.write(_("Affected archs:    "))
 					if path["arch"] == "*":


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-01-20  7:28 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2017-01-20  7:28 UTC (permalink / raw
  To: gentoo-commits

commit:     aa0cf0c993759f559988c8d0d6ea50be8cf716ce
Author:     Aaron Bauman <bman <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 20 06:50:54 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jan 20 07:26:52 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=aa0cf0c9

Properly retrieve the count attribute and adjust logic to properly support both GLSA formats

X-Gentoo-Bug: 605612
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=605612

 pym/portage/glsa.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 5e6662d..ea3819b 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -533,8 +533,8 @@ class Glsa:
 		# <revised count="2">2007-12-30</revised>
 		revisedEl = myroot.getElementsByTagName("revised")[0]
 		self.revised = getText(revisedEl, format="strip")
-		count = revisedEl.attributes.get("count")
-		if count is None:
+		count = revisedEl.getAttribute("count")
+		if not count:
 			if self.revised.find(":") >= 0:
 				(self.revised, count) = self.revised.split(":")
 			else:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-01-27  0:04 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2017-01-27  0:04 UTC (permalink / raw
  To: gentoo-commits

commit:     ccf975296daec92d376c4989e5ffb2a6cdbe8a2d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 26 00:12:45 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jan 26 19:13:17 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ccf97529

spawn: instantiate userpriv_groups before fork (bug 582098)

Make spawn force instantiation of portage.data.userpriv_groups in the
main process, in order to avoid redundant instantiation in child
processes. This mitigates the impact of "Bad file descriptor" errors
reported in bug 582098, by avoiding redundant instantiation of
userpriv_groups in child processes. It may even solve the problem
completely, if the "Bad file descriptor" errors are triggered by
interactions between garbage collection and the file descriptor
operations performed in the _exec function by the _setup_pipes call.

X-Gentoo-Bug: 582098
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=582098

 pym/portage/process.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index ba41ea8..bc4efb5 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -305,6 +305,10 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 	if unshare_net or unshare_ipc:
 		find_library("c")
 
+	# Force instantiation of portage.data.userpriv_groups before the
+	# fork, so that the result is cached in the main process.
+	bool(groups)
+
 	parent_pid = os.getpid()
 	pid = None
 	try:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-02-28 22:07 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-02-28 22:07 UTC (permalink / raw
  To: gentoo-commits

commit:     804bd357327e71bacef69b51ed9abbeb9a2c95a7
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 28 07:57:41 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Feb 28 22:07:09 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=804bd357

checksum: Add summary on top to help following the logic

Add a summary of all supported digest algorithms on top of the file
along with the supported implementations and their order of preference.
This will help people follow the crazy logic below.

 pym/portage/checksum.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index cdf467003..319252315 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -1,5 +1,5 @@
 # checksum.py -- core Portage functionality
-# Copyright 1998-2014 Gentoo Foundation
+# Copyright 1998-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import portage
@@ -13,6 +13,19 @@ import stat
 import subprocess
 import tempfile
 
+
+# Summary of all available hashes and their implementations,
+# most preferred first. Please keep this in sync with logic below.
+# ================================================================
+#
+# MD5: python-fchksum, hashlib, mhash, hashlib/md5
+# SHA1: hashlib, mhash, hashlib/sha1
+# SHA256: hashlib, pycrypto, mhash
+# SHA512: hashlib, mhash
+# RMD160: hashlib, pycrypto, mhash
+# WHIRLPOOL: hashlib, mhash, bundled
+
+
 #dict of all available hash functions
 hashfunc_map = {}
 hashorigin_map = {}


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-02-28 22:07 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-02-28 22:07 UTC (permalink / raw
  To: gentoo-commits

commit:     59c1b58469ee9bf0bd0158a0bdbd10defd872415
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 28 08:01:59 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Feb 28 22:07:09 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=59c1b584

checksum: Remove redundant internal fallbacks

Remove the internal digest fallbacks since they have no real use
nowadays. The hashlib versions are preferred later in the logic anyway,
and they are available since Python 2.5.

 pym/portage/checksum.py | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 319252315..8b4d96e30 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -18,8 +18,8 @@ import tempfile
 # most preferred first. Please keep this in sync with logic below.
 # ================================================================
 #
-# MD5: python-fchksum, hashlib, mhash, hashlib/md5
-# SHA1: hashlib, mhash, hashlib/sha1
+# MD5: python-fchksum, hashlib, mhash
+# SHA1: hashlib, mhash
 # SHA256: hashlib, pycrypto, mhash
 # SHA512: hashlib, mhash
 # RMD160: hashlib, pycrypto, mhash
@@ -77,21 +77,6 @@ class _generate_hash_function(object):
 # Define hash functions, try to use the best module available. Later definitions
 # override earlier ones
 
-# Use the internal modules as last fallback
-try:
-	from hashlib import md5 as _new_md5
-except ImportError:
-	from md5 import new as _new_md5
-
-md5hash = _generate_hash_function("MD5", _new_md5, origin="internal")
-
-try:
-	from hashlib import sha1 as _new_sha1
-except ImportError:
-	from sha import new as _new_sha1
-
-sha1hash = _generate_hash_function("SHA1", _new_sha1, origin="internal")
-
 # Try to use mhash if available
 # mhash causes GIL presently, so it gets less priority than hashlib and
 # pycrypto. However, it might be the only accelerated implementation of


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-02-28 22:07 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-02-28 22:07 UTC (permalink / raw
  To: gentoo-commits

commit:     5f0f383c852ede3368ede31f05eb6880a2f29455
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 28 08:17:51 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Feb 28 22:07:10 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5f0f383c

checksum: Add blake2* and sha3 hashes from hashlib 3.6+

Add initial support for using the new SHA3_256 and SHA3_512, as well
as competitive BLAKE2b and BLAKE2s hashes that are now provided
in hashlib module of Python 3.6.

Approved-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/checksum.py | 14 +++++++++++++-
 pym/portage/const.py    |  6 ++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 8b4d96e30..a46b820af 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -24,6 +24,10 @@ import tempfile
 # SHA512: hashlib, mhash
 # RMD160: hashlib, pycrypto, mhash
 # WHIRLPOOL: hashlib, mhash, bundled
+# BLAKE2B (512): hashlib (3.6+)
+# BLAKE2S (512): hashlib (3.6+)
+# SHA3_256: hashlib (3.6+)
+# SHA3_512: hashlib (3.6+)
 
 
 #dict of all available hash functions
@@ -121,7 +125,15 @@ try:
 	sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
 	sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
 	sha512hash = _generate_hash_function("SHA512", hashlib.sha512, origin="hashlib")
-	for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")):
+	for local_name, hash_name in (
+			("rmd160", "ripemd160"),
+			("whirlpool", "whirlpool"),
+			# available since Python 3.6
+			("BLAKE2B", "blake2b"),
+			("BLAKE2S", "blake2s"),
+			("SHA3_256", "sha3_256"),
+			("SHA3_512", "sha3_512"),
+			):
 		try:
 			hashlib.new(hash_name)
 		except ValueError:

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 179efce98..0cef2e8ae 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -224,9 +224,6 @@ MANIFEST1_REQUIRED_HASH  = "MD5"
 # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
 #     manifest-hashes = SHA512 WHIRLPOOL
 #
-# After SHA-3 is approved:
-# - Add new hashes to MANIFEST2_HASH_*.
-#
 # After SHA-3 is supported in stable portage:
 # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
 #     manifest-hashes = SHA3 SHA512 WHIRLPOOL
@@ -234,7 +231,8 @@ MANIFEST1_REQUIRED_HASH  = "MD5"
 # After layout.conf settings correspond to defaults in stable portage:
 # - Remove redundant settings from gentoo-x86/metadata/layout.conf.
 
-MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL")
+MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL",
+		"BLAKE2B", "BLAKE2S", "SHA3_256", "SHA3_512")
 MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"])
 MANIFEST2_REQUIRED_HASH  = "SHA256"
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-01 15:43 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-01 15:43 UTC (permalink / raw
  To: gentoo-commits

commit:     929f27a8ee7025c3ed29715437dc6bbdbba01f21
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 28 22:22:43 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Mar  1 15:42:39 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=929f27a8

checksum: Add pycryptodome fallbacks for SHA3 and BLAKE2

Approved-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/checksum.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index fc38417a7..042a0a745 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -116,6 +116,28 @@ try:
 except ImportError:
 	pass
 
+try:
+	# added in pycryptodome
+	from Crypto.Hash import BLAKE2b, BLAKE2s, SHA3_256, SHA3_512
+	blake2bhash_ = getattr(BLAKE2b, 'new', None)
+	if blake2bhash_ is not None:
+		blake2bhash = _generate_hash_function("BLAKE2B",
+			blake2bhash_, origin="pycrypto")
+	blake2shash_ = getattr(BLAKE2s, 'new', None)
+	if blake2shash_ is not None:
+		blake2shash = _generate_hash_function("BLAKE2S",
+			blake2shash_, origin="pycrypto")
+	sha3_256hash_ = getattr(SHA3_256, 'new', None)
+	if sha3_256hash_ is not None:
+		sha3_256hash = _generate_hash_function("SHA3_256",
+			sha3_256hash_, origin="pycrypto")
+	sha3_512hash_ = getattr(SHA3_512, 'new', None)
+	if sha3_512hash_ is not None:
+		sha3_512hash = _generate_hash_function("SHA3_512",
+			sha3_512hash_, origin="pycrypto")
+except ImportError:
+	pass
+
 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
 # Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib.
 try:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-01 15:43 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-01 15:43 UTC (permalink / raw
  To: gentoo-commits

commit:     1c7b39c6cb89da22038291ae69528ac5486fd10c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 28 22:15:20 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Mar  1 15:42:24 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=1c7b39c6

checksum: Fix overriding fallbacks on broken pycrypto

The pycrypto override used the same variables as actual hash functions
before determining whether its functions are useful. As a result, if
pycrypto had a broken module and no hash function was generated,
the possible previous implementation was replaced by None.

 pym/portage/checksum.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index a46b820af..fc38417a7 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -105,14 +105,14 @@ except ImportError:
 # is broken somehow.
 try:
 	from Crypto.Hash import SHA256, RIPEMD
-	sha256hash = getattr(SHA256, 'new', None)
-	if sha256hash is not None:
+	sha256hash_ = getattr(SHA256, 'new', None)
+	if sha256hash_ is not None:
 		sha256hash = _generate_hash_function("SHA256",
-			sha256hash, origin="pycrypto")
-	rmd160hash = getattr(RIPEMD, 'new', None)
-	if rmd160hash is not None:
+			sha256hash_, origin="pycrypto")
+	rmd160hash_ = getattr(RIPEMD, 'new', None)
+	if rmd160hash_ is not None:
 		rmd160hash = _generate_hash_function("RMD160",
-			rmd160hash, origin="pycrypto")
+			rmd160hash_, origin="pycrypto")
 except ImportError:
 	pass
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     83a17574cae30ec81adc64f59c55a0eb6b2be064
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 15:51:35 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:30 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=83a17574

portage.checksum: Stop exposing global hash variables

Stop exposing global variables such as 'md5hash'. Those are not used
anywhere anymore, exposing them makes the code more complex and makes it
easy to accidentally fail to set them properly (this happened already
for SHA3). Instead, rely on them being inserted into hashfunc_map.

 pym/portage/checksum.py | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 68ed44fa9..659012cdc 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -102,11 +102,10 @@ class _generate_hash_function(object):
 # WHIRLPOOL available.
 try:
 	import mhash
-	for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")):
-		if hasattr(mhash, 'MHASH_%s' % local_name.upper()):
-			globals()['%shash' % local_name] = \
-				_generate_hash_function(local_name.upper(), \
-				functools.partial(mhash.MHASH, getattr(mhash, 'MHASH_%s' % hash_name.upper())), \
+	for local_name, hash_name in (("RMD160", "RIPEMD160"), ("WHIRLPOOL", "WHIRLPOOL")):
+		if hasattr(mhash, 'MHASH_%s' % hash_name):
+			_generate_hash_function(local_name,
+				functools.partial(mhash.MHASH, getattr(mhash, 'MHASH_%s' % hash_name)),
 				origin='mhash')
 except ImportError:
 	pass
@@ -118,7 +117,7 @@ try:
 	from Crypto.Hash import RIPEMD
 	rmd160hash_ = getattr(RIPEMD, 'new', None)
 	if rmd160hash_ is not None:
-		rmd160hash = _generate_hash_function("RMD160",
+		_generate_hash_function("RMD160",
 			rmd160hash_, origin="pycrypto")
 except ImportError:
 	pass
@@ -129,19 +128,19 @@ try:
 
 	blake2bhash_ = getattr(BLAKE2b, 'new', None)
 	if blake2bhash_ is not None:
-		blake2bhash = _generate_hash_function("BLAKE2B",
+		_generate_hash_function("BLAKE2B",
 			functools.partial(blake2bhash_, digest_bytes=64), origin="pycrypto")
 	blake2shash_ = getattr(BLAKE2s, 'new', None)
 	if blake2shash_ is not None:
-		blake2shash = _generate_hash_function("BLAKE2S",
+		_generate_hash_function("BLAKE2S",
 			functools.partial(blake2shash_, digest_bytes=32), origin="pycrypto")
 	sha3_256hash_ = getattr(SHA3_256, 'new', None)
 	if sha3_256hash_ is not None:
-		sha3_256hash = _generate_hash_function("SHA3_256",
+		_generate_hash_function("SHA3_256",
 			sha3_256hash_, origin="pycrypto")
 	sha3_512hash_ = getattr(SHA3_512, 'new', None)
 	if sha3_512hash_ is not None:
-		sha3_512hash = _generate_hash_function("SHA3_512",
+		_generate_hash_function("SHA3_512",
 			sha3_512hash_, origin="pycrypto")
 except ImportError:
 	pass
@@ -150,20 +149,20 @@ except ImportError:
 try:
 	import sha3
 
-	sha3_256hash = _generate_hash_function("SHA3_256", sha3.sha3_256, origin="pysha3")
-	sha3_512hash = _generate_hash_function("SHA3_512", sha3.sha3_512, origin="pysha3")
+	_generate_hash_function("SHA3_256", sha3.sha3_256, origin="pysha3")
+	_generate_hash_function("SHA3_512", sha3.sha3_512, origin="pysha3")
 except ImportError:
 	pass
 
 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
 # Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib.
-md5hash = _generate_hash_function("MD5", hashlib.md5, origin="hashlib")
-sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
-sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
-sha512hash = _generate_hash_function("SHA512", hashlib.sha512, origin="hashlib")
+_generate_hash_function("MD5", hashlib.md5, origin="hashlib")
+_generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
+_generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
+_generate_hash_function("SHA512", hashlib.sha512, origin="hashlib")
 for local_name, hash_name in (
-		("rmd160", "ripemd160"),
-		("whirlpool", "whirlpool"),
+		("RMD160", "ripemd160"),
+		("WHIRLPOOL", "whirlpool"),
 		# available since Python 3.6
 		("BLAKE2B", "blake2b"),
 		("BLAKE2S", "blake2s"),
@@ -175,9 +174,8 @@ for local_name, hash_name in (
 	except ValueError:
 		pass
 	else:
-		globals()['%shash' % local_name] = \
-			_generate_hash_function(local_name.upper(), \
-			functools.partial(hashlib.new, hash_name), \
+		_generate_hash_function(local_name,
+			functools.partial(hashlib.new, hash_name),
 			origin='hashlib')
 
 _whirlpool_unaccelerated = False
@@ -185,7 +183,7 @@ if "WHIRLPOOL" not in hashfunc_map:
 	# Bundled WHIRLPOOL implementation
 	_whirlpool_unaccelerated = True
 	from portage.util.whirlpool import new as _new_whirlpool
-	whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
+	_generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
 
 
 # There is only one implementation for size


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     0751158e5de176befeed5cb694342a1f0e19e895
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 15:21:44 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:29 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=0751158e

portage.checksum: Fix BLAKE2* fallbacks from pycryptodome

Fix BLAKE2* fallback functions to explicitly provide digest length as
required by pycryptodome.

 pym/portage/checksum.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 9ba251f29..82e8bec00 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -132,14 +132,16 @@ except ImportError:
 try:
 	# added in pycryptodome
 	from Crypto.Hash import BLAKE2b, BLAKE2s, SHA3_256, SHA3_512
+	import functools
+
 	blake2bhash_ = getattr(BLAKE2b, 'new', None)
 	if blake2bhash_ is not None:
 		blake2bhash = _generate_hash_function("BLAKE2B",
-			blake2bhash_, origin="pycrypto")
+			functools.partial(blake2bhash_, digest_bytes=64), origin="pycrypto")
 	blake2shash_ = getattr(BLAKE2s, 'new', None)
 	if blake2shash_ is not None:
 		blake2shash = _generate_hash_function("BLAKE2S",
-			blake2shash_, origin="pycrypto")
+			functools.partial(blake2shash_, digest_bytes=32), origin="pycrypto")
 	sha3_256hash_ = getattr(SHA3_256, 'new', None)
 	if sha3_256hash_ is not None:
 		sha3_256hash = _generate_hash_function("SHA3_256",


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     74ac4204f1d17c07f1b84c139b2484da8b95b98d
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 14:16:23 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:29 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=74ac4204

portage.checksum: Support getting byte string checksums

Add a checksum_str() method to Portage hashes and a matching function to
make it possible to compute checksums of arbitrary bytestrings rather
than just files.

 pym/portage/checksum.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 67d6a544f..9ba251f29 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -59,6 +59,18 @@ class _generate_hash_function(object):
 		hashfunc_map[hashtype] = self
 		hashorigin_map[hashtype] = origin
 
+	def checksum_str(self, data):
+		"""
+		Obtain a checksum of a byte-string.
+
+		@param data: Data to hash
+		@type data: bytes
+		@return: The hash of the data (hex-digest)
+		"""
+		checksum = self._hashobject()
+		checksum.update(data)
+		return checksum.hexdigest()
+
 	def checksum_file(self, filename):
 		"""
 		Run a checksum against a file.
@@ -461,3 +473,20 @@ def perform_multiple_checksums(filename, hashes=["MD5"], calc_prelink=0):
 			raise portage.exception.DigestException(x+" hash function not available (needs dev-python/pycrypto or >=dev-lang/python-2.5)")
 		rVal[x] = perform_checksum(filename, x, calc_prelink)[0]
 	return rVal
+
+
+def checksum_str(data, hashname="MD5"):
+	"""
+	Run a specific checksum against a byte string.
+
+	@param filename: Data to checksum
+	@type filename: Bytes
+	@param hashname: The type of hash function to run
+	@type hashname: String
+	@rtype: String
+	@return: The hash (hex-digest) of the data
+	"""
+	if hashname not in hashfunc_map:
+		raise portage.exception.DigestException(hashname + \
+			" hash function not available (needs dev-python/pycrypto)")
+	return hashfunc_map[hashname].checksum_str(data)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     cd23be212c0ae60034c833873502bb36ee27e94c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 12:12:31 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:28 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cd23be21

portage.checksum: Support pysha3 fallback for SHA3

pysha3 provides a stand-alone FIPS-compliant SHA3 implementation that
can be used as a fallback for Python < 3.6.

 pym/portage/checksum.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index ac11d3f4b..3e61acdec 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -10,6 +10,7 @@ from portage import _encodings
 from portage import _unicode_decode, _unicode_encode
 import errno
 import stat
+import sys
 import subprocess
 import tempfile
 
@@ -26,8 +27,8 @@ import tempfile
 # WHIRLPOOL: hashlib, mhash, bundled
 # BLAKE2B (512): hashlib (3.6+), pycrypto
 # BLAKE2S (512): hashlib (3.6+), pycrypto
-# SHA3_256: hashlib (3.6+), pycrypto
-# SHA3_512: hashlib (3.6+), pycrypto
+# SHA3_256: hashlib (3.6+), pysha3, pycrypto
+# SHA3_512: hashlib (3.6+), pysha3, pycrypto
 
 
 #dict of all available hash functions
@@ -138,6 +139,15 @@ try:
 except ImportError:
 	pass
 
+# Support using pysha3 as fallback for python<3.6
+try:
+	import sha3
+
+	sha3_256hash = _generate_hash_function("SHA3_256", sha3.sha3_256, origin="pysha3")
+	sha3_512hash = _generate_hash_function("SHA3_512", sha3.sha3_512, origin="pysha3")
+except ImportError:
+	pass
+
 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
 # Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib.
 try:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     3e5a2b3057bd77f965b30a80e4e914d428ad6617
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 14:23:21 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:29 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3e5a2b30

portage.checksum: Remove python-fchksum support

Remove the support for MD5 implementation from python-fchksum package.
The package is rarely installed, supports Python 2.7 only and the code
handles checksumming a whole file only.

 pym/portage/checksum.py | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 3e61acdec..9f88f7e65 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -19,7 +19,7 @@ import tempfile
 # most preferred first. Please keep this in sync with logic below.
 # ================================================================
 #
-# MD5: python-fchksum, hashlib, mhash
+# MD5: hashlib, mhash
 # SHA1: hashlib, mhash
 # SHA256: hashlib, pycrypto, mhash
 # SHA512: hashlib, mhash
@@ -186,15 +186,6 @@ if "WHIRLPOOL" not in hashfunc_map:
 	from portage.util.whirlpool import new as _new_whirlpool
 	whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
 
-# Use python-fchksum if available, prefer it over all other MD5 implementations
-try:
-	from fchksum import fmd5t as md5hash
-	hashfunc_map["MD5"] = md5hash
-	hashorigin_map["MD5"] = "python-fchksum"
-
-except ImportError:
-	pass
-
 # There is only one implementation for size
 def getsize(filename):
 	size = os.stat(filename).st_size


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     b55246ef32bf35d24977c7dda7a4ace946ebf476
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 11:49:08 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:28 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b55246ef

portage.checksum: Update fallback doc for SHA3/BLAKE2*

 pym/portage/checksum.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 042a0a745..ac11d3f4b 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -24,10 +24,10 @@ import tempfile
 # SHA512: hashlib, mhash
 # RMD160: hashlib, pycrypto, mhash
 # WHIRLPOOL: hashlib, mhash, bundled
-# BLAKE2B (512): hashlib (3.6+)
-# BLAKE2S (512): hashlib (3.6+)
-# SHA3_256: hashlib (3.6+)
-# SHA3_512: hashlib (3.6+)
+# BLAKE2B (512): hashlib (3.6+), pycrypto
+# BLAKE2S (512): hashlib (3.6+), pycrypto
+# SHA3_256: hashlib (3.6+), pycrypto
+# SHA3_512: hashlib (3.6+), pycrypto
 
 
 #dict of all available hash functions


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     42fa52af521867b45b56f091c91b7b6aa78ba677
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 15:33:28 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:29 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=42fa52af

portage.checksum: Remove fallbacks for algorithms guaranteed since py2.7

The MD5, SHA1 and SHA2 algorithms are guaranteed to be available in
hashlib for Python 2.7 and newer, making the fallbacks to other
implementations meaningless. Remove them to simplify the code.

 pym/portage/checksum.py | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 82e8bec00..7812791ad 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -19,10 +19,10 @@ import tempfile
 # most preferred first. Please keep this in sync with logic below.
 # ================================================================
 #
-# MD5: hashlib, mhash
-# SHA1: hashlib, mhash
-# SHA256: hashlib, pycrypto, mhash
-# SHA512: hashlib, mhash
+# MD5: hashlib
+# SHA1: hashlib
+# SHA256: hashlib
+# SHA512: hashlib
 # RMD160: hashlib, pycrypto, mhash
 # WHIRLPOOL: hashlib, mhash, bundled
 # BLAKE2B (512): hashlib (3.6+), pycrypto
@@ -100,10 +100,6 @@ class _generate_hash_function(object):
 # WHIRLPOOL available.
 try:
 	import mhash, functools
-	md5hash = _generate_hash_function("MD5", functools.partial(mhash.MHASH, mhash.MHASH_MD5), origin="mhash")
-	sha1hash = _generate_hash_function("SHA1", functools.partial(mhash.MHASH, mhash.MHASH_SHA1), origin="mhash")
-	sha256hash = _generate_hash_function("SHA256", functools.partial(mhash.MHASH, mhash.MHASH_SHA256), origin="mhash")
-	sha512hash = _generate_hash_function("SHA512", functools.partial(mhash.MHASH, mhash.MHASH_SHA512), origin="mhash")
 	for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")):
 		if hasattr(mhash, 'MHASH_%s' % local_name.upper()):
 			globals()['%shash' % local_name] = \
@@ -117,11 +113,7 @@ except ImportError:
 # Check for 'new' attributes, since they can be missing if the module
 # is broken somehow.
 try:
-	from Crypto.Hash import SHA256, RIPEMD
-	sha256hash_ = getattr(SHA256, 'new', None)
-	if sha256hash_ is not None:
-		sha256hash = _generate_hash_function("SHA256",
-			sha256hash_, origin="pycrypto")
+	from Crypto.Hash import RIPEMD
 	rmd160hash_ = getattr(RIPEMD, 'new', None)
 	if rmd160hash_ is not None:
 		rmd160hash = _generate_hash_function("RMD160",


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     121e8a21abfad35f1a571bdbf228c3400e1e8f00
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 14:12:37 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:29 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=121e8a21

portage.checksum: create explicit checksum_file() method

Make the file checksum generation code use an explicit checksum_file()
method rather than implicit __call__. This should be more readable,
and make it cleanly possible to add more methods.

 pym/portage/checksum.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 9f88f7e65..67d6a544f 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -59,7 +59,7 @@ class _generate_hash_function(object):
 		hashfunc_map[hashtype] = self
 		hashorigin_map[hashtype] = origin
 
-	def __call__(self, filename):
+	def checksum_file(self, filename):
 		"""
 		Run a checksum against a file.
 	
@@ -186,11 +186,14 @@ if "WHIRLPOOL" not in hashfunc_map:
 	from portage.util.whirlpool import new as _new_whirlpool
 	whirlpoolhash = _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
 
+
 # There is only one implementation for size
-def getsize(filename):
-	size = os.stat(filename).st_size
-	return (size, size)
-hashfunc_map["size"] = getsize
+class SizeHash(object):
+	def checksum_file(self, filename):
+		size = os.stat(filename).st_size
+		return (size, size)
+
+hashfunc_map["size"] = SizeHash()
 
 # end actual hash functions
 
@@ -420,7 +423,7 @@ def perform_checksum(filename, hashname="MD5", calc_prelink=0):
 			if hashname not in hashfunc_map:
 				raise portage.exception.DigestException(hashname + \
 					" hash function not available (needs dev-python/pycrypto)")
-			myhash, mysize = hashfunc_map[hashname](myfilename)
+			myhash, mysize = hashfunc_map[hashname].checksum_file(myfilename)
 		except (OSError, IOError) as e:
 			if e.errno in (errno.ENOENT, errno.ESTALE):
 				raise portage.exception.FileNotFound(myfilename)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     d0cbfdccc26707abbbad2ceb1040988a03da87fb
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 15:39:12 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:29 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d0cbfdcc

portage.checksum: Remove exception handling for missing hashlib

Remove the try-except block for potential ImportError of hashlib.
The hashlib module should be available in all supported Python versions,
and we do not really test or support the case when it is not available.

 pym/portage/checksum.py | 55 ++++++++++++++++++++++---------------------------
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 7812791ad..68ed44fa9 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -9,6 +9,8 @@ from portage import os
 from portage import _encodings
 from portage import _unicode_decode, _unicode_encode
 import errno
+import functools
+import hashlib
 import stat
 import sys
 import subprocess
@@ -99,7 +101,7 @@ class _generate_hash_function(object):
 # pycrypto. However, it might be the only accelerated implementation of
 # WHIRLPOOL available.
 try:
-	import mhash, functools
+	import mhash
 	for local_name, hash_name in (("rmd160", "ripemd160"), ("whirlpool", "whirlpool")):
 		if hasattr(mhash, 'MHASH_%s' % local_name.upper()):
 			globals()['%shash' % local_name] = \
@@ -124,7 +126,6 @@ except ImportError:
 try:
 	# added in pycryptodome
 	from Crypto.Hash import BLAKE2b, BLAKE2s, SHA3_256, SHA3_512
-	import functools
 
 	blake2bhash_ = getattr(BLAKE2b, 'new', None)
 	if blake2bhash_ is not None:
@@ -156,34 +157,28 @@ except ImportError:
 
 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
 # Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib.
-try:
-	import hashlib, functools
-	
-	md5hash = _generate_hash_function("MD5", hashlib.md5, origin="hashlib")
-	sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
-	sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
-	sha512hash = _generate_hash_function("SHA512", hashlib.sha512, origin="hashlib")
-	for local_name, hash_name in (
-			("rmd160", "ripemd160"),
-			("whirlpool", "whirlpool"),
-			# available since Python 3.6
-			("BLAKE2B", "blake2b"),
-			("BLAKE2S", "blake2s"),
-			("SHA3_256", "sha3_256"),
-			("SHA3_512", "sha3_512"),
-			):
-		try:
-			hashlib.new(hash_name)
-		except ValueError:
-			pass
-		else:
-			globals()['%shash' % local_name] = \
-				_generate_hash_function(local_name.upper(), \
-				functools.partial(hashlib.new, hash_name), \
-				origin='hashlib')
-
-except ImportError:
-	pass
+md5hash = _generate_hash_function("MD5", hashlib.md5, origin="hashlib")
+sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
+sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
+sha512hash = _generate_hash_function("SHA512", hashlib.sha512, origin="hashlib")
+for local_name, hash_name in (
+		("rmd160", "ripemd160"),
+		("whirlpool", "whirlpool"),
+		# available since Python 3.6
+		("BLAKE2B", "blake2b"),
+		("BLAKE2S", "blake2s"),
+		("SHA3_256", "sha3_256"),
+		("SHA3_512", "sha3_512"),
+		):
+	try:
+		hashlib.new(hash_name)
+	except ValueError:
+		pass
+	else:
+		globals()['%shash' % local_name] = \
+			_generate_hash_function(local_name.upper(), \
+			functools.partial(hashlib.new, hash_name), \
+			origin='hashlib')
 
 _whirlpool_unaccelerated = False
 if "WHIRLPOOL" not in hashfunc_map:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     0eba01c258f8b3716cff0a768afaa3bb0271479b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 17:02:01 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:30 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=0eba01c2

portage.checksum: Support pygost as fallback Streebog provider

Support the pure Python implementation of Streebog in pygost as
a fallback algorithm. The code is horrible (it stores all the data
in memory before hashing), so it is really intended as last fallback.

 pym/portage/checksum.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 3ee100c3f..df896533f 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -247,6 +247,21 @@ if 'RMD160' not in hashfunc_map or 'WHIRLPOOL' not in hashfunc_map:
 		pass
 
 
+# Support pygost as fallback streebog provider
+# It's mostly provided as a reference implementation; it's pure Python,
+# slow and reads all data to memory (i.e. doesn't hash on update()...)
+if 'STREEBOG256' not in hashfunc_map or 'STREEBOG512' not in hashfunc_map:
+	try:
+		import pygost.gost34112012
+
+		_generate_hash_function("STREEBOG256",
+			functools.partial(pygost.gost34112012.GOST34112012, digest_size=32), origin="pygost")
+		_generate_hash_function("STREEBOG512",
+			functools.partial(pygost.gost34112012.GOST34112012, digest_size=64), origin="pygost")
+	except ImportError:
+		pass
+
+
 _whirlpool_unaccelerated = False
 if "WHIRLPOOL" not in hashfunc_map:
 	# Bundled WHIRLPOOL implementation


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     35d17f9331ac367a47e0e5277e63d766da097df3
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 16:32:06 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:30 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=35d17f93

portage.checksum: Support pygcrypt as optimized fallback

pygcrypt uses libgcrypt which provides support for ripemd160, whirlpool,
SHA3, plus some algorithms not provided by any other library.

 pym/portage/checksum.py | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 2c482f5e7..92b41b133 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -135,6 +135,44 @@ if "SHA3_256" not in hashfunc_map or "SHA3_512" not in hashfunc_map:
 		pass
 
 
+# Support pygcrypt as fallback using optimized routines from libgcrypt
+# (GnuPG).
+gcrypt_algos = frozenset(('RMD160', 'WHIRLPOOL', 'SHA3_256', 'SHA3_512'))
+if gcrypt_algos.difference(hashfunc_map):
+	try:
+		import binascii
+		import pygcrypt.hashcontext
+
+		class GCryptHashWrapper(object):
+			def __init__(self, algo):
+				self._obj = pygcrypt.hashcontext.HashContext(algo=algo)
+
+			def update(self, data):
+				self._obj.write(data)
+
+			def hexdigest(self):
+				return binascii.b2a_hex(self._obj.read()).decode()
+
+		name_mapping = {
+			'RMD160': 'ripemd160',
+			'WHIRLPOOL': 'whirlpool',
+			'SHA3_256': 'sha3-256',
+			'SHA3_512': 'sha3-512',
+		}
+
+		for local_name, gcry_name in name_mapping.items():
+			try:
+				pygcrypt.hashcontext.HashContext(algo=gcry_name)
+			except Exception: # yes, it throws Exception...
+				pass
+			else:
+				_generate_hash_function(local_name,
+						functools.partial(GCryptHashWrapper, gcry_name),
+						origin="pygcrypt")
+	except ImportError:
+		pass
+
+
 # Use pycrypto when available, prefer it over the internal fallbacks
 # Check for 'new' attributes, since they can be missing if the module
 # is broken somehow.


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     9a36b0c028af8a13bc9c8b28da2cdbf336a625ae
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 16:00:27 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:30 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9a36b0c0

portage.checksum: Reorder to avoid loading redundant impls

Reorder the checksum implementations to start with the most preferred
implementation, and try fallbacks only if the most preferred
implementation is not available. Most importantly, this means that
Portage will no longer attempt to load all hash libraries in the system,
especially when it can satisfy its requirements with hashlib.

 pym/portage/checksum.py | 145 +++++++++++++++++++++++++++++-------------------
 1 file changed, 87 insertions(+), 58 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 659012cdc..2c482f5e7 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -93,66 +93,11 @@ class _generate_hash_function(object):
 
 		return (checksum.hexdigest(), size)
 
-# Define hash functions, try to use the best module available. Later definitions
-# override earlier ones
 
-# Try to use mhash if available
-# mhash causes GIL presently, so it gets less priority than hashlib and
-# pycrypto. However, it might be the only accelerated implementation of
-# WHIRLPOOL available.
-try:
-	import mhash
-	for local_name, hash_name in (("RMD160", "RIPEMD160"), ("WHIRLPOOL", "WHIRLPOOL")):
-		if hasattr(mhash, 'MHASH_%s' % hash_name):
-			_generate_hash_function(local_name,
-				functools.partial(mhash.MHASH, getattr(mhash, 'MHASH_%s' % hash_name)),
-				origin='mhash')
-except ImportError:
-	pass
-
-# Use pycrypto when available, prefer it over the internal fallbacks
-# Check for 'new' attributes, since they can be missing if the module
-# is broken somehow.
-try:
-	from Crypto.Hash import RIPEMD
-	rmd160hash_ = getattr(RIPEMD, 'new', None)
-	if rmd160hash_ is not None:
-		_generate_hash_function("RMD160",
-			rmd160hash_, origin="pycrypto")
-except ImportError:
-	pass
-
-try:
-	# added in pycryptodome
-	from Crypto.Hash import BLAKE2b, BLAKE2s, SHA3_256, SHA3_512
-
-	blake2bhash_ = getattr(BLAKE2b, 'new', None)
-	if blake2bhash_ is not None:
-		_generate_hash_function("BLAKE2B",
-			functools.partial(blake2bhash_, digest_bytes=64), origin="pycrypto")
-	blake2shash_ = getattr(BLAKE2s, 'new', None)
-	if blake2shash_ is not None:
-		_generate_hash_function("BLAKE2S",
-			functools.partial(blake2shash_, digest_bytes=32), origin="pycrypto")
-	sha3_256hash_ = getattr(SHA3_256, 'new', None)
-	if sha3_256hash_ is not None:
-		_generate_hash_function("SHA3_256",
-			sha3_256hash_, origin="pycrypto")
-	sha3_512hash_ = getattr(SHA3_512, 'new', None)
-	if sha3_512hash_ is not None:
-		_generate_hash_function("SHA3_512",
-			sha3_512hash_, origin="pycrypto")
-except ImportError:
-	pass
-
-# Support using pysha3 as fallback for python<3.6
-try:
-	import sha3
+# Define hash functions, try to use the best module available. Preferred
+# modules should go first, latter ones should check if the hashes aren't
+# already defined.
 
-	_generate_hash_function("SHA3_256", sha3.sha3_256, origin="pysha3")
-	_generate_hash_function("SHA3_512", sha3.sha3_512, origin="pysha3")
-except ImportError:
-	pass
 
 # Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
 # Need special handling for RMD160/WHIRLPOOL as they may not always be provided by hashlib.
@@ -178,6 +123,89 @@ for local_name, hash_name in (
 			functools.partial(hashlib.new, hash_name),
 			origin='hashlib')
 
+
+# Support using pysha3 as fallback for python<3.6
+if "SHA3_256" not in hashfunc_map or "SHA3_512" not in hashfunc_map:
+	try:
+		import sha3
+
+		_generate_hash_function("SHA3_256", sha3.sha3_256, origin="pysha3")
+		_generate_hash_function("SHA3_512", sha3.sha3_512, origin="pysha3")
+	except ImportError:
+		pass
+
+
+# Use pycrypto when available, prefer it over the internal fallbacks
+# Check for 'new' attributes, since they can be missing if the module
+# is broken somehow.
+if 'RMD160' not in hashfunc_map:
+	try:
+		from Crypto.Hash import RIPEMD
+		rmd160hash_ = getattr(RIPEMD, 'new', None)
+		if rmd160hash_ is not None:
+			_generate_hash_function("RMD160",
+				rmd160hash_, origin="pycrypto")
+	except ImportError:
+		pass
+
+# The following hashes were added in pycryptodome (pycrypto fork)
+if 'BLAKE2B' not in hashfunc_map:
+	try:
+		from Crypto.Hash import BLAKE2b
+		blake2bhash_ = getattr(BLAKE2b, 'new', None)
+		if blake2bhash_ is not None:
+			_generate_hash_function("BLAKE2B",
+				functools.partial(blake2bhash_, digest_bytes=64), origin="pycrypto")
+	except ImportError:
+		pass
+
+if 'BLAKE2S' not in hashfunc_map:
+	try:
+		from Crypto.Hash import BLAKE2s
+		blake2shash_ = getattr(BLAKE2s, 'new', None)
+		if blake2shash_ is not None:
+			_generate_hash_function("BLAKE2S",
+				functools.partial(blake2shash_, digest_bytes=32), origin="pycrypto")
+	except ImportError:
+		pass
+
+if 'SHA3_256' not in hashfunc_map:
+	try:
+		from Crypto.Hash import SHA3_256
+		sha3_256hash_ = getattr(SHA3_256, 'new', None)
+		if sha3_256hash_ is not None:
+			_generate_hash_function("SHA3_256",
+				sha3_256hash_, origin="pycrypto")
+	except ImportError:
+		pass
+
+if 'SHA3_512' not in hashfunc_map:
+	try:
+		from Crypto.Hash import SHA3_512
+		sha3_512hash_ = getattr(SHA3_512, 'new', None)
+		if sha3_512hash_ is not None:
+			_generate_hash_function("SHA3_512",
+				sha3_512hash_, origin="pycrypto")
+	except ImportError:
+		pass
+
+
+# Try to use mhash if available
+# mhash causes GIL presently, so it gets less priority than hashlib and
+# pycrypto. However, it might be the only accelerated implementation of
+# WHIRLPOOL available.
+if 'RMD160' not in hashfunc_map or 'WHIRLPOOL' not in hashfunc_map:
+	try:
+		import mhash
+		for local_name, hash_name in (("RMD160", "RIPEMD160"), ("WHIRLPOOL", "WHIRLPOOL")):
+			if local_name not in hashfunc_map and hasattr(mhash, 'MHASH_%s' % hash_name):
+				_generate_hash_function(local_name,
+					functools.partial(mhash.MHASH, getattr(mhash, 'MHASH_%s' % hash_name)),
+					origin='mhash')
+	except ImportError:
+		pass
+
+
 _whirlpool_unaccelerated = False
 if "WHIRLPOOL" not in hashfunc_map:
 	# Bundled WHIRLPOOL implementation
@@ -196,6 +224,7 @@ hashfunc_map["size"] = SizeHash()
 
 # end actual hash functions
 
+
 prelink_capable = False
 if os.path.exists(PRELINK_BINARY):
 	cmd = [PRELINK_BINARY, "--version"]


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-03-13 21:46 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
  To: gentoo-commits

commit:     a3300858d3ab3f427e1a1450641f440f97272f19
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 13 14:43:21 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:37 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a3300858

portage.checksum: Store supported hash types in a frozenset

Copy the list of supported hash types (hashfunc_map dict) into
a frozenset to support efficient access in the public API.

 pym/portage/checksum.py | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index df896533f..ff132751b 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -278,6 +278,9 @@ class SizeHash(object):
 
 hashfunc_map["size"] = SizeHash()
 
+# cache all supported hash methods in a frozenset
+hashfunc_keys = frozenset(hashfunc_map)
+
 # end actual hash functions
 
 
@@ -312,15 +315,15 @@ def _perform_md5_merge(x, **kwargs):
 
 def perform_all(x, calc_prelink=0):
 	mydict = {}
-	for k in hashfunc_map:
+	for k in hashfunc_keys:
 		mydict[k] = perform_checksum(x, k, calc_prelink)[0]
 	return mydict
 
 def get_valid_checksum_keys():
-	return list(hashfunc_map)
+	return hashfunc_keys
 
 def get_hash_origin(hashtype):
-	if hashtype not in hashfunc_map:
+	if hashtype not in hashfunc_keys:
 		raise KeyError(hashtype)
 	return hashorigin_map.get(hashtype, "unknown")
 
@@ -334,7 +337,7 @@ def _filter_unaccelarated_hashes(digests):
 	due to minimization of dependencies.
 	"""
 	if _whirlpool_unaccelerated and "WHIRLPOOL" in digests:
-		verifiable_hash_types = set(digests).intersection(hashfunc_map)
+		verifiable_hash_types = set(digests).intersection(hashfunc_keys)
 		verifiable_hash_types.discard("size")
 		if len(verifiable_hash_types) > 1:
 			digests = dict(digests)
@@ -383,7 +386,7 @@ def _apply_hash_filter(digests, hash_filter):
 	@type hash_filter: callable
 	"""
 
-	verifiable_hash_types = set(digests).intersection(hashfunc_map)
+	verifiable_hash_types = set(digests).intersection(hashfunc_keys)
 	verifiable_hash_types.discard("size")
 	modified = False
 	if len(verifiable_hash_types) > 1:
@@ -430,10 +433,10 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0):
 			raise portage.exception.FileNotFound(filename)
 		return False, (str(e), None, None)
 
-	verifiable_hash_types = set(mydict).intersection(hashfunc_map)
+	verifiable_hash_types = set(mydict).intersection(hashfunc_keys)
 	verifiable_hash_types.discard("size")
 	if not verifiable_hash_types:
-		expected = set(hashfunc_map)
+		expected = set(hashfunc_keys)
 		expected.discard("size")
 		expected = list(expected)
 		expected.sort()
@@ -448,7 +451,7 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0):
 	for x in sorted(mydict):
 		if   x == "size":
 			continue
-		elif x in hashfunc_map:
+		elif x in hashfunc_keys:
 			myhash = perform_checksum(filename, x, calc_prelink=calc_prelink)[0]
 			if mydict[x] != myhash:
 				if strict:
@@ -504,7 +507,7 @@ def perform_checksum(filename, hashname="MD5", calc_prelink=0):
 				# This happens during uninstallation of prelink.
 				prelink_capable = False
 		try:
-			if hashname not in hashfunc_map:
+			if hashname not in hashfunc_keys:
 				raise portage.exception.DigestException(hashname + \
 					" hash function not available (needs dev-python/pycrypto)")
 			myhash, mysize = hashfunc_map[hashname].checksum_file(myfilename)
@@ -541,7 +544,7 @@ def perform_multiple_checksums(filename, hashes=["MD5"], calc_prelink=0):
 	"""
 	rVal = {}
 	for x in hashes:
-		if x not in hashfunc_map:
+		if x not in hashfunc_keys:
 			raise portage.exception.DigestException(x+" hash function not available (needs dev-python/pycrypto or >=dev-lang/python-2.5)")
 		rVal[x] = perform_checksum(filename, x, calc_prelink)[0]
 	return rVal
@@ -558,7 +561,7 @@ def checksum_str(data, hashname="MD5"):
 	@rtype: String
 	@return: The hash (hex-digest) of the data
 	"""
-	if hashname not in hashfunc_map:
+	if hashname not in hashfunc_keys:
 		raise portage.exception.DigestException(hashname + \
 			" hash function not available (needs dev-python/pycrypto)")
 	return hashfunc_map[hashname].checksum_str(data)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-06-15 17:05 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-06-15 17:05 UTC (permalink / raw
  To: gentoo-commits

commit:     ff2c1d017cf2f8aa6a8eba4e0495089c5d73f277
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 15 07:25:23 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 15 17:05:30 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ff2c1d01

const: Remove unused MANIFEST1_REQUIRED_HASH

The MANIFEST1_REQUIRED_HASH constant is not used anywhere, so it should
be possible to remove it safely.

Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/const.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 7e415ba9c..052d4ca2f 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -206,7 +206,6 @@ EAPI                     = 6
 
 HASHING_BLOCKSIZE        = 32768
 MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160")
-MANIFEST1_REQUIRED_HASH  = "MD5"
 
 # Past events:
 #


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-06-15 17:15 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-06-15 17:15 UTC (permalink / raw
  To: gentoo-commits

commit:     e6abcc0b7cbdca481862a5c7cca946c01c471ffb
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 15 07:27:47 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jun 15 17:15:05 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e6abcc0b

const: Change the MANIFEST2_REQUIRED_HASH to SHA512

Following the plan established in GLEP 59, we're long overdue
deprecating SHA256. Since we have finally got rid of the last packages
lacking SHA512 checksums, we can proceed with that. In order to prepare
for it, however, we need to change the required hash to SHA512 and make
sure developers install the new Portage & repoman versions first.

Of course, a better course of action would be to kill
MANIFEST2_REQUIRED_HASH entirely and make Portage capable of dealing
with any hash set. However, that's a larger piece of work and it would
delay the immediate goal.

Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/const.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 052d4ca2f..cbd2b6042 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -234,7 +234,7 @@ MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL",
 		"BLAKE2B", "BLAKE2S", "SHA3_256", "SHA3_512",
 		"STREEBOG256", "STREEBOG512")
 MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"])
-MANIFEST2_REQUIRED_HASH  = "SHA256"
+MANIFEST2_REQUIRED_HASH  = "SHA512"
 
 MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-07-19 20:54 Manuel Rüger
  0 siblings, 0 replies; 248+ messages in thread
From: Manuel Rüger @ 2017-07-19 20:54 UTC (permalink / raw
  To: gentoo-commits

commit:     becb67d7bf5e653d5646e974f2976b0ef5d63570
Author:     Manuel Rüger <mrueg <AT> gentoo <DOT> org>
AuthorDate: Tue Jul  4 22:56:59 2017 +0000
Commit:     Manuel Rüger <mrueg <AT> gentoo <DOT> org>
CommitDate: Wed Jul 19 20:52:33 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=becb67d7

localization: Replace deprecated locale.format() with format_string()

 pym/portage/localization.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/localization.py b/pym/portage/localization.py
index 90202fb58..b215b9cba 100644
--- a/pym/portage/localization.py
+++ b/pym/portage/localization.py
@@ -39,7 +39,7 @@ def localized_size(num_bytes):
 	# always round up, so that small files don't end up as '0 KiB'
 	num_kib = math.ceil(num_bytes / 1024)
 	try:
-		formatted_num = locale.format('%d', num_kib, grouping=True)
+		formatted_num = locale.format_string('%d', num_kib, grouping=True)
 	except UnicodeDecodeError:
 		# failure to decode locale data
 		formatted_num = str(num_kib)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-10-22 22:33 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2017-10-22 22:33 UTC (permalink / raw
  To: gentoo-commits

commit:     5575570894c064976f701831d5a15bfa7f529935
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 22 22:30:15 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Oct 22 22:33:02 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=55755708

is_prelinkable_elf: fix for python3 (bug 635116)

Change magic[16] to magic[16:17], since magic[16] returns
an integer for python3.

Bug: https://bugs.gentoo.org/635116

 pym/portage/checksum.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index ad090ddb3..5424ce56b 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -315,7 +315,7 @@ def is_prelinkable_elf(filename):
 	finally:
 		f.close()
 	return (len(magic) == 17 and magic.startswith(b'\x7fELF') and
-		magic[16] in (b'\x02', b'\x03')) # 2=ET_EXEC, 3=ET_DYN
+		magic[16:17] in (b'\x02', b'\x03')) # 2=ET_EXEC, 3=ET_DYN
 
 def perform_md5(x, calc_prelink=0):
 	return perform_checksum(x, "MD5", calc_prelink)[0]


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-11-06 14:33 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-11-06 14:33 UTC (permalink / raw
  To: gentoo-commits

commit:     8fb65220f1c65593f82ea7fbffdd523f0b235334
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Nov  6 07:12:31 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Nov  6 14:33:01 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=8fb65220

Remove last traces of Manifest1 code

Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/const.py    | 1 -
 pym/portage/manifest.py | 7 ++-----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 98b7c88c9..0af57d0e2 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -205,7 +205,6 @@ SUPPORTED_FEATURES       = frozenset([
 EAPI                     = 6
 
 HASHING_BLOCKSIZE        = 32768
-MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160")
 
 MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"])
 MANIFEST2_REQUIRED_HASH  = "SHA512"

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 0a68aa653..36c82690c 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -26,7 +26,7 @@ from portage import _unicode_encode
 from portage.exception import DigestException, FileNotFound, \
 	InvalidDataType, MissingParameter, PermissionDenied, \
 	PortageException, PortagePackageException
-from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS,
+from portage.const import (MANIFEST2_HASH_DEFAULTS,
 	MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH)
 from portage.localization import _
 
@@ -710,10 +710,7 @@ class Manifest(object):
 		myfile.close()
 		for l in lines:
 			mysplit = l.split()
-			if len(mysplit) == 4 and mysplit[0] in MANIFEST1_HASH_FUNCTIONS \
-				and 1 not in rVal:
-				rVal.append(1)
-			elif len(mysplit) > 4 and mysplit[0] in MANIFEST2_IDENTIFIERS \
+			if len(mysplit) > 4 and mysplit[0] in MANIFEST2_IDENTIFIERS \
 				and ((len(mysplit) - 3) % 2) == 0 and not 2 in rVal:
 				rVal.append(2)
 		return rVal


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-11-06 14:33 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-11-06 14:33 UTC (permalink / raw
  To: gentoo-commits

commit:     148ef9055f20dfeb2996417575cefeda922b43a9
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Nov  6 07:04:11 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Nov  6 14:33:00 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=148ef905

portage.const: Remove obsolete manifest-hashes comment

The comment is based upon the wrong assumption that the world is
Portage-centric. We are keeping the manifest-hashes in layout.conf
indefinitely, and we will most likely take BLAKE2 instead of SHA3.

Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/const.py | 23 -----------------------
 1 file changed, 23 deletions(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index cbd2b6042..11e94b0a2 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -207,29 +207,6 @@ EAPI                     = 6
 HASHING_BLOCKSIZE        = 32768
 MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160")
 
-# Past events:
-#
-# 20120704 - After WHIRLPOOL is supported in stable portage:
-# - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
-#     manifest-hashes = SHA256 SHA512 WHIRLPOOL
-# - Add SHA512 and WHIRLPOOL to MANIFEST2_HASH_DEFAULTS.
-# - Remove SHA1 and RMD160 from MANIFEST2_HASH_*.
-#
-# Future events:
-#
-# After WHIRLPOOL is supported in stable portage for at least 1 year:
-# - Change MANIFEST2_REQUIRED_HASH to WHIRLPOOL.
-# - Remove SHA256 from MANIFEST2_HASH_*.
-# - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
-#     manifest-hashes = SHA512 WHIRLPOOL
-#
-# After SHA-3 is supported in stable portage:
-# - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
-#     manifest-hashes = SHA3 SHA512 WHIRLPOOL
-#
-# After layout.conf settings correspond to defaults in stable portage:
-# - Remove redundant settings from gentoo-x86/metadata/layout.conf.
-
 MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL",
 		"BLAKE2B", "BLAKE2S", "SHA3_256", "SHA3_512",
 		"STREEBOG256", "STREEBOG512")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-11-20 18:44 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-11-20 18:44 UTC (permalink / raw
  To: gentoo-commits

commit:     b4a444819986e6f4d987ec746dc00508190f1e3c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 19 16:56:50 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Nov 20 18:38:00 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b4a44481

portage.manifest: Fix mis-parsing Manifests with numerical checksums

Fix the regular expression used to parse Manifests not to fail horribly
when one of the checksums accidentally happens to be all-digits.

The previously used regular expression used to greedily take everything
up to the first number as filename. If one of the checksums happened to
be purely numeric, this meant that everything up to that checksum was
taken as filename, and the checksum itself was taken as file size. It
was also capable of accepting an empty filename.

The updated regular expression uses '\S+' to match filenames. Therefore,
the match is terminated on first whitespace character and filenames can
no longer contain spaces. Not that it could ever work reliably.

Spotted by Ulrich Müller.

Bug: https://bugs.gentoo.org/638148
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/manifest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 4ec20515e..4bca61e86 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -30,7 +30,7 @@ from portage.const import (MANIFEST2_HASH_DEFAULTS, MANIFEST2_IDENTIFIERS)
 from portage.localization import _
 
 _manifest_re = re.compile(
-	r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + r') (.*)( \d+( \S+ \S+)+)$',
+	r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + r') (\S+)( \d+( \S+ \S+)+)$',
 	re.UNICODE)
 
 if sys.hexversion >= 0x3000000:


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-12-04  8:40 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2017-12-04  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     a45f1cad89eb96e11fd198565f2a6f8ce6922e38
Author:     Christoph Böhmwalder <christoph <AT> boehmwalder <DOT> at>
AuthorDate: Sun Dec  3 15:23:55 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Dec  4 08:36:47 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a45f1cad

xtermTitle: support st (simple terminal)

Currently users of suckless' simple terminal have to rely on ugly hacks
like this in order to make portage display merging progress in the
terminals title bar:

alias emerge="TERM=xterm emerge"

Officially support st by adding it to the list of legal terminals.

Signed-off-by: Christoph Böhmwalder <christoph <AT> boehmwalder.at>

 pym/portage/output.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 6d8c6324a..1070d0ef3 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -234,7 +234,7 @@ def nc_len(mystr):
 	tmp = re.sub(esc_seq + "^m]+m", "", mystr);
 	return len(tmp)
 
-_legal_terms_re = re.compile(r'^(xterm|xterm-color|Eterm|aterm|rxvt|screen|kterm|rxvt-unicode|gnome|interix|tmux)')
+_legal_terms_re = re.compile(r'^(xterm|xterm-color|Eterm|aterm|rxvt|screen|kterm|rxvt-unicode|gnome|interix|tmux|st-256color)')
 _disable_xtermTitle = None
 _max_xtermTitle_len = 253
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-12-05 17:37 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-12-05 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     6076f4217dc463340547984b4f88551deec0cc55
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Dec  5 16:33:32 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Dec  5 17:36:46 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=6076f421

[checksum] Disable pygcrypt backend due to breakage

Closes: https://bugs.gentoo.org/615620
Reviewed-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/checksum.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 5424ce56b..9e7bffea9 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -150,7 +150,11 @@ if "SHA3_256" not in hashfunc_map or "SHA3_512" not in hashfunc_map:
 # (GnuPG).
 gcrypt_algos = frozenset(('RMD160', 'WHIRLPOOL', 'SHA3_256', 'SHA3_512',
 	'STREEBOG256', 'STREEBOG512'))
-if gcrypt_algos.difference(hashfunc_map):
+# Note: currently disabled due to resource exhaustion bugs in pygcrypt.
+# Please do not reenable until upstream has a fix.
+# https://bugs.gentoo.org/615620
+if False:
+#if gcrypt_algos.difference(hashfunc_map):
 	try:
 		import binascii
 		import pygcrypt.hashcontext


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2017-12-06  8:39 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2017-12-06  8:39 UTC (permalink / raw
  To: gentoo-commits

commit:     7cfa6daaac45e56fbbc8da9928c698adf1d52ec0
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Dec  5 19:58:47 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Dec  6 08:39:15 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7cfa6daa

[checksum] Do not use secure memory for pygcrypt backend

Disable using secure memory for pygcrypt backend since we are not
processing secrets. This can avoid the libgcrypt memory error; however,
it turned out to be a huge memory/resource leak which needs to be fixed
independently.

Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/checksum.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index 9e7bffea9..4174638e6 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -161,7 +161,8 @@ if False:
 
 		class GCryptHashWrapper(object):
 			def __init__(self, algo):
-				self._obj = pygcrypt.hashcontext.HashContext(algo=algo)
+				self._obj = pygcrypt.hashcontext.HashContext(algo=algo,
+						secure=False)
 
 			def update(self, data):
 				self._obj.write(data)


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2018-01-14  9:59 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2018-01-14  9:59 UTC (permalink / raw
  To: gentoo-commits

commit:     864481d1375e99c631a389a6d2850071be20858e
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 13 08:48:26 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jan 14 09:59:37 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=864481d1

const: Switch default hash set to BLAKE2B+SHA512

Switch the Portage defaults to the new Gentoo hash set. We're already
far past the initial testing and I have been approached by a few people
who were surprised that Portage does not use new hashes for overlays.
Switching the defaults will remove the need for custom hashes
in layout.conf.

Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/const.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/const.py b/pym/portage/const.py
index ec877b841..e5fa4b67c 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -206,8 +206,8 @@ EAPI                     = 6
 
 HASHING_BLOCKSIZE        = 32768
 
-MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"])
-MANIFEST2_HASH_DEFAULT  = "SHA512"
+MANIFEST2_HASH_DEFAULTS = frozenset(["BLAKE2B", "SHA512"])
+MANIFEST2_HASH_DEFAULT  = "BLAKE2B"
 
 MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2018-02-22 17:32 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2018-02-22 17:32 UTC (permalink / raw
  To: gentoo-commits

commit:     d3778a92be0ac4a22eb61e3affdc85f99337847a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 21 23:14:44 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Feb 22 17:30:26 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d3778a92

portage.process.spawn: default close_fds=False (bug 648432)

For python3.4 and later, default to close_fds=False, since file
descriptors are non-inheritable by default due to PEP 446. This solves
a performance problem on systems like FreeBSD, where our get_open_fds
function returns all possible file descriptor values (including those
that are not open).

Bug: https://bugs.gentoo.org/648432
See: https://www.python.org/dev/peps/pep-0446/

 pym/portage/process.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pym/portage/process.py b/pym/portage/process.py
index bc4efb5fe..4d96f156e 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -196,7 +196,8 @@ def cleanup():
 
 def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
           uid=None, gid=None, groups=None, umask=None, logfile=None,
-          path_lookup=True, pre_exec=None, close_fds=True, unshare_net=False,
+          path_lookup=True, pre_exec=None,
+          close_fds=(sys.version_info < (3, 4)), unshare_net=False,
           unshare_ipc=False, cgroup=None):
 	"""
 	Spawns a given command.
@@ -228,7 +229,8 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
 	@param pre_exec: A function to be called with no arguments just prior to the exec call.
 	@type pre_exec: callable
 	@param close_fds: If True, then close all file descriptors except those
-		referenced by fd_pipes (default is True).
+		referenced by fd_pipes (default is True for python3.3 and earlier, and False for
+		python3.4 and later due to non-inheritable file descriptor behavior from PEP 446).
 	@type close_fds: Boolean
 	@param unshare_net: If True, networking will be unshared from the spawned process
 	@type unshare_net: Boolean


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2018-02-22 19:13 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2018-02-22 19:13 UTC (permalink / raw
  To: gentoo-commits

commit:     39c797992bcdf8403521d8b61bb3e592135b3307
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 22 15:04:52 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Feb 22 19:13:43 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=39c79799

FreeBSD: use os.*chflags() instead of calling external tool

Use os.chflags() and os.lchflags() built-in functions instead of calling
external 'chflags' tool on FreeBSD. This fixes major performance
problems Portage has on FreeBSD.

Bug: https://bugs.gentoo.org/648432
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/__init__.py | 50 +++----------------------------------------------
 1 file changed, 3 insertions(+), 47 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 0e036b12e..99f3f98ac 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -419,54 +419,10 @@ def _shell_quote(s):
 bsd_chflags = None
 
 if platform.system() in ('FreeBSD',):
-
+	# TODO: remove this class?
 	class bsd_chflags(object):
-
-		@classmethod
-		def chflags(cls, path, flags, opts=""):
-			cmd = ['chflags']
-			if opts:
-				cmd.append(opts)
-			cmd.append('%o' % (flags,))
-			cmd.append(path)
-
-			if sys.hexversion < 0x3020000 and sys.hexversion >= 0x3000000:
-				# Python 3.1 _execvp throws TypeError for non-absolute executable
-				# path passed as bytes (see https://bugs.python.org/issue8513).
-				fullname = process.find_binary(cmd[0])
-				if fullname is None:
-					raise exception.CommandNotFound(cmd[0])
-				cmd[0] = fullname
-
-			encoding = _encodings['fs']
-			cmd = [_unicode_encode(x, encoding=encoding, errors='strict')
-				for x in cmd]
-			proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
-				stderr=subprocess.STDOUT)
-			output = proc.communicate()[0]
-			status = proc.wait()
-			if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK:
-				return
-			# Try to generate an ENOENT error if appropriate.
-			if 'h' in opts:
-				_os_merge.lstat(path)
-			else:
-				_os_merge.stat(path)
-			# Make sure the binary exists.
-			if not portage.process.find_binary('chflags'):
-				raise portage.exception.CommandNotFound('chflags')
-			# Now we're not sure exactly why it failed or what
-			# the real errno was, so just report EPERM.
-			output = _unicode_decode(output, encoding=encoding)
-			e = OSError(errno.EPERM, output)
-			e.errno = errno.EPERM
-			e.filename = path
-			e.message = output
-			raise e
-
-		@classmethod
-		def lchflags(cls, path, flags):
-			return cls.chflags(path, flags, opts='-h')
+		chflags = os.chflags
+		lchflags = os.lchflags
 
 def load_mod(name):
 	modname = ".".join(name.split(".")[:-1])


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2018-02-25 20:58 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2018-02-25 20:58 UTC (permalink / raw
  To: gentoo-commits

commit:     b49646b5bcfdfb9ea64a1028f0003e255f294fec
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 25 19:59:03 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Feb 25 20:58:00 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b49646b5

Deprecate EAPI 6_pre1

Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 pym/portage/__init__.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 99f3f98ac..4773738b2 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2014 Gentoo Foundation
+# Copyright 1998-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
@@ -462,8 +462,8 @@ def abssymlink(symlink, target=None):
 
 _doebuild_manifest_exempt_depend = 0
 
-_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend", "6_pre1"])
-_deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1", "5_pre2"])
+_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend"])
+_deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1", "5_pre2", "6_pre1"])
 _supported_eapis = frozenset([str(x) for x in range(portage.const.EAPI + 1)] + list(_testing_eapis) + list(_deprecated_eapis))
 
 def _eapi_is_deprecated(eapi):


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2018-03-04 21:05 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2018-03-04 21:05 UTC (permalink / raw
  To: gentoo-commits

commit:     682925a464173ac3ebd58492a01ca5acb4c496fe
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 25 20:00:09 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Mar  4 21:03:52 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=682925a4

Enable testing EAPI 7_pre1

 pym/portage/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 4773738b2..69658b432 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -462,7 +462,7 @@ def abssymlink(symlink, target=None):
 
 _doebuild_manifest_exempt_depend = 0
 
-_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend"])
+_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend", "7_pre1"])
 _deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1", "5_pre2", "6_pre1"])
 _supported_eapis = frozenset([str(x) for x in range(portage.const.EAPI + 1)] + list(_testing_eapis) + list(_deprecated_eapis))
 


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2018-03-11 11:44 Michał Górny
  0 siblings, 0 replies; 248+ messages in thread
From: Michał Górny @ 2018-03-11 11:44 UTC (permalink / raw
  To: gentoo-commits

commit:     7a5cf68420896ba51a8fda541b973f95278e17b3
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 21 07:50:04 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Mar 11 11:43:40 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7a5cf684

Allow package.*, use.* directories in EAPI 7

Bug: https://bugs.gentoo.org/282296

 pym/portage/eapi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index 075f7a59c..092780ded 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -85,7 +85,7 @@ def eapi_supports_stable_use_forcing_and_masking(eapi):
 	return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi")
 
 def eapi_allows_directories_on_profile_level_and_repository_level(eapi):
-	return eapi in ("4-python", "5-progress")
+	return eapi not in ("0", "1", "2", "3", "4", "4-slot-abi", "5", "6")
 
 def eapi_has_use_aliases(eapi):
 	return eapi in ("4-python", "5-progress")


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
  2018-03-30  5:20 [gentoo-commits] proj/portage:repoman " Zac Medico
@ 2018-03-30  4:23 ` Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2018-03-30  4:23 UTC (permalink / raw
  To: gentoo-commits

commit:     3bffbc6150be9ee81d47547cbff113a8d45edb6d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 01:50:21 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Mar 30 03:51:20 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3bffbc61

module.py: Extend the module loader for API version checking

If provided with an iterable of compatibility versions, The controller
will check the plugin modules module_spec 'version' variable is
compatible with the base application.

 pym/portage/module.py | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/pym/portage/module.py b/pym/portage/module.py
index c79e65518..bd7c94d4e 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -15,6 +15,10 @@ class InvalidModuleName(PortageException):
 	"""An invalid or unknown module name."""
 
 
+class ModuleVersionError(PortageException):
+	'''An incompatible module version'''
+
+
 class Module(object):
 	"""Class to define and hold our plug-in module
 
@@ -87,16 +91,17 @@ class Modules(object):
 	@param namepath: Python import path to the "modules" directory
 	"""
 
-	def __init__(self, path, namepath):
+	def __init__(self, path, namepath, compat_versions=None):
 		self._module_path = path
 		self._namepath = namepath
+		self.compat_versions = compat_versions
 		self.parents = []
 		self._modules = self._get_all_modules()
 		self.modules = ProtectedDict(self._modules)
 		self.module_names = sorted(self._modules)
 
 	def _get_all_modules(self):
-		"""scans the emaint modules dir for loadable modules
+		"""scans the _module_path dir for loadable modules
 
 		@rtype: dictionary of module_plugins
 		"""
@@ -117,6 +122,7 @@ class Modules(object):
 		kids = {}
 		for entry in importables:
 			new_module = Module(entry, self._namepath)
+			self._check_compat(new_module)
 			for module_name in new_module.kids:
 				kid = new_module.kids[module_name]
 				kid['parent'] = new_module
@@ -211,6 +217,8 @@ class Modules(object):
 
 		@type modname: string
 		@param modname: the module class name
+		@type var: string
+		@param var: the base level variable to return
 		@type dictionary
 		@return: the modules class exported options descriptions
 		"""
@@ -220,3 +228,13 @@ class Modules(object):
 			raise InvalidModuleName(
 				"Module name '%s' is invalid or not found" % modname)
 		return value
+
+	def _check_compat(self, module):
+		if self.compat_versions:
+			if not module.module_spec['version'] in self.compat_versions:
+				raise ModuleVersionError(
+					"Error loading '%s' plugin module: %s, version: %s\n"
+					"Module is not compatible with the current application version\n"
+					"Compatible module API versions are: %s"
+					% (self._namepath, module.module_spec['name'],
+						module.module_spec['version'], self.compat_versions))


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2018-04-17  2:22 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2018-04-17  2:22 UTC (permalink / raw
  To: gentoo-commits

commit:     3628eaf7d4691c249943e9059ba2ddc60253ba82
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 16 01:33:59 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Apr 17 02:22:00 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3628eaf7

config.environ(): filter PORTDIR only when required (bug 653230)

The changes related bug 373349 were more aggressive than necessary,
causing the PORTDIR variable to be omitted from config.environ()
calls when the EAPI is defined. We really only need to filter the
PORTDIR variable when the current EAPI requires it.

Fixes: 802e7d0bdd96 ("Do not export PORTDIR & ECLASSDIR in EAPI 7")
Bug: https://bugs.gentoo.org/653230

 pym/portage/eapi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index cdbbf07fb..b0f993a14 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -159,7 +159,7 @@ def _get_eapi_attrs(eapi):
 		dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
 		empty_groups_always_true = (eapi is not None and eapi_empty_groups_always_true(eapi)),
 		exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)),
-		exports_PORTDIR = (eapi is not None and eapi_exports_PORTDIR(eapi)),
+		exports_PORTDIR = (eapi is None or eapi_exports_PORTDIR(eapi)),
 		exports_ECLASSDIR = (eapi is not None and eapi_exports_ECLASSDIR(eapi)),
 		feature_flag_test = True,
 		feature_flag_targetroot = (eapi is not None and eapi_has_targetroot(eapi)),


^ permalink raw reply related	[flat|nested] 248+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/
@ 2018-04-28 23:08 Zac Medico
  0 siblings, 0 replies; 248+ messages in thread
From: Zac Medico @ 2018-04-28 23:08 UTC (permalink / raw
  To: gentoo-commits

commit:     97887768e3f5e8bc1b520b119fde97fed16cfe7d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 28 22:59:21 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Apr 28 23:05:25 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=97887768

PortageKeyError: fix __unicode__ AttributeError under python2.7

  File "pym/portage/exception.py", line 32, in __unicode__
    if isinstance(self.value, unicode):
AttributeError: 'PortageKeyError' object has no attribute 'value'

 pym/portage/exception.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 263cdf087..aed8beeb9 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -44,6 +44,9 @@ class PortageException(Exception):
 
 class PortageKeyError(KeyError, PortageException):
 	__doc__ = KeyError.__doc__
+	def __init__(self, value):
+		KeyError.__init__(self, value)
+		PortageException.__init__(self, value)
 
 class CorruptionError(PortageException):
 	"""Corruption indication"""


^ permalink raw reply related	[flat|nested] 248+ messages in thread

end of thread, other threads:[~2018-04-28 23:08 UTC | newest]

Thread overview: 248+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-06  0:41 [gentoo-commits] proj/portage:master commit in: pym/portage/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2018-04-28 23:08 Zac Medico
2018-04-17  2:22 Zac Medico
2018-03-30  5:20 [gentoo-commits] proj/portage:repoman " Zac Medico
2018-03-30  4:23 ` [gentoo-commits] proj/portage:master " Zac Medico
2018-03-11 11:44 Michał Górny
2018-03-04 21:05 Michał Górny
2018-02-25 20:58 Michał Górny
2018-02-22 19:13 Michał Górny
2018-02-22 17:32 Zac Medico
2018-01-14  9:59 Michał Górny
2017-12-06  8:39 Michał Górny
2017-12-05 17:37 Michał Górny
2017-12-04  8:40 Zac Medico
2017-11-20 18:44 Michał Górny
2017-11-06 14:33 Michał Górny
2017-11-06 14:33 Michał Górny
2017-10-22 22:33 Zac Medico
2017-07-19 20:54 Manuel Rüger
2017-06-15 17:15 Michał Górny
2017-06-15 17:05 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-13 21:46 Michał Górny
2017-03-01 15:43 Michał Górny
2017-03-01 15:43 Michał Górny
2017-02-28 22:07 Michał Górny
2017-02-28 22:07 Michał Górny
2017-02-28 22:07 Michał Górny
2017-01-27  0:04 Zac Medico
2017-01-20  7:28 Zac Medico
2017-01-17 17:43 Zac Medico
2016-12-06  3:54 Brian Dolbec
2016-12-06  3:54 Brian Dolbec
2016-12-05  5:14 Brian Dolbec
2016-10-02  4:46 Zac Medico
2016-09-15 21:42 Zac Medico
2016-09-15  2:03 Zac Medico
2016-09-15  2:03 Zac Medico
2016-07-23 23:09 Zac Medico
2016-06-29  3:04 Brian Dolbec
2016-05-31  1:05 Zac Medico
2016-05-20  9:01 Alexander Berntsen
2016-05-18 16:45 Zac Medico
2016-05-18 16:42 Zac Medico
2016-05-16  9:47 Brian Dolbec
2016-04-30  0:12 Brian Dolbec
2016-04-29 23:16 Brian Dolbec
2015-12-21 16:17 Zac Medico
2015-12-16 18:58 Zac Medico
2015-12-15 16:18 Zac Medico
2015-11-15 22:54 Michał Górny
2015-11-12 19:32 Michał Górny
2015-10-02  5:08 Zac Medico
2015-08-17  3:39 Zac Medico
2015-05-11  0:47 Zac Medico
2015-01-31 23:13 Zac Medico
2015-01-30 20:32 Brian Dolbec
2015-01-30 20:32 Brian Dolbec
2015-01-12  9:13 Zac Medico
2015-01-12  9:13 Zac Medico
2014-12-04 14:01 Michał Górny
2014-12-04 14:01 Michał Górny
2014-12-03 18:30 Zac Medico
2014-11-18  1:04 Zac Medico
2014-11-11 22:30 Zac Medico
2014-10-23 18:18 Zac Medico
2014-09-12 21:26 Zac Medico
2014-09-11 23:45 Brian Dolbec
2014-09-11 23:45 Brian Dolbec
2014-09-11 23:45 Brian Dolbec
2014-09-11 23:04 Brian Dolbec
2014-09-11 23:04 Brian Dolbec
2014-08-19  7:01 Michał Górny
2014-08-06 20:54 ` Michał Górny
2014-06-12 15:47 Brian Dolbec
2014-04-05 20:44 Sebastian Luther
2014-02-04  2:53 Mike Frysinger
2014-01-19  8:45 Arfrever Frehtes Taifersar Arahesis
2014-01-07 23:42 Arfrever Frehtes Taifersar Arahesis
2014-01-02 22:53 Arfrever Frehtes Taifersar Arahesis
2013-11-30 18:15 Mike Frysinger
2013-11-30  5:35 Mike Frysinger
2013-09-02  0:55 Zac Medico
2013-09-01 23:57 Zac Medico
2013-09-01 20:55 Zac Medico
2013-08-18  6:04 Zac Medico
2013-07-29 18:40 Zac Medico
2013-07-13  9:24 Arfrever Frehtes Taifersar Arahesis
2013-06-22 17:49 Zac Medico
2013-04-28 22:42 Zac Medico
2013-03-22 15:42 Zac Medico
2013-03-22 15:36 Zac Medico
2013-03-22  1:42 Zac Medico
2013-03-19 21:57 Zac Medico
2013-03-17  4:33 Arfrever Frehtes Taifersar Arahesis
2013-03-17  3:35 Arfrever Frehtes Taifersar Arahesis
2013-02-17 22:13 Zac Medico
2013-02-15 22:34 Zac Medico
2013-01-28  1:21 Zac Medico
2013-01-25 21:30 Zac Medico
2013-01-19  6:14 Zac Medico
2013-01-19  4:57 Zac Medico
2013-01-19  4:32 Zac Medico
2013-01-19  4:03 Zac Medico
2013-01-19  3:43 Zac Medico
2013-01-19  2:10 Zac Medico
2013-01-18 19:11 Zac Medico
2013-01-17 17:23 Zac Medico
2013-01-14 11:35 Zac Medico
2013-01-09 12:20 Zac Medico
2013-01-08  1:03 Zac Medico
2013-01-08  0:56 Zac Medico
2013-01-04  4:25 Zac Medico
2013-01-03 23:45 Zac Medico
2012-11-15 16:09 Zac Medico
2012-11-14 17:28 Zac Medico
2012-10-17 22:58 Zac Medico
2012-10-16 19:09 Zac Medico
2012-10-08 15:43 Zac Medico
2012-10-08 14:54 Zac Medico
2012-09-24 15:19 Zac Medico
2012-09-21 22:00 Zac Medico
2012-09-20  4:17 Zac Medico
2012-09-12  8:12 Zac Medico
2012-09-12  6:39 Zac Medico
2012-09-02  2:38 Zac Medico
2012-09-02  0:42 Zac Medico
2012-08-29 20:29 Zac Medico
2012-08-26 22:31 Zac Medico
2012-07-27 22:46 Zac Medico
2012-07-27 22:40 Zac Medico
2012-07-27 22:22 Zac Medico
2012-07-27 22:10 Zac Medico
2012-07-27  2:43 Zac Medico
2012-07-23  7:52 Zac Medico
2012-07-22 22:06 Zac Medico
2012-07-22 21:53 Zac Medico
2012-07-18 22:31 Zac Medico
2012-07-12 19:54 Zac Medico
2012-07-10  0:13 Zac Medico
2012-07-09 21:50 Zac Medico
2012-07-09 20:46 Zac Medico
2012-07-05  0:22 Zac Medico
2012-07-02 21:34 Zac Medico
2012-06-10 23:41 Zac Medico
2012-06-03  6:35 Arfrever Frehtes Taifersar Arahesis
2012-06-01 21:43 Zac Medico
2012-06-01 21:28 Zac Medico
2012-05-14  3:29 Zac Medico
2012-05-14  3:18 Zac Medico
2012-05-14  1:24 Zac Medico
2012-05-13 22:30 Zac Medico
2012-05-13 22:16 Zac Medico
2012-05-13 19:52 Zac Medico
2012-05-13  9:05 Zac Medico
2012-05-13  8:44 Zac Medico
2012-05-12 22:57 Zac Medico
2012-05-12 22:31 Arfrever Frehtes Taifersar Arahesis
2012-05-12 16:26 Arfrever Frehtes Taifersar Arahesis
2012-05-12  7:36 Zac Medico
2012-05-02 19:55 Zac Medico
2012-04-14  0:56 Zac Medico
2012-04-01 16:38 Zac Medico
2012-03-31 17:22 Zac Medico
2012-03-29  3:35 Mike Frysinger
2012-03-28  0:36 Zac Medico
2012-03-18 17:07 Zac Medico
2012-02-28  4:58 Zac Medico
2012-02-16 19:44 Arfrever Frehtes Taifersar Arahesis
2012-02-15  9:32 Zac Medico
2012-02-13 21:58 Zac Medico
2012-02-12  3:39 Zac Medico
2012-02-06 17:20 Zac Medico
2012-01-11  3:59 Arfrever Frehtes Taifersar Arahesis
2011-12-24  1:29 Arfrever Frehtes Taifersar Arahesis
2011-12-21 20:56 Zac Medico
2011-12-20 23:27 Zac Medico
2011-12-14 20:14 Arfrever Frehtes Taifersar Arahesis
2011-12-14 17:54 Zac Medico
2011-12-14  9:11 Zac Medico
2011-12-14  7:33 Zac Medico
2011-12-14  6:00 Zac Medico
2011-12-14  5:26 Zac Medico
2011-12-14  2:03 Zac Medico
2011-12-11  8:15 Zac Medico
2011-12-10 23:49 Zac Medico
2011-12-10 22:40 Zac Medico
2011-12-10 22:02 Zac Medico
2011-12-10 19:13 Zac Medico
2011-12-10  5:28 Arfrever Frehtes Taifersar Arahesis
2011-12-09 23:23 Zac Medico
2011-12-08 21:16 Zac Medico
2011-12-02  3:24 Zac Medico
2011-12-01 23:26 Zac Medico
2011-12-01 17:52 Zac Medico
2011-11-13 20:33 Zac Medico
2011-10-30  7:08 Zac Medico
2011-10-30  6:53 Zac Medico
2011-10-29  3:34 Zac Medico
2011-10-28  0:54 Zac Medico
2011-10-26 21:51 Zac Medico
2011-10-23 18:32 Zac Medico
2011-10-17 21:46 Zac Medico
2011-10-17  3:04 Zac Medico
2011-10-17  3:00 Zac Medico
2011-10-16 12:50 Arfrever Frehtes Taifersar Arahesis
2011-10-15  1:49 Zac Medico
2011-10-08  8:05 Zac Medico
2011-10-03 17:42 Zac Medico
2011-10-02 23:43 Zac Medico
2011-10-02 22:54 Zac Medico
2011-10-02  6:32 Zac Medico
2011-10-02  6:01 Zac Medico
2011-10-02  5:55 Zac Medico
2011-10-02  5:42 Zac Medico
2011-10-02  5:25 Zac Medico
2011-10-02  5:18 Zac Medico
2011-10-02  4:58 Zac Medico
2011-09-28  6:49 Zac Medico
2011-09-15  2:38 Zac Medico
2011-09-15  2:23 Zac Medico
2011-09-14  2:35 Zac Medico
2011-09-09 20:47 Zac Medico
2011-09-09  4:06 Zac Medico
2011-09-06 19:15 Zac Medico
2011-09-02  2:14 Zac Medico
2011-08-29  5:21 Zac Medico
2011-08-25 21:50 Arfrever Frehtes Taifersar Arahesis
2011-07-12 22:49 Zac Medico
2011-07-11  0:13 Zac Medico
2011-07-10 23:46 Zac Medico
2011-06-09 15:44 Zac Medico
2011-06-09 10:41 Zac Medico
2011-06-03 21:51 Zac Medico
2011-05-04  4:12 Zac Medico
2011-02-18  8:33 Zac Medico
2011-02-18  8:04 Zac Medico
2011-02-08  9:33 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox