]> git.pld-linux.org Git - packages/rpm.git/blobdiff - rpm-5.4.5-python-export-spec-macros.patch
- add fixes and useful features from Mandriva
[packages/rpm.git] / rpm-5.4.5-python-export-spec-macros.patch
diff --git a/rpm-5.4.5-python-export-spec-macros.patch b/rpm-5.4.5-python-export-spec-macros.patch
new file mode 100644 (file)
index 0000000..081deee
--- /dev/null
@@ -0,0 +1,70 @@
+--- rpm-5.4.5/python/spec-py.c.py_macros~      2012-03-01 22:55:19.592995392 +0100
++++ rpm-5.4.5/python/spec-py.c 2012-03-01 22:56:02.081016570 +0100
+@@ -6,6 +6,8 @@
+ #include <rpmiotypes.h>
+ #include <rpmio.h>
++#define _MACRO_INTERNAL
++#include <rpmmacro.h>
+ #include "spec-py.h"
+ /** \ingroup python
+@@ -146,6 +148,50 @@ spec_get_sources(specObject *s)
+ }
++static PyObject *
++spec_get_macros(specObject *s)
++    /*@*/
++{
++    MacroContext mc;
++    PyObject *macroDict;
++    Spec spec;
++
++    macroDict = PyDict_New();
++    if (!macroDict) {
++        return NULL;
++    }
++    spec = specFromSpec(s);
++    if ( spec != NULL) {
++      mc = spec->macros;
++      if (mc->macroTable != NULL) {
++          int i;
++          for (i = 0; i < mc->firstFree; i++) {
++              MacroEntry me;
++              PyObject *macro;
++              if ((me = mc->macroTable[i]) == NULL) {
++                  /* XXX this should never happen */
++                  continue;
++              }
++              macro = PyDict_New();
++
++              PyMapping_SetItemString(macro, "used", PyInt_FromLong(me->used));
++              PyMapping_SetItemString(macro, "level", PyInt_FromLong(me->level));
++              if (me->opts && *me->opts)
++                  PyMapping_SetItemString(macro, "opts", PyString_FromString(me->opts));
++              if (me->body && *me->body)
++                  PyMapping_SetItemString(macro, "body", PyString_FromString(me->body));
++              PyMapping_SetItemString(macroDict, strdup(me->name), macro);
++          }
++      }
++
++      return macroDict;
++    }
++    else {
++      return NULL;
++    }
++
++}
++
+ /**
+  */
+  /*@unchecked@*/ /*@observer@*/
+@@ -161,6 +207,7 @@ static PyMethodDef spec_Spec_methods[] =
+     {"check",   (PyCFunction) spec_get_check, METH_VARARGS,  NULL },
+     {"clean",   (PyCFunction) spec_get_clean, METH_VARARGS,  NULL },
+     {"buildRoot",   (PyCFunction) spec_get_buildroot, METH_VARARGS,  NULL },
++    {"macros",   (PyCFunction) spec_get_macros, METH_VARARGS,  NULL },
+     {NULL}  /* Sentinel */
+ };
+ /*@=fullinitblock@*/
This page took 0.064645 seconds and 4 git commands to generate.