[Yum-devel] [PATCH] Fix no script output from transaction, BZ 554462

Panu Matilainen pmatilai at laiskiainen.org
Wed Jan 20 09:39:02 UTC 2010


On Tue, 19 Jan 2010, Seth Vidal wrote:
>
> On Tue, 19 Jan 2010, James Antill wrote:
>
>> ---
>> yum/rpmtrans.py |    3 ++-
>> 1 files changed, 2 insertions(+), 1 deletions(-)
>> 
>> diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
>> index f33f048..0340153 100644
>> --- a/yum/rpmtrans.py
>> +++ b/yum/rpmtrans.py
>> @@ -209,7 +209,8 @@ class RPMTransaction:
>>         io_r = tempfile.NamedTemporaryFile()
>>         self._readpipe = io_r
>>         self._writepipe = open(io_r.name, 'w+b')
>> -        self.base.ts.scriptFd = self._writepipe.fileno()
>> +        # This is dark magic, it really needs to be "base.ts.ts".
>> +        self.base.ts.ts.scriptFd = self._writepipe.fileno()
>>         rpmverbosity = {'critical' : 'crit',
>>                         'emergency' : 'emerg',
>>                         'error' : 'err',
>
> I'd like to hear from someone in suse, if possible

The patch cannot have been correct, really. Either it would've required 
other changes to TransactionWrapper class, or (perhaps more likely) the 
change just masked away the real problem.

Without other changes to yum's TransactionWrapper class, this change
-        self.base.ts.ts.scriptFd = self._writepipe.fileno()
+        self.base.ts.scriptFd = self._writepipe.fileno()

..is precisely equal to
-        self.base.ts.ts.scriptFd = self._writepipe.fileno()
+        self.base.ts.foobar = self._writepipe.fileno()

Not knowing what the real problem was with yum in Suse at that time, it's 
impossible to come up with a correct workaround/fix for *that* issue.
But the right thing to do here is either James' patch above, OR something 
like the attached variant of James' patch in 
http://lists.baseurl.org/pipermail/yum-devel/2010-January/006529.html 
which:
- changes TransactionWrapper to be new-style class to make property() work
- adds a write-only property wrapper for scriptFd (its write-only in
   rpm-python level too)

diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index 329de69..c189973 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -19,7 +19,7 @@ ts = None

  # wrapper/proxy class for rpm.Transaction so we can
  # instrument it, etc easily
-class TransactionWrapper:
+class TransactionWrapper(object):
      def __init__(self, root='/'):
          self.ts = rpm.TransactionSet(root)
          self._methods = ['dbMatch',
@@ -48,6 +48,11 @@ class TransactionWrapper:
          # Automatically close the rpm transaction when the reference is lost
          self.close()

+    def _wrap_scriptFd_set(self, val):
+        self.ts.scriptFd = val
+
+    scriptFd = property(fget=None, fset=_wrap_scriptFd_set)
+
      def close(self):
          if self.open:
              self.ts.closeDB()

 	- Panu -




More information about the Yum-devel mailing list