[PATCH] Use yum's new headerless callback mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This enables yum's new callback mode which uses the associated
txmbr as the callback key instead of (header, rpmpath) tuples,
simplifying the callback code and avoiding unnecessary memory bloat.
This differs a bit from what was originally discussed for the
headerless callback but it's even nicer this way.

Some further cleanups are possible, eg it would no longer be necessary
to track self.inProgressPo but keeping this to minimum for now.

Note that this relies on a feature which doesn't yet exist in any
released yum version and in rawhide only since today, so you might
want a different version which is compatible with both modes. Ain't
hard to do at all and can supply such a patch if that's what you want,
consider this more of an demonstration of what the new callback looks like.
---
 anaconda.spec.in         |    2 +-
 pyanaconda/yuminstall.py |   31 ++++++++-----------------------
 2 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/anaconda.spec.in b/anaconda.spec.in
index bbbe1e8..cd79d34 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -29,7 +29,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 %define pykickstartver 1.81
 %define rpmpythonver 4.2-0.61
 %define slangver 2.0.6-2
-%define yumver 2.9.2
+%define yumver 3.2.29-8
 %define partedver 1.8.1
 %define pypartedver 2.5-2
 %define syscfgdatever 1.9.48
diff --git a/pyanaconda/yuminstall.py b/pyanaconda/yuminstall.py
index 93e557b..fd7fb00 100644
--- a/pyanaconda/yuminstall.py
+++ b/pyanaconda/yuminstall.py
@@ -144,18 +144,7 @@ class AnacondaCallback:
             self.progressWindow.pop()
 
         if what == rpm.RPMCALLBACK_INST_OPEN_FILE:
-            (hdr, rpmloc) = h
-            # hate hate hate at epochs...
-            epoch = hdr['epoch']
-            if epoch is not None:
-                epoch = str(epoch)
-            txmbrs = self.ayum.tsInfo.matchNaevr(hdr['name'], hdr['arch'],
-                                                 epoch, hdr['version'],
-                                                 hdr['release'])
-            if len(txmbrs) == 0:
-                raise RuntimeError, "Unable to find package %s-%s-%s.%s" %(hdr['name'], hdr['version'], hdr['release'], hdr['arch'])
-            po = txmbrs[0].po
-
+            po = h.po
             repo = self.repos.getRepo(po.repoid)
 
             pkgStr = "%s-%s-%s.%s" % (po.name, po.version, po.release, po.arch)
@@ -195,8 +184,6 @@ class AnacondaCallback:
                 self.initWindow.pop()
                 self.initWindow = None
 
-            (hdr, rpmloc) = h
-
             fn = self.openfile.name
             self.openfile.close()
             self.openfile = None
@@ -230,16 +217,11 @@ class AnacondaCallback:
         elif what in (rpm.RPMCALLBACK_CPIO_ERROR,
                       rpm.RPMCALLBACK_UNPACK_ERROR,
                       rpm.RPMCALLBACK_SCRIPT_ERROR):
-            if not isinstance(h, types.TupleType):
-                h = (h, None)
-
-            (hdr, rpmloc) = h
-
-            # If this is a cleanup/remove, then hdr is a string not a header.
-            if isinstance(hdr, basestring):
-                name = hdr
+            # If this is a cleanup/remove, then h is a string not a txmbr
+            if isinstance(h, basestring):
+                name = h
             else:
-                name = hdr['name']
+                name = h.name
 
             # Script errors store whether or not they're fatal in "total".  So,
             # we should only error out for fatal script errors or the cpio and
@@ -312,6 +294,9 @@ class AnacondaYum(yum.YumBase):
         # Only needed for media installs.
         self.mediagrabber = None
 
+        # Enable new callback mode
+        self.use_txmbr_in_callback = True
+
         # Where is the source media mounted?  This is the directory
         # where Packages/ is located.
         self.tree = "/mnt/source"
-- 
1.7.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux