Add librpm-tizen.spec file & Debian packaging.
[tools/librpm-tizen.git] / python / rpmmodule.c
1 #include "rpmsystem-py.h"
2
3 #include <rpm/rpmlib.h>         /* rpmMachineScore, rpmReadConfigFiles */
4 #include <rpm/rpmtag.h>
5 #include <rpm/rpmdb.h>
6 #include <rpm/rpmsq.h>
7 #include <rpm/rpmlog.h>
8 #include <rpm/rpmmacro.h>
9 #include <rpm/rpmsign.h>
10
11 #include "header-py.h"
12 #include "rpmarchive-py.h"
13 #include "rpmds-py.h"
14 #include "rpmfd-py.h"
15 #include "rpmfi-py.h"
16 #include "rpmfiles-py.h"
17 #include "rpmkeyring-py.h"
18 #include "rpmmi-py.h"
19 #include "rpmii-py.h"
20 #include "rpmps-py.h"
21 #include "rpmmacro-py.h"
22 #include "rpmstrpool-py.h"
23 #include "rpmtd-py.h"
24 #include "rpmte-py.h"
25 #include "rpmts-py.h"
26 #include "spec-py.h"
27
28 /** \ingroup python
29  * \name Module: rpm
30  */
31
32 PyObject * pyrpmError;
33
34 static PyObject * archScore(PyObject * self, PyObject * arg)
35 {
36     const char * arch;
37
38     if (!PyArg_Parse(arg, "s", &arch))
39         return NULL;
40
41     return Py_BuildValue("i", rpmMachineScore(RPM_MACHTABLE_INSTARCH, arch));
42 }
43
44 static PyObject * signalCaught(PyObject *self, PyObject *o)
45 {
46     int signo;
47     if (!PyArg_Parse(o, "i", &signo)) return NULL;
48
49     return PyBool_FromLong(rpmsqIsCaught(signo));
50 }
51
52 static PyObject * checkSignals(PyObject * self)
53 {
54     return Py_BuildValue("i", rpmsqPoll());
55 }
56
57 static PyObject * blockSignals(PyObject * self, PyObject *arg)
58 {
59     int block;
60     if (!PyArg_Parse(arg, "p", &block)) return NULL;
61
62     return Py_BuildValue("i", rpmsqBlock(block ? SIG_BLOCK : SIG_UNBLOCK));
63 }
64
65
66 static PyObject * setLogFile (PyObject * self, PyObject *arg)
67 {
68     FILE *fp;
69     int fdno = PyObject_AsFileDescriptor(arg);
70
71     if (fdno >= 0) {
72         /* XXX we dont know the mode here.. guessing append for now */
73         fp = fdopen(fdno, "a");
74         if (fp == NULL) {
75             PyErr_SetFromErrno(PyExc_IOError);
76             return NULL;
77         }
78     } else if (arg == Py_None) {
79         fp = NULL;
80     } else {
81         PyErr_SetString(PyExc_TypeError, "file object or None expected");
82         return NULL;
83     }
84
85     (void) rpmlogSetFile(fp);
86     Py_RETURN_NONE;
87 }
88
89 static PyObject *
90 setVerbosity (PyObject * self, PyObject * arg)
91 {
92     int level;
93
94     if (!PyArg_Parse(arg, "i", &level))
95         return NULL;
96
97     rpmSetVerbosity(level);
98
99     Py_RETURN_NONE;
100 }
101
102 static PyObject *
103 setEpochPromote (PyObject * self, PyObject * arg)
104 {
105     if (!PyArg_Parse(arg, "i", &_rpmds_nopromote))
106         return NULL;
107
108     Py_RETURN_NONE;
109 }
110
111 static PyObject * setStats (PyObject * self, PyObject * arg)
112 {
113     if (!PyArg_Parse(arg, "i", &_rpmts_stats))
114         return NULL;
115
116     Py_RETURN_NONE;
117 }
118
119 static PyObject * doLog(PyObject * self, PyObject * args, PyObject *kwds)
120 {
121     int code;
122     const char *msg;
123     char * kwlist[] = {"code", "msg", NULL};
124     if (!PyArg_ParseTupleAndKeywords(args, kwds, "is", kwlist, &code, &msg))
125         return NULL;
126
127     rpmlog(code, "%s", msg);
128     Py_RETURN_NONE;
129 }
130
131 static PyObject * reloadConfig(PyObject * self, PyObject * args, PyObject *kwds)
132 {
133     const char * target = NULL;
134     char * kwlist[] = { "target", NULL };
135     int rc;
136     
137     if (!PyArg_ParseTupleAndKeywords(args, kwds, "|s", kwlist, &target))
138         return NULL;
139
140     rpmFreeMacros(NULL);
141     rpmFreeRpmrc();
142     rc = rpmReadConfigFiles(NULL, target) ;
143
144     return PyBool_FromLong(rc == 0);
145 }
146
147 static PyObject * setInterruptSafety(PyObject * self, PyObject * args, PyObject *kwds)
148 {
149     int on = 1;
150     PyObject * obj;
151     char * kwlist[] = { "on", NULL };
152     if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, &obj))
153         return NULL;
154     if (obj) {
155         on = PyObject_IsTrue(obj);
156     }
157     rpmsqSetInterruptSafety(on);
158     Py_RETURN_NONE;
159 }
160
161 static int parseSignArgs(PyObject * args, PyObject *kwds,
162                         const char **path, struct rpmSignArgs *sargs)
163 {
164     char * kwlist[] = { "path", "keyid", "hashalgo", NULL };
165
166     memset(sargs, 0, sizeof(*sargs));
167     return PyArg_ParseTupleAndKeywords(args, kwds, "s|si", kwlist,
168                                     path, &sargs->keyid, &sargs->hashalgo);
169 }
170
171 static PyObject * addSign(PyObject * self, PyObject * args, PyObject *kwds)
172 {
173     const char *path = NULL;
174     struct rpmSignArgs sargs;
175
176     if (!parseSignArgs(args, kwds, &path, &sargs))
177         return NULL;
178
179     return PyBool_FromLong(rpmPkgSign(path, &sargs) == 0);
180 }
181
182 static PyObject * delSign(PyObject * self, PyObject * args, PyObject *kwds)
183 {
184     const char *path = NULL;
185     struct rpmSignArgs sargs;
186
187     if (!parseSignArgs(args, kwds, &path, &sargs))
188         return NULL;
189
190     return PyBool_FromLong(rpmPkgDelSign(path, &sargs) == 0);
191 }
192
193 static PyMethodDef rpmModuleMethods[] = {
194     { "addMacro", (PyCFunction) rpmmacro_AddMacro, METH_VARARGS|METH_KEYWORDS,
195       "rpmPushMacro(macro, value)\n"
196     },
197     { "delMacro", (PyCFunction) rpmmacro_DelMacro, METH_VARARGS|METH_KEYWORDS,
198       "rpmPopMacro(macro)\n"
199     },
200     { "expandMacro", (PyCFunction) rpmmacro_ExpandMacro, METH_VARARGS|METH_KEYWORDS,
201       "expandMacro(string, numeric=False) -- expands a string containing macros\n\n"
202       "Returns an int if numeric is True. 'Y' or 'y' returns 1,\n'N' or 'n' returns 0\nAn undefined macro returns 0."},
203
204     { "archscore", (PyCFunction) archScore, METH_O,
205       "archscore(archname) -- How well does an architecture fit on this machine\n\n"
206       "0 for non matching arch names\n1 for best arch\nhigher numbers for less fitting arches\n(e.g. 2 for \"i586\" on an i686 machine)" },
207
208     { "signalCaught", (PyCFunction) signalCaught, METH_O, 
209         "signalCaught(signo) -- Returns True if signal was caught." },
210     { "checkSignals", (PyCFunction) checkSignals, METH_NOARGS,
211       "checkSignals() -- Check for and exit on termination signals."},
212     { "blockSignals", (PyCFunction) blockSignals, METH_O,
213       "blocksignals(True/False) -- Block/unblock signals, refcounted."},
214
215     { "mergeHeaderListFromFD", (PyCFunction) rpmMergeHeadersFromFD, METH_VARARGS|METH_KEYWORDS,
216         NULL },
217
218     { "log",            (PyCFunction) doLog, METH_VARARGS|METH_KEYWORDS,
219         "log(level, msg) -- Write msg to log if level is selected to be logged.\n\n"
220     "level must be one of the RPMLOG_* constants."},
221     { "setLogFile", (PyCFunction) setLogFile, METH_O,
222         "setLogFile(file) -- set file to write log messages to or None." },
223
224     { "versionCompare", (PyCFunction) versionCompare, METH_VARARGS|METH_KEYWORDS,
225       "versionCompare(version0, version1) -- compares two version strings\n\n"
226       "Returns 1 if version0 > version1\n"
227       "Returns 0 if version0 == version1\n"
228       "Returns -1 if version0 < version1\n"},
229     { "labelCompare", (PyCFunction) labelCompare, METH_VARARGS|METH_KEYWORDS,
230       "labelCompare(version0, version1) -- as versionCompare()\n\n"
231       "but arguments are tuples of of strings for (epoch, version, release)"},
232     { "setVerbosity", (PyCFunction) setVerbosity, METH_O,
233       "setVerbosity(level) -- Set log level. See RPMLOG_* constants." },
234     { "setEpochPromote", (PyCFunction) setEpochPromote, METH_O,
235         "setEpochPromote(bool) -- Set if no epoch shall be treated as epoch 0" },
236     { "setStats", (PyCFunction) setStats, METH_O,
237       "setStats(bool) -- Set if timing stats are printed after a transaction."},
238     { "reloadConfig", (PyCFunction) reloadConfig, METH_VARARGS|METH_KEYWORDS,
239       "reloadConfig(target=None) -- Reload config from files.\n\n"
240       "Set all macros and settings accordingly."},
241
242     { "setInterruptSafety", (PyCFunction) setInterruptSafety,
243       METH_VARARGS|METH_KEYWORDS,
244       "setInterruptSafety(on=True) -- Set if various signals get intercepted.\n\n"
245       "By default, librpm will trap various unix signals (like SIGINT and\n"
246       "SIGTERM), in order to avoid process exit while locks are held or\n"
247       "a transaction is being performed.\n\n"
248       "If this is not the desired behaviour it's recommended to call this\n"
249       "once only at process startup because currently signal handlers will\n"
250       "not be retroactively applied if a database is open."
251     },
252     { "addSign", (PyCFunction) addSign, METH_VARARGS|METH_KEYWORDS, NULL },
253     { "delSign", (PyCFunction) delSign, METH_VARARGS|METH_KEYWORDS, NULL },
254     { NULL }
255 } ;
256
257 static char rpm__doc__[] = "";
258
259 /*
260  * Add rpm tag dictionaries to the module
261  */
262 static void addRpmTags(PyObject *module)
263 {
264     PyObject *pyval, *pyname, *dict = PyDict_New();
265     rpmtd names = rpmtdNew();
266     rpmTagGetNames(names, 1);
267     const char *tagname, *shortname;
268     rpmTagVal tagval;
269
270     while ((tagname = rpmtdNextString(names))) {
271         shortname = tagname + strlen("RPMTAG_");
272         tagval = rpmTagGetValue(shortname);
273
274         PyModule_AddIntConstant(module, tagname, tagval);
275         pyval = PyLong_FromLong(tagval);
276         pyname = utf8FromString(shortname);
277         PyDict_SetItem(dict, pyval, pyname);
278         Py_DECREF(pyval);
279         Py_DECREF(pyname);
280     }
281     PyModule_AddObject(module, "tagnames", dict);
282     rpmtdFree(names);
283 }
284
285 /*
286   Do any common preliminary work before python 2 vs python 3 module creation:
287 */
288 static int prepareInitModule(void)
289 {
290     if (PyType_Ready(&hdr_Type) < 0) return 0;
291     if (PyType_Ready(&rpmarchive_Type) < 0) return 0;
292     if (PyType_Ready(&rpmds_Type) < 0) return 0;
293     if (PyType_Ready(&rpmfd_Type) < 0) return 0;
294     if (PyType_Ready(&rpmfi_Type) < 0) return 0;
295     if (PyType_Ready(&rpmfile_Type) < 0) return 0;
296     if (PyType_Ready(&rpmfiles_Type) < 0) return 0;
297     if (PyType_Ready(&rpmKeyring_Type) < 0) return 0;
298     if (PyType_Ready(&rpmmi_Type) < 0) return 0;
299     if (PyType_Ready(&rpmii_Type) < 0) return 0;
300     if (PyType_Ready(&rpmProblem_Type) < 0) return 0;
301     if (PyType_Ready(&rpmPubkey_Type) < 0) return 0;
302     if (PyType_Ready(&rpmstrPool_Type) < 0) return 0;
303 #if 0
304     if (PyType_Ready(&rpmtd_Type) < 0) return 0;
305 #endif
306     if (PyType_Ready(&rpmte_Type) < 0) return 0;
307     if (PyType_Ready(&rpmts_Type) < 0) return 0;
308     if (PyType_Ready(&spec_Type) < 0) return 0;
309     if (PyType_Ready(&specPkg_Type) < 0) return 0;
310
311     return 1;
312 }
313 static int initModule(PyObject *m);
314
315 #if PY_MAJOR_VERSION >= 3
316 static int rpmModuleTraverse(PyObject *m, visitproc visit, void *arg) {
317     Py_VISIT(pyrpmError);
318     return 0;
319 }
320
321 static int rpmModuleClear(PyObject *m) {
322     Py_CLEAR(pyrpmError);
323     return 0;
324 }
325
326 static struct PyModuleDef moduledef = {
327     PyModuleDef_HEAD_INIT,
328     "_rpm",            /* m_name */
329     rpm__doc__,        /* m_doc */
330     0,                 /* m_size */
331     rpmModuleMethods,
332     NULL,              /* m_reload */
333     rpmModuleTraverse,
334     rpmModuleClear,
335     NULL               /* m_free */
336 };
337
338 PyObject *
339 PyInit__rpm(void);
340
341 PyObject *
342 PyInit__rpm(void)
343 {
344     PyObject * m;
345     if (!prepareInitModule()) return NULL;
346     m = PyModule_Create(&moduledef);
347     initModule(m);
348     return m;
349 }
350 #else
351 void init_rpm(void);    /* XXX eliminate gcc warning */
352 void init_rpm(void)
353 {
354     PyObject * m;
355
356     if (!prepareInitModule()) return;
357     m = Py_InitModule3("_rpm", rpmModuleMethods, rpm__doc__);
358     if (m == NULL)
359         return;
360     initModule(m);
361 }
362 #endif
363
364 /* Shared python2/3 module initialization: */
365 static int initModule(PyObject *m)
366 {
367     PyObject * d;
368
369     /* failure to initialize rpm (crypto and all) is rather fatal too... */
370     if (rpmReadConfigFiles(NULL, NULL) == -1)
371         return 0;
372
373     d = PyModule_GetDict(m);
374
375     pyrpmError = PyErr_NewException("_rpm.error", NULL, NULL);
376     if (pyrpmError != NULL)
377         PyDict_SetItemString(d, "error", pyrpmError);
378
379     Py_INCREF(&hdr_Type);
380     PyModule_AddObject(m, "hdr", (PyObject *) &hdr_Type);
381
382     Py_INCREF(&rpmarchive_Type);
383     PyModule_AddObject(m, "archive", (PyObject *) &rpmarchive_Type);
384
385     Py_INCREF(&rpmds_Type);
386     PyModule_AddObject(m, "ds", (PyObject *) &rpmds_Type);
387
388     Py_INCREF(&rpmfd_Type);
389     PyModule_AddObject(m, "fd", (PyObject *) &rpmfd_Type);
390
391     Py_INCREF(&rpmfi_Type);
392     PyModule_AddObject(m, "fi", (PyObject *) &rpmfi_Type);
393
394     Py_INCREF(&rpmfile_Type);
395     PyModule_AddObject(m, "file", (PyObject *) &rpmfile_Type);
396
397     Py_INCREF(&rpmfiles_Type);
398     PyModule_AddObject(m, "files", (PyObject *) &rpmfiles_Type);
399
400     Py_INCREF(&rpmKeyring_Type);
401     PyModule_AddObject(m, "keyring", (PyObject *) &rpmKeyring_Type);
402
403     Py_INCREF(&rpmmi_Type);
404     PyModule_AddObject(m, "mi", (PyObject *) &rpmmi_Type);
405
406     Py_INCREF(&rpmii_Type);
407     PyModule_AddObject(m, "ii", (PyObject *) &rpmii_Type);
408
409     Py_INCREF(&rpmProblem_Type);
410     PyModule_AddObject(m, "prob", (PyObject *) &rpmProblem_Type);
411
412     Py_INCREF(&rpmPubkey_Type);
413     PyModule_AddObject(m, "pubkey", (PyObject *) &rpmPubkey_Type);
414
415     Py_INCREF(&rpmstrPool_Type);
416     PyModule_AddObject(m, "strpool", (PyObject *) &rpmstrPool_Type);
417
418 #if 0
419     Py_INCREF(&rpmtd_Type);
420     PyModule_AddObject(m, "td", (PyObject *) &rpmtd_Type);
421 #endif
422
423     Py_INCREF(&rpmte_Type);
424     PyModule_AddObject(m, "te", (PyObject *) &rpmte_Type);
425
426     Py_INCREF(&rpmts_Type);
427     PyModule_AddObject(m, "ts", (PyObject *) &rpmts_Type);
428
429     Py_INCREF(&spec_Type);
430     PyModule_AddObject(m, "spec", (PyObject *) &spec_Type);
431
432     Py_INCREF(&specPkg_Type);
433     PyModule_AddObject(m, "specPkg", (PyObject *) &specPkg_Type);
434
435     addRpmTags(m);
436
437     PyModule_AddStringConstant(m, "__version__", RPMVERSION);
438
439     PyModule_AddObject(m, "header_magic",
440                 PyBytes_FromStringAndSize((const char *)rpm_header_magic, 8));
441
442 #define REGISTER_ENUM(val) PyModule_AddIntConstant(m, #val, val)
443
444     REGISTER_ENUM(RPMTAG_NOT_FOUND);
445
446     REGISTER_ENUM(RPMRC_OK);
447     REGISTER_ENUM(RPMRC_NOTFOUND);
448     REGISTER_ENUM(RPMRC_FAIL);
449     REGISTER_ENUM(RPMRC_NOTTRUSTED);
450     REGISTER_ENUM(RPMRC_NOKEY);
451
452     REGISTER_ENUM(RPMFILE_STATE_NORMAL);
453     REGISTER_ENUM(RPMFILE_STATE_REPLACED);
454     REGISTER_ENUM(RPMFILE_STATE_NOTINSTALLED);
455     REGISTER_ENUM(RPMFILE_STATE_NETSHARED);
456     REGISTER_ENUM(RPMFILE_STATE_WRONGCOLOR);
457
458     REGISTER_ENUM(RPMFILE_CONFIG);
459     REGISTER_ENUM(RPMFILE_DOC);
460     REGISTER_ENUM(RPMFILE_ICON);
461     REGISTER_ENUM(RPMFILE_MISSINGOK);
462     REGISTER_ENUM(RPMFILE_NOREPLACE);
463     REGISTER_ENUM(RPMFILE_SPECFILE);
464     REGISTER_ENUM(RPMFILE_GHOST);
465     REGISTER_ENUM(RPMFILE_LICENSE);
466     REGISTER_ENUM(RPMFILE_README);
467     REGISTER_ENUM(RPMFILE_PUBKEY);
468     REGISTER_ENUM(RPMFILE_ARTIFACT);
469
470     REGISTER_ENUM(RPMDEP_SENSE_REQUIRES);
471     REGISTER_ENUM(RPMDEP_SENSE_CONFLICTS);
472
473     REGISTER_ENUM(RPMSENSE_ANY);
474     REGISTER_ENUM(RPMSENSE_LESS);
475     REGISTER_ENUM(RPMSENSE_GREATER);
476     REGISTER_ENUM(RPMSENSE_EQUAL);
477     REGISTER_ENUM(RPMSENSE_POSTTRANS);
478     REGISTER_ENUM(RPMSENSE_PREREQ);
479     REGISTER_ENUM(RPMSENSE_PRETRANS);
480     REGISTER_ENUM(RPMSENSE_INTERP);
481     REGISTER_ENUM(RPMSENSE_SCRIPT_PRE);
482     REGISTER_ENUM(RPMSENSE_SCRIPT_POST);
483     REGISTER_ENUM(RPMSENSE_SCRIPT_PREUN);
484     REGISTER_ENUM(RPMSENSE_SCRIPT_POSTUN);
485     REGISTER_ENUM(RPMSENSE_SCRIPT_VERIFY);
486     REGISTER_ENUM(RPMSENSE_FIND_REQUIRES);
487     REGISTER_ENUM(RPMSENSE_FIND_PROVIDES);
488     REGISTER_ENUM(RPMSENSE_TRIGGERIN);
489     REGISTER_ENUM(RPMSENSE_TRIGGERUN);
490     REGISTER_ENUM(RPMSENSE_TRIGGERPOSTUN);
491     REGISTER_ENUM(RPMSENSE_RPMLIB);
492     REGISTER_ENUM(RPMSENSE_TRIGGERPREIN);
493     REGISTER_ENUM(RPMSENSE_KEYRING);
494     REGISTER_ENUM(RPMSENSE_STRONG);
495     REGISTER_ENUM(RPMSENSE_CONFIG);
496     REGISTER_ENUM(RPMSENSE_MISSINGOK);
497
498     REGISTER_ENUM(RPMTRANS_FLAG_TEST);
499     REGISTER_ENUM(RPMTRANS_FLAG_BUILD_PROBS);
500     REGISTER_ENUM(RPMTRANS_FLAG_NOSCRIPTS);
501     REGISTER_ENUM(RPMTRANS_FLAG_JUSTDB);
502     REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERS);
503     REGISTER_ENUM(RPMTRANS_FLAG_NODOCS);
504     REGISTER_ENUM(RPMTRANS_FLAG_ALLFILES);
505     REGISTER_ENUM(RPMTRANS_FLAG_NOPLUGINS);
506     REGISTER_ENUM(RPMTRANS_FLAG_KEEPOBSOLETE);
507     REGISTER_ENUM(RPMTRANS_FLAG_NOCONTEXTS);
508     REGISTER_ENUM(RPMTRANS_FLAG_NOCAPS);
509     REGISTER_ENUM(RPMTRANS_FLAG_REPACKAGE);
510     REGISTER_ENUM(RPMTRANS_FLAG_REVERSE);
511     REGISTER_ENUM(RPMTRANS_FLAG_NOPRE);
512     REGISTER_ENUM(RPMTRANS_FLAG_NOPOST);
513     REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERPREIN);
514     REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERIN);
515     REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERUN);
516     REGISTER_ENUM(RPMTRANS_FLAG_NOPREUN);
517     REGISTER_ENUM(RPMTRANS_FLAG_NOPOSTUN);
518     REGISTER_ENUM(RPMTRANS_FLAG_NOTRIGGERPOSTUN);
519     REGISTER_ENUM(RPMTRANS_FLAG_NOPRETRANS);
520     REGISTER_ENUM(RPMTRANS_FLAG_NOPOSTTRANS);
521     REGISTER_ENUM(RPMTRANS_FLAG_NOMD5);
522     REGISTER_ENUM(RPMTRANS_FLAG_NOFILEDIGEST);
523     REGISTER_ENUM(RPMTRANS_FLAG_NOSUGGEST);
524     REGISTER_ENUM(RPMTRANS_FLAG_ADDINDEPS);
525     REGISTER_ENUM(RPMTRANS_FLAG_NOCONFIGS);
526     REGISTER_ENUM(RPMTRANS_FLAG_DEPLOOPS);
527
528     REGISTER_ENUM(RPMPROB_FILTER_IGNOREOS);
529     REGISTER_ENUM(RPMPROB_FILTER_IGNOREARCH);
530     REGISTER_ENUM(RPMPROB_FILTER_REPLACEPKG);
531     REGISTER_ENUM(RPMPROB_FILTER_FORCERELOCATE);
532     REGISTER_ENUM(RPMPROB_FILTER_REPLACENEWFILES);
533     REGISTER_ENUM(RPMPROB_FILTER_REPLACEOLDFILES);
534     REGISTER_ENUM(RPMPROB_FILTER_OLDPACKAGE);
535     REGISTER_ENUM(RPMPROB_FILTER_DISKSPACE);
536     REGISTER_ENUM(RPMPROB_FILTER_DISKNODES);
537
538     REGISTER_ENUM(RPMCALLBACK_UNKNOWN);
539     REGISTER_ENUM(RPMCALLBACK_INST_PROGRESS);
540     REGISTER_ENUM(RPMCALLBACK_INST_START);
541     REGISTER_ENUM(RPMCALLBACK_INST_OPEN_FILE);
542     REGISTER_ENUM(RPMCALLBACK_INST_CLOSE_FILE);
543     REGISTER_ENUM(RPMCALLBACK_TRANS_PROGRESS);
544     REGISTER_ENUM(RPMCALLBACK_TRANS_START);
545     REGISTER_ENUM(RPMCALLBACK_TRANS_STOP);
546     REGISTER_ENUM(RPMCALLBACK_UNINST_PROGRESS);
547     REGISTER_ENUM(RPMCALLBACK_UNINST_START);
548     REGISTER_ENUM(RPMCALLBACK_UNINST_STOP);
549     REGISTER_ENUM(RPMCALLBACK_REPACKAGE_PROGRESS);
550     REGISTER_ENUM(RPMCALLBACK_REPACKAGE_START);
551     REGISTER_ENUM(RPMCALLBACK_REPACKAGE_STOP);
552     REGISTER_ENUM(RPMCALLBACK_UNPACK_ERROR);
553     REGISTER_ENUM(RPMCALLBACK_CPIO_ERROR);
554     REGISTER_ENUM(RPMCALLBACK_SCRIPT_ERROR);
555     REGISTER_ENUM(RPMCALLBACK_SCRIPT_START);
556     REGISTER_ENUM(RPMCALLBACK_SCRIPT_STOP);
557     REGISTER_ENUM(RPMCALLBACK_INST_STOP);
558     REGISTER_ENUM(RPMCALLBACK_ELEM_PROGRESS);
559
560     REGISTER_ENUM(RPMPROB_BADARCH);
561     REGISTER_ENUM(RPMPROB_BADOS);
562     REGISTER_ENUM(RPMPROB_PKG_INSTALLED);
563     REGISTER_ENUM(RPMPROB_BADRELOCATE);
564     REGISTER_ENUM(RPMPROB_REQUIRES);
565     REGISTER_ENUM(RPMPROB_CONFLICT);
566     REGISTER_ENUM(RPMPROB_NEW_FILE_CONFLICT);
567     REGISTER_ENUM(RPMPROB_FILE_CONFLICT);
568     REGISTER_ENUM(RPMPROB_OLDPACKAGE);
569     REGISTER_ENUM(RPMPROB_DISKSPACE);
570     REGISTER_ENUM(RPMPROB_DISKNODES);
571     REGISTER_ENUM(RPMPROB_OBSOLETES);
572
573     REGISTER_ENUM(VERIFY_DIGEST);
574     REGISTER_ENUM(VERIFY_SIGNATURE);
575
576     REGISTER_ENUM(RPMLOG_EMERG);
577     REGISTER_ENUM(RPMLOG_ALERT);
578     REGISTER_ENUM(RPMLOG_CRIT);
579     REGISTER_ENUM(RPMLOG_ERR);
580     REGISTER_ENUM(RPMLOG_WARNING);
581     REGISTER_ENUM(RPMLOG_NOTICE);
582     REGISTER_ENUM(RPMLOG_INFO);
583     REGISTER_ENUM(RPMLOG_DEBUG);
584
585     REGISTER_ENUM(RPMMIRE_DEFAULT);
586     REGISTER_ENUM(RPMMIRE_STRCMP);
587     REGISTER_ENUM(RPMMIRE_REGEX);
588     REGISTER_ENUM(RPMMIRE_GLOB);
589
590     REGISTER_ENUM(RPMVSF_DEFAULT);
591     REGISTER_ENUM(RPMVSF_NOHDRCHK);
592     REGISTER_ENUM(RPMVSF_NEEDPAYLOAD);
593     REGISTER_ENUM(RPMVSF_NOSHA1HEADER);
594     REGISTER_ENUM(RPMVSF_NOSHA256HEADER);
595     REGISTER_ENUM(RPMVSF_NODSAHEADER);
596     REGISTER_ENUM(RPMVSF_NORSAHEADER);
597     REGISTER_ENUM(RPMVSF_NOPAYLOAD);
598     REGISTER_ENUM(RPMVSF_NOMD5);
599     REGISTER_ENUM(RPMVSF_NODSA);
600     REGISTER_ENUM(RPMVSF_NORSA);
601     REGISTER_ENUM(_RPMVSF_NODIGESTS);
602     REGISTER_ENUM(_RPMVSF_NOSIGNATURES);
603     REGISTER_ENUM(_RPMVSF_NOHEADER);
604     REGISTER_ENUM(_RPMVSF_NOPAYLOAD);
605
606     REGISTER_ENUM(TR_ADDED);
607     REGISTER_ENUM(TR_REMOVED);
608
609     REGISTER_ENUM(RPMDBI_PACKAGES);
610     REGISTER_ENUM(RPMDBI_LABEL);
611     REGISTER_ENUM(RPMDBI_INSTFILENAMES);
612     REGISTER_ENUM(RPMDBI_NAME);
613     REGISTER_ENUM(RPMDBI_BASENAMES);
614     REGISTER_ENUM(RPMDBI_GROUP);
615     REGISTER_ENUM(RPMDBI_REQUIRENAME);
616     REGISTER_ENUM(RPMDBI_PROVIDENAME);
617     REGISTER_ENUM(RPMDBI_CONFLICTNAME);
618     REGISTER_ENUM(RPMDBI_OBSOLETENAME);
619     REGISTER_ENUM(RPMDBI_TRIGGERNAME);
620     REGISTER_ENUM(RPMDBI_DIRNAMES);
621     REGISTER_ENUM(RPMDBI_INSTALLTID);
622     REGISTER_ENUM(RPMDBI_SIGMD5);
623     REGISTER_ENUM(RPMDBI_SHA1HEADER);
624
625     REGISTER_ENUM(HEADERCONV_EXPANDFILELIST);
626     REGISTER_ENUM(HEADERCONV_COMPRESSFILELIST);
627     REGISTER_ENUM(HEADERCONV_RETROFIT_V3);
628
629     REGISTER_ENUM(RPMVERIFY_NONE);
630     REGISTER_ENUM(RPMVERIFY_FILEDIGEST);
631     REGISTER_ENUM(RPMVERIFY_FILESIZE);
632     REGISTER_ENUM(RPMVERIFY_LINKTO);
633     REGISTER_ENUM(RPMVERIFY_USER);
634     REGISTER_ENUM(RPMVERIFY_GROUP);
635     REGISTER_ENUM(RPMVERIFY_MTIME);
636     REGISTER_ENUM(RPMVERIFY_MODE);
637     REGISTER_ENUM(RPMVERIFY_RDEV);
638     REGISTER_ENUM(RPMVERIFY_CAPS);
639     REGISTER_ENUM(RPMVERIFY_READLINKFAIL);
640     REGISTER_ENUM(RPMVERIFY_READFAIL);
641     REGISTER_ENUM(RPMVERIFY_LSTATFAIL);
642
643     REGISTER_ENUM(RPMBUILD_ISSOURCE);
644     REGISTER_ENUM(RPMBUILD_ISPATCH);
645     REGISTER_ENUM(RPMBUILD_ISICON);
646     REGISTER_ENUM(RPMBUILD_ISNO);
647
648     REGISTER_ENUM(RPMBUILD_NONE);
649     REGISTER_ENUM(RPMBUILD_PREP);
650     REGISTER_ENUM(RPMBUILD_BUILD);
651     REGISTER_ENUM(RPMBUILD_INSTALL);
652     REGISTER_ENUM(RPMBUILD_CHECK);
653     REGISTER_ENUM(RPMBUILD_CLEAN);
654     REGISTER_ENUM(RPMBUILD_FILECHECK);
655     REGISTER_ENUM(RPMBUILD_PACKAGESOURCE);
656     REGISTER_ENUM(RPMBUILD_PACKAGEBINARY);
657     REGISTER_ENUM(RPMBUILD_RMSOURCE);
658     REGISTER_ENUM(RPMBUILD_RMBUILD);
659     REGISTER_ENUM(RPMBUILD_RMSPEC);
660
661     REGISTER_ENUM(RPMBUILD_PKG_NONE);
662     REGISTER_ENUM(RPMBUILD_PKG_NODIRTOKENS);
663
664     REGISTER_ENUM(RPMSPEC_NONE);
665     REGISTER_ENUM(RPMSPEC_ANYARCH);
666     REGISTER_ENUM(RPMSPEC_FORCE);
667     REGISTER_ENUM(RPMSPEC_NOLANG);
668
669     return 1;
670 }
671