aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Erdmann <dywi@mailerd.de>2013-01-30 20:57:42 +0100
committerAndré Erdmann <dywi@mailerd.de>2013-01-30 21:00:33 +0100
commit78675495ed708852d5771ebd98aec38d0c2ed6ab (patch)
treead8c60018e7b96f1cc15d0c7ab296408bb9a93c2 /roverlay/packageinfo.py
parentebuild: add sys-apps/portage to RDEPEND (diff)
downloadR_overlay-78675495ed708852d5771ebd98aec38d0c2ed6ab.tar.gz
R_overlay-78675495ed708852d5771ebd98aec38d0c2ed6ab.tar.bz2
R_overlay-78675495ed708852d5771ebd98aec38d0c2ed6ab.zip
packageinfo: update_unsafe(), add ebuild variables
new function update_unsafe() that simply adds information to a PackageInfo instance without locking or checking for writability. added EVAR* key that can be used to add per-package ebuild variables (evar)
Diffstat (limited to 'roverlay/packageinfo.py')
-rw-r--r--roverlay/packageinfo.py45
1 files changed, 36 insertions, 9 deletions
diff --git a/roverlay/packageinfo.py b/roverlay/packageinfo.py
index f4b7c9e..438433c 100644
--- a/roverlay/packageinfo.py
+++ b/roverlay/packageinfo.py
@@ -357,6 +357,17 @@ class PackageInfo ( object ):
self.set_readonly()
# --- end of update_now (...) ---
+ def update_unsafe ( self, **info ):
+ """Updates the package info data without retrieving any locks or
+ checking writability.
+ Meant for usage with "package actions" (packagerules module).
+
+ arguments:
+ * **info --
+ """
+ self._update ( info )
+ # --- end of update_unsafe (...) ---
+
def update ( self, **info ):
"""Uses **info to update the package info data.
@@ -369,13 +380,27 @@ class PackageInfo ( object ):
# nothing to do
return
- initial = len ( self._info ) == 0
-
# remove_auto has to be the last action (keyword order is not "stable")
remove_auto = info.pop ( 'remove_auto', None )
self._writelock_acquire()
+ self._update ( info )
+
+ if remove_auto:
+ self._remove_auto ( remove_auto )
+
+ self._update_lock.release()
+ # --- end of update (**kw) ---
+
+ def _update ( self, info ):
+ """Updates self._info using the given info dict.
+
+ arguments:
+ * info --
+ """
+ initial = len ( self._info ) == 0
+
for key, value in info.items():
if key in self.__class__._UPDATE_KEYS_SIMPLE:
@@ -384,6 +409,13 @@ class PackageInfo ( object ):
elif initial and key in self.__class__._UPDATE_KEYS_SIMPLE_INITIAL:
self [key] = value
+ elif key[:4] == 'EVAR':
+ if 'EVAR' in self._info:
+ self._info ['EVAR'].add ( value )
+ else:
+ # set or dict?
+ self._info ['EVAR'] = set ( ( value, ) )
+
elif key in self.__class__._UPDATE_KEYS_FILTER_NONE:
if value is not None:
self [key] = value
@@ -416,15 +448,10 @@ class PackageInfo ( object ):
else:
self.logger.error (
- "in update(): unknown info key {}!".format ( key )
+ "in _update(): unknown info key {}!".format ( key )
)
# -- end for;
-
- if remove_auto:
- self._remove_auto ( remove_auto )
-
- self._update_lock.release()
- # --- end of update (**kw) ---
+ # --- end of _update (...) ---
def _use_filename ( self, _filename ):
"""auxiliary method for update(**kw)