[Yum] Get rid of the header download

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

 



I started looking at this item on the YumIdeas page.  A yum upgrade from
FC5 to FC6 pushed me over the edge. :)

I think the critical piece to get this working is to fill out the RPM
Python interface.  Currently you cannot create new hdr objects from
python.  The only factory interfaces I found depend on reading a binary
blog, which is exactly what we want to avoid.

I started trying to get "h = rpm.hdr()" working and ran into a big
problem.  I created a tp_new function for hdr which allowed me to create
new hdr objects in Python.  Then I allocated the Header structure in
hdrObject and all hell broke loose.  On my system calling headerNew()
totally clobbers the hdrObject.

Can someone else try this?

1. Download rpm source
2. apply the following patch to rpm/python/header-py.c
3. build and install the python directory.
4. run these commands in python:
  import rpm
  h = rpm.hdr()
  dir(h)

I've been setting a breakpoint in "hdr_new" and running it under gdb.

Nate


[nate@localhost python]$ diff -u header-py.c.pyapi header-py.c
--- header-py.c.pyapi   2006-10-29 08:03:04.000000000 -0600
+++ header-py.c 2006-10-29 09:44:03.000000000 -0600
@@ -420,6 +420,24 @@
     return PyObject_GenericSetAttr(o, n, v);
 }
 
+/** \ingroup py_c
+ */
+static void hdr_new(PyTypeObject *subtype, PyObject *args, PyObject
*kwds)
+{
+    hdrObject *self;
+    Header h;
+    self = (hdrObject *)subtype->tp_alloc(subtype, 0);
+    if (self != NULL) {
+       h = headerNew();
+        if (h == NULL) {
+           Py_DECREF(self);
+           return NULL;
+       }
+        self->h = h;
+    }
+
+    return (PyObject *)self;
+}
 
 /** \ingroup py_c
  */
@@ -648,7 +666,7 @@
 /**
  */
 static char hdr_doc[] =
-"";
+"RPM Header Class";
 
 /** \ingroup py_c
  */
@@ -693,7 +711,7 @@
        0,                              /* tp_dictoffset */
        0,                              /* tp_init */
        0,                              /* tp_alloc */
-       0,                              /* tp_new */
+       hdr_new,                        /* tp_new */
        0,                              /* tp_free */
        0,                              /* tp_is_gc */
 #endif



[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux