]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-5.4.5-python-export-spec-macros.patch
- don't install and package some useless scripts
[packages/rpm.git] / rpm-5.4.5-python-export-spec-macros.patch
1 --- rpm-5.4.16/python/spec-py.c~        2016-03-16 17:22:00.000000000 +0200
2 +++ rpm-5.4.16/python/spec-py.c 2016-03-16 17:24:05.660232743 +0200
3 @@ -6,6 +6,8 @@
4  
5  #include <rpmiotypes.h>
6  #include <rpmio.h>
7 +#define _MACRO_INTERNAL
8 +#include <rpmmacro.h>
9  #include "spec-py.h"
10  
11  /** \ingroup python
12 @@ -257,6 +257,50 @@
13      return makeHeader(spec->sourceHeader);
14  }
15  
16 +static PyObject *
17 +spec_get_macros(specObject *s, void *closure)
18 +    /*@*/
19 +{
20 +    MacroContext mc;
21 +    PyObject *macroDict;
22 +    Spec spec;
23 +
24 +    macroDict = PyDict_New();
25 +    if (!macroDict) {
26 +        return NULL;
27 +    }
28 +    spec = specFromSpec(s);
29 +    if ( spec != NULL) {
30 +       mc = spec->macros;
31 +       if (mc->macroTable != NULL) {
32 +           int i;
33 +           for (i = 0; i < mc->firstFree; i++) {
34 +               MacroEntry me;
35 +               PyObject *macro;
36 +               if ((me = mc->macroTable[i]) == NULL) {
37 +                   /* XXX this should never happen */
38 +                   continue;
39 +               }
40 +               macro = PyDict_New();
41 +
42 +               PyMapping_SetItemString(macro, "used", PyInt_FromLong(me->used));
43 +               PyMapping_SetItemString(macro, "level", PyInt_FromLong(me->level));
44 +               if (me->opts && *me->opts)
45 +                   PyMapping_SetItemString(macro, "opts", PyString_FromString(me->opts));
46 +               if (me->body && *me->body)
47 +                   PyMapping_SetItemString(macro, "body", PyString_FromString(me->body));
48 +               PyMapping_SetItemString(macroDict, strdup(me->name), macro);
49 +           }
50 +       }
51 +
52 +       return macroDict;
53 +    }
54 +    else {
55 +       return NULL;
56 +    }
57 +
58 +}
59 +
60  static char spec_doc[] = "RPM Spec file object";
61  
62  static PyGetSetDef spec_getseters[] = {
63 @@ -269,6 +313,7 @@
64      {"buildRoot",   (getter) spec_get_buildroot, NULL, NULL },
65      {"packages", (getter) spec_get_packages, NULL, NULL },
66      {"sourceHeader", (getter) spec_get_source_header, NULL, NULL },
67 +    {"macros",   (getter) spec_get_macros, NULL,  NULL },
68      {NULL}  /* Sentinel */
69  };
70  
This page took 0.313631 seconds and 3 git commands to generate.