[Yum-devel] [PATCH 2/4] Save loginuids of installed_by and changed_by to the yumdb

James Antill james at and.org
Thu Jun 10 20:47:58 UTC 2010


---
 yum/__init__.py |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index fa26e62..8e58124 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1419,7 +1419,29 @@ class YumBase(depsolve.Depsolve):
                     po.yumdb_info.from_repo_revision  = str(md.revision)
                 if md:
                     po.yumdb_info.from_repo_timestamp = str(md.timestamp)
-            
+
+                loginuid = misc.getloginuid()
+                if loginuid is None:
+                    continue
+                loginuid = str(loginuid)
+                if (txmbr.updates or txmbr.downgrades or
+                    (hasattr(txmbr, 'reinstall') and txmbr.reinstall)):
+                    if txmbr.updates:
+                        opo = txmbr.updates[0]
+                    elif txmbr.downgrades:
+                        opo = txmbr.downgrades[0]
+                    else:
+                        opo = po
+                    if 'installed_by' in opo.yumdb_info:
+                        po.yumdb_info.installed_by = opo.yumdb_info.installed_by
+                    po.yumdb_info.changed_by = loginuid
+                else:
+                    po.yumdb_info.installed_by = loginuid
+
+        # Remove old ones after installing new ones, so we can copy values.
+        for txmbr in self.tsInfo:
+            if txmbr.output_state in TS_INSTALL_STATES:
+                pass
             elif txmbr.output_state in TS_REMOVE_STATES:
                 if self.rpmdb.contains(po=txmbr.po):
                     if not self.tsInfo.getMembersWithState(pkgtup=txmbr.pkgtup,
-- 
1.7.0.1



More information about the Yum-devel mailing list