public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/util/_dyn_libs/
@ 2011-05-08 20:50 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2011-05-08 20:50 UTC (permalink / raw
  To: gentoo-commits

commit:     eaa0691df6216347060d267e0285674a1b31ac2f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May  7 17:25:20 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May  8 18:42:35 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=eaa0691d

PreserveLibsRegistry: add lock/unlock assertions

Also, add comments to store() about unobvious interaction with
locking due to atomic replacement of the inode.

---
 .../util/_dyn_libs/PreservedLibsRegistry.py        |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
index f3cbb33..3fb8120 100644
--- a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
+++ b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
@@ -36,11 +36,16 @@ class PreservedLibsRegistry(object):
 
 	def lock(self):
 		"""Grab an exclusive lock on the preserved libs registry."""
+		if self._lock is not None:
+			raise AssertionError("already locked")
 		self._lock = lockfile(self._filename)
 
 	def unlock(self):
 		"""Release our exclusive lock on the preserved libs registry."""
+		if self._lock is None:
+			raise AssertionError("not locked")
 		unlockfile(self._lock)
+		self._lock = None
 
 	def load(self):
 		""" Reload the registry data from file """
@@ -65,7 +70,13 @@ class PreservedLibsRegistry(object):
 		self.pruneNonExisting()
 
 	def store(self):
-		""" Store the registry data to file """
+		"""
+		Store the registry data to the file. The existing inode will be
+		replaced atomically, so if that inode is currently being used
+		for a lock then that lock will be rendered useless. Therefore,
+		it is important not to call this method until the current lock
+		is ready to be immediately released.
+		"""
 		if os.environ.get("SANDBOX_ON") == "1" or \
 			self._data == self._data_orig:
 			return



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

* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/util/_dyn_libs/
@ 2011-05-08 20:50 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2011-05-08 20:50 UTC (permalink / raw
  To: gentoo-commits

commit:     794188c21d30ee7f1ef3d0c81505689b46b1f3bf
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May  8 07:09:37 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May  8 18:55:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=794188c2

linkmap: use exclude_pkgs for the registry too

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

diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py b/pym/portage/util/_dyn_libs/LinkageMapELF.py
index 9e79bd8..d856e92 100644
--- a/pym/portage/util/_dyn_libs/LinkageMapELF.py
+++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py
@@ -198,8 +198,15 @@ class LinkageMapELF(object):
 			plibs.update(preserve_paths)
 		if self._dbapi._plib_registry and \
 			self._dbapi._plib_registry.hasEntries():
-			for items in \
-				self._dbapi._plib_registry.getPreservedLibs().values():
+			for cpv, items in \
+				self._dbapi._plib_registry.getPreservedLibs().items():
+				if exclude_pkgs is not None and cpv in exclude_pkgs:
+					# These preserved libs will either be unmerged,
+					# rendering them irrelevant, or they will be
+					# preserved in the replacement package and are
+					# already represented via the preserve_paths
+					# parameter.
+					continue
 				plibs.update(items)
 		if plibs:
 			args = ["/usr/bin/scanelf", "-qF", "%a;%F;%S;%r;%n"]



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

* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/util/_dyn_libs/
@ 2011-05-08 21:31 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2011-05-08 21:31 UTC (permalink / raw
  To: gentoo-commits

commit:     6b5f06e0b6f7b1bf2d569d0465f873bc35797631
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May  8 21:31:11 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May  8 21:31:46 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6b5f06e0

PreservedLibsRegistry: normalize counter as str

---
 .../util/_dyn_libs/PreservedLibsRegistry.py        |   26 ++++++++++++++++---
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
index 3fb8120..838cbaa 100644
--- a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
+++ b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
@@ -3,6 +3,7 @@
 
 import errno
 import logging
+import sys
 
 try:
 	import cPickle as pickle
@@ -12,6 +13,7 @@ except ImportError:
 from portage import os
 from portage import _encodings
 from portage import _os_merge
+from portage import _unicode_decode
 from portage import _unicode_encode
 from portage.exception import PermissionDenied
 from portage.localization import _
@@ -20,6 +22,9 @@ from portage.util import writemsg_level
 from portage.versions import cpv_getkey
 from portage.locks import lockfile, unlockfile
 
+if sys.hexversion >= 0x3000000:
+	basestring = str
+
 class PreservedLibsRegistry(object):
 	""" This class handles the tracking of preserved library objects """
 	def __init__(self, root, filename):
@@ -91,6 +96,17 @@ class PreservedLibsRegistry(object):
 		else:
 			self._data_orig = self._data.copy()
 
+	def _normalize_counter(self, counter):
+		"""
+		For simplicity, normalize as a unicode string
+		and strip whitespace. This avoids the need for
+		int conversion and a possible ValueError resulting
+		from vardb corruption.
+		"""
+		if not isinstance(counter, basestring):
+			counter = str(counter)
+		return _unicode_decode(counter).strip()
+
 	def register(self, cpv, slot, counter, paths):
 		""" Register new objects in the registry. If there is a record with the
 			same packagename (internally derived from cpv) and slot it is 
@@ -99,19 +115,21 @@ class PreservedLibsRegistry(object):
 			@type cpv: CPV (as String)
 			@param slot: the value of SLOT of the given package instance
 			@type slot: String
-			@param counter: vdb counter value for the package instace
-			@type counter: Integer
+			@param counter: vdb counter value for the package instance
+			@type counter: String
 			@param paths: absolute paths of objects that got preserved during an update
 			@type paths: List
 		"""
 		cp = cpv_getkey(cpv)
 		cps = cp+":"+slot
+		counter = self._normalize_counter(counter)
 		if len(paths) == 0 and cps in self._data \
-				and self._data[cps][0] == cpv and int(self._data[cps][1]) == int(counter):
+				and self._data[cps][0] == cpv and \
+				self._normalize_counter(self._data[cps][1]) == counter:
 			del self._data[cps]
 		elif len(paths) > 0:
 			self._data[cps] = (cpv, counter, paths)
-	
+
 	def unregister(self, cpv, slot, counter):
 		""" Remove a previous registration of preserved objects for the given package.
 			@param cpv: package instance whose records should be removed



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

* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/util/_dyn_libs/
@ 2011-05-08 21:40 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2011-05-08 21:40 UTC (permalink / raw
  To: gentoo-commits

commit:     66c5f7a74d2204dce2413c0e6e57d29ee62eafa9
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May  8 21:40:08 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May  8 21:40:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=66c5f7a7

Update timestamps in headers of modified files.

---
 pym/portage/util/_dyn_libs/LinkageMapELF.py        |    2 +-
 .../util/_dyn_libs/PreservedLibsRegistry.py        |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py b/pym/portage/util/_dyn_libs/LinkageMapELF.py
index d856e92..3305aca 100644
--- a/pym/portage/util/_dyn_libs/LinkageMapELF.py
+++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2010 Gentoo Foundation
+# Copyright 1998-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import errno

diff --git a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
index 838cbaa..602cf87 100644
--- a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
+++ b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2010 Gentoo Foundation
+# Copyright 1998-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import errno



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

end of thread, other threads:[~2011-05-08 21:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-08 20:50 [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/util/_dyn_libs/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2011-05-08 20:50 Zac Medico
2011-05-08 21:31 Zac Medico
2011-05-08 21:40 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox