rpm  5.4.15
rpmts-py.c
Go to the documentation of this file.
1 
5 #include "system-py.h"
6 
7 #include <rpmio_internal.h> /* XXX for fdSetOpen */
8 #include <rpmcb.h>
9 
10 #define _RPMPS_INTERNAL /* XXX almost (but not quite) opaque. */
11 #include <rpmpgp.h>
12 
13 #include <rpmtypes.h>
14 #include <rpmtag.h>
15 #include <pkgio.h> /* XXX headerCheck() */
16 #include <rpmdb.h>
17 
18 #define _RPMTS_INTERNAL /* XXX expose rpmtsSetScriptFd */
19 #include <rpmbuild.h>
20 
21 #include <rpmcli.h>
22 #define _RPMROLLBACK_INTERNAL /* XXX IDTX et al */
23 #include <rpmrollback.h>
24 
25 #include "header-py.h"
26 #include "rpmds-py.h" /* XXX for rpmdsNew */
27 #include "rpmfi-py.h" /* XXX for rpmfiNew */
28 #include "rpmmi-py.h"
29 #include "rpmps-py.h"
30 #include "rpmte-py.h"
31 #include "spec-py.h"
32 
33 #include "rpmts-py.h"
34 
35 #include "debug.h"
36 
37 #define rpmtsfree() rpmioFreePoolItem()
38 
39 /*@unchecked@*/
40 /*@-shadow@*/
41 extern int _rpmts_debug;
42 /*@=shadow@*/
43 
44 /*@access alKey @*/
45 /*@access FD_t @*/
46 /*@access Header @*/
47 /*@access rpmal @*/
48 /*@access rpmdb @*/
49 /*@access rpmds @*/
50 /*@access rpmts @*/
51 /*@access rpmtsi @*/
52 
173  PyObject * cb;
174  PyObject * data;
177  PyThreadState *_save;
178 };
179 
182 /*@exits@*/
183 static void rpmts_Die(PyObject *cb)
184  /*@*/
185 {
186  PyObject * r = PyObject_Repr(cb);
187  char *pyfn = (r != NULL ? PyString_AsString(r) : "???");
188 
189  if (PyErr_Occurred())
190  PyErr_Print();
191  rpmlog(RPMLOG_ERR, _("python callback %s failed, aborting!\n"), pyfn);
193  exit(EXIT_FAILURE);
194 }
195 
198 static int
200  /*@*/
201 {
202  struct rpmtsCallbackType_s * cbInfo = (struct rpmtsCallbackType_s *) data;
203  PyObject * args, * result;
204  int res = 1;
205 
206 if (_rpmts_debug)
207 fprintf(stderr, "*** rpmts_SolveCallback(%p,%p,%p) \"%s\"\n", ts, ds, data, rpmdsDNEVR(ds));
208 
209  if (cbInfo->tso == NULL) return res;
210  if (cbInfo->cb == Py_None) return res;
211 
212  PyEval_RestoreThread(cbInfo->_save);
213 
214  cbInfo->dso = rpmds_Wrap(ds); /* XXX perhaps persistent? */
215  args = Py_BuildValue("(OO)", cbInfo->tso, cbInfo->dso);
216  result = PyEval_CallObject(cbInfo->cb, args);
217  Py_XDECREF(cbInfo->dso);
218  cbInfo->dso = NULL;
219  Py_XDECREF(args);
220 
221  if (!result) {
222  rpmts_Die(cbInfo->cb);
223  /*@notreached@*/
224  } else {
225  if (PyInt_Check(result))
226  res = PyInt_AsLong(result);
227  Py_XDECREF(result);
228  }
229 
230  cbInfo->_save = PyEval_SaveThread();
231 
232  return res;
233 }
234 
237 /*@null@*/
238 static void *
239 rpmtsCallback(/*@unused@*/ const void * hd, const rpmCallbackType what,
240  const rpmuint64_t amount, const rpmuint64_t total,
241  fnpyKey pkgKey, rpmCallbackData data)
242  /*@globals _Py_NoneStruct @*/
243  /*@modifies _Py_NoneStruct @*/
244 {
245 /*@-castexpose@*/
246  Header h = (Header) hd;
247 /*@=castexpose@*/
248  struct rpmtsCallbackType_s * cbInfo = data;
249  PyObject * pkgObj = (PyObject *) pkgKey;
250  PyObject * oh = NULL;
251  const char * origin = NULL;
252  PyObject * args, * result;
253  static FD_t fd;
254 
255  if (cbInfo->cb == Py_None) return NULL;
256 
257  /* Synthesize a python object for callback (if necessary). */
258  if (pkgObj == NULL) {
259  if (h) {
260  HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
261  he->tag = RPMTAG_NAME;
262  if (headerGet(h, he, 0)) {
263  pkgObj = Py_BuildValue("s", he->p.str);
264  he->p.ptr = _free(he->p.ptr);
265  } else {
266  pkgObj = Py_None;
267  Py_INCREF(pkgObj);
268  }
269  } else {
270  pkgObj = Py_None;
271  Py_INCREF(pkgObj);
272  }
273  } else {
274  Py_INCREF(pkgObj);
275  /* XXX yum has (h, rpmloc) tuple as pkgKey. Extract the path. */
276  if (!(PyTuple_Check(pkgObj) && PyArg_ParseTuple(pkgObj, "|Os", &oh, &origin)))
277  origin = NULL;
278  /* XXX clean up the path, yum paths start "//..." */
279  if (origin && origin[0] == '/' && origin[1] == '/')
280  origin++;
281  }
282 
283  PyEval_RestoreThread(cbInfo->_save);
284 
285  args = Py_BuildValue("(iLLOO)", what, amount, total, pkgObj, cbInfo->data);
286  result = PyEval_CallObject(cbInfo->cb, args);
287  Py_XDECREF(args);
288  Py_XDECREF(pkgObj);
289 
290  if (!result) {
291  rpmts_Die(cbInfo->cb);
292  /*@notreached@*/
293  }
294 
295  if (what == RPMCALLBACK_INST_OPEN_FILE) {
296  int fdno;
297 
298  if (!PyArg_Parse(result, "i", &fdno)) {
299  rpmts_Die(cbInfo->cb);
300  /*@notreached@*/
301  }
302  Py_XDECREF(result);
303  cbInfo->_save = PyEval_SaveThread();
304 
305  fd = fdDup(fdno);
306 if (_rpmts_debug)
307 fprintf(stderr, "\t%p = fdDup(%d)\n", fd, fdno);
308 
309  fcntl(Fileno(fd), F_SETFD, FD_CLOEXEC);
310 
311  if (origin != NULL)
312  (void) fdSetOpen(fd, origin, 0, 0);
313 
314  return fd;
315  } else
316  if (what == RPMCALLBACK_INST_CLOSE_FILE) {
317 if (_rpmts_debug)
318 fprintf(stderr, "\tFclose(%p)\n", fd);
319  Fclose (fd);
320  } else {
321 if (_rpmts_debug)
322 fprintf(stderr, "\t%llu:%llu key %p\n", (unsigned long long)amount, (unsigned long long)total, pkgKey);
323  }
324 
325  Py_XDECREF(result);
326  cbInfo->_save = PyEval_SaveThread();
327 
328  return NULL;
329 }
330 
331 #if Py_TPFLAGS_HAVE_ITER
332 
334 static PyObject *
336  /*@*/
337 {
338 if (_rpmts_debug)
339 fprintf(stderr, "*** rpmts_iter(%p) ts %p\n", s, s->ts);
340 
341  Py_INCREF(s);
342  return (PyObject *)s;
343 }
344 #endif
345 
349 /*@null@*/
350 static PyObject *
352  /*@modifies s @*/
353 {
354  PyObject * result = NULL;
355  rpmte te;
356 
357 if (_rpmts_debug)
358 fprintf(stderr, "*** rpmts_iternext(%p) ts %p tsi %p %d\n", s, s->ts, s->tsi, s->tsiFilter);
359 
360  /* Reset iterator on 1st entry. */
361  if (s->tsi == NULL) {
362  s->tsi = rpmtsiInit(s->ts);
363  if (s->tsi == NULL)
364  return NULL;
365  s->tsiFilter = 0;
366  }
367 
368  te = rpmtsiNext(s->tsi, s->tsiFilter);
369 /*@-branchstate@*/
370  if (te != NULL) {
371  result = (PyObject *) rpmte_Wrap(te);
372  } else {
373  s->tsi = rpmtsiFree(s->tsi);
374  s->tsiFilter = 0;
375  }
376 /*@=branchstate@*/
377 
378  return result;
379 }
380 
385 
388 /*@null@*/
389 static PyObject *
390 rpmts_Debug(/*@unused@*/ rpmtsObject * s, PyObject * args, PyObject * kwds)
391  /*@globals _Py_NoneStruct @*/
392  /*@modifies _Py_NoneStruct @*/
393 {
394  char * kwlist[] = {"debugLevel", NULL};
395 
396  if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Debug", kwlist,
397  &_rpmts_debug))
398  return NULL;
399 
400 if (_rpmts_debug < 0)
401 fprintf(stderr, "*** rpmts_Debug(%p) ts %p\n", s, s->ts);
402 
403  Py_RETURN_NONE;
404 }
405 
408 /*@null@*/
409 static PyObject *
410 rpmts_AddInstall(rpmtsObject * s, PyObject * args, PyObject * kwds)
411  /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
412  /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
413 {
414  hdrObject * h;
415  PyObject * key;
416  char * how = "u"; /* XXX default to upgrade element if missing */
417  int isUpgrade = 0;
418  char * kwlist[] = {"header", "key", "how", NULL};
419 
420  if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O|s:AddInstall", kwlist,
421  &hdr_Type, &h, &key, &how))
422  return NULL;
423 
424  { PyObject * hObj = (PyObject *) h;
425  if (hObj->ob_type != &hdr_Type) {
426  PyErr_SetString(PyExc_TypeError, "bad type for header argument");
427  return NULL;
428  }
429  }
430 
431 if (_rpmts_debug < 0 || (_rpmts_debug > 0 && *how != 'a'))
432 fprintf(stderr, "*** rpmts_AddInstall(%p,%p,%p,%s) ts %p\n", s, h, key, how, s->ts);
433 
434  if (how && strcmp(how, "a") && strcmp(how, "u") && strcmp(how, "i")) {
435  PyErr_SetString(PyExc_TypeError, "how argument must be \"u\", \"a\", or \"i\"");
436  return NULL;
437  } else if (how && !strcmp(how, "u"))
438  isUpgrade = 1;
439 
440  rpmtsAddInstallElement(s->ts, hdrGetHeader(h), key, isUpgrade, NULL);
441 
442  /* This should increment the usage count for me */
443  if (key)
444  PyList_Append(s->keyList, key);
445 
446  Py_RETURN_NONE;
447 }
448 
452 /*@null@*/
453 static PyObject *
454 rpmts_AddErase(rpmtsObject * s, PyObject * args, PyObject * kwds)
455  /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
456  /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
457 {
458  PyObject * o;
459  int count;
460  rpmmi mi;
461  char * kwlist[] = {"name", NULL};
462 
463 if (_rpmts_debug)
464 fprintf(stderr, "*** rpmts_AddErase(%p) ts %p\n", s, s->ts);
465 
466  if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:AddErase", kwlist, &o))
467  return NULL;
468 
469  if (PyString_Check(o) || PyUnicode_Check(o)) {
470  char * name = PyString_AsString(o);
471 
472  mi = rpmtsInitIterator(s->ts, RPMTAG_NVRA, name, 0);
473  count = rpmmiCount(mi);
474  if (count <= 0) {
475  mi = rpmmiFree(mi);
476  PyErr_SetString(pyrpmError, "package not installed");
477  return NULL;
478  } else { /* XXX: Note that we automatically choose to remove all matches */
479  Header h;
480  while ((h = rpmmiNext(mi)) != NULL) {
481  uint32_t hdrNum = rpmmiInstance(mi);
482  if (hdrNum)
483  rpmtsAddEraseElement(s->ts, h, hdrNum);
484  }
485  }
486  mi = rpmmiFree(mi);
487  } else
488  if (PyInt_Check(o)) {
489  uint32_t instance = PyInt_AsLong(o);
490 
491  mi = rpmtsInitIterator(s->ts, RPMDBI_PACKAGES, &instance, sizeof(instance));
492  if (instance == 0 || mi == NULL) {
493  mi = rpmmiFree(mi);
494  PyErr_SetString(pyrpmError, "package not installed");
495  return NULL;
496  } else {
497  Header h;
498  while ((h = rpmmiNext(mi)) != NULL) {
499  uint32_t hdrNum = rpmmiInstance(mi);
500  if (hdrNum)
501  rpmtsAddEraseElement(s->ts, h, hdrNum);
502  break;
503  }
504  }
505  mi = rpmmiFree(mi);
506  }
507 
508  Py_RETURN_NONE;
509 }
510 
513 /*@null@*/
514 static PyObject *
515 rpmts_Check(rpmtsObject * s, PyObject * args, PyObject * kwds)
516  /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
517  /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
518 {
519  rpmps ps;
520  rpmProblem p;
521  PyObject * list, * cf;
522  struct rpmtsCallbackType_s cbInfo;
523  int i;
524  int xx;
525  char * kwlist[] = {"callback", NULL};
526 
527  memset(&cbInfo, 0, sizeof(cbInfo));
528  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:Check", kwlist,
529  &cbInfo.cb))
530  return NULL;
531 
532  if (cbInfo.cb != NULL) {
533  if (!PyCallable_Check(cbInfo.cb)) {
534  PyErr_SetString(PyExc_TypeError, "expected a callable");
535  return NULL;
536  }
537  xx = rpmtsSetSolveCallback(s->ts, rpmts_SolveCallback, (void *)&cbInfo);
538  }
539 
540 if (_rpmts_debug)
541 fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb);
542 
543  cbInfo.tso = s;
544  cbInfo.dso = NULL; /* XXX perhaps persistent? */
545  cbInfo._save = PyEval_SaveThread();
546 
547  xx = rpmtsCheck(s->ts);
548  ps = rpmtsProblems(s->ts);
549 
550  if (cbInfo.cb)
551  xx = rpmtsSetSolveCallback(s->ts, rpmtsSolve, NULL);
552 
553  PyEval_RestoreThread(cbInfo._save);
554 
555  if (ps != NULL) {
556  list = PyList_New(0);
557  if (!list) {
558  return NULL;
559  }
560 
561  rpmpsi psi = rpmpsInitIterator(ps);
562 
563  while ((i = rpmpsNextIterator(psi)) >= 0) {
564 #ifdef DYING
565  cf = Py_BuildValue("((sss)(ss)iOi)", conflicts[i].byName,
566  conflicts[i].byVersion, conflicts[i].byRelease,
567 
568  conflicts[i].needsName,
569  conflicts[i].needsVersion,
570 
571  conflicts[i].needsFlags,
572  conflicts[i].suggestedPkgs ?
573  conflicts[i].suggestedPkgs[0] : Py_None,
574  conflicts[i].sense);
575 #else
576  char * byName, * byVersion, * byRelease, *byArch;
577  char * needsName, * needsOP, * needsVersion;
578  char * a, * b;
579  int needsFlags, sense;
580  fnpyKey key;
581 
582  p = rpmpsProblem(psi);
583 
584  /* XXX autorelocated i386 on ia64, fix system-config-packages! */
586  continue;
587 
588  a = byName = xstrdup(rpmProblemGetPkgNEVR(p));
589  if ((byArch= strrchr(byName, '.')) != NULL)
590  *byArch++ = '\0';
591  if ((byRelease = strrchr(byName, '-')) != NULL)
592  *byRelease++ = '\0';
593  if ((byVersion = strrchr(byName, '-')) != NULL)
594  *byVersion++ = '\0';
595 
596  key = rpmProblemKey(p);
597 
598  b = needsName = xstrdup(rpmProblemGetAltNEVR(p));
599  if (needsName[1] == ' ') {
600  sense = (needsName[0] == 'C')
602  needsName += 2;
603  } else
604  sense = RPMDEP_SENSE_REQUIRES;
605  if ((needsVersion = strrchr(needsName, ' ')) != NULL)
606  *needsVersion++ = '\0';
607 
608  needsFlags = 0;
609  if ((needsOP = strrchr(needsName, ' ')) != NULL) {
610  for (*needsOP++ = '\0'; *needsOP != '\0'; needsOP++) {
611  if (*needsOP == '<') needsFlags |= RPMSENSE_LESS;
612  else if (*needsOP == '>') needsFlags |= RPMSENSE_GREATER;
613  else if (*needsOP == '=') needsFlags |= RPMSENSE_EQUAL;
614  }
615  }
616 
617  cf = Py_BuildValue("((sss)(ss)iOi)", byName, byVersion, byRelease,
618  needsName, needsVersion, needsFlags,
619  (key != NULL ? key : Py_None),
620  sense);
621  a = _free(a);
622  b = _free(b);
623 #endif
624  PyList_Append(list, (PyObject *) cf);
625  Py_XDECREF(cf);
626  }
627 
628  psi = rpmpsFreeIterator(psi);
629  ps = rpmpsFree(ps);
630 
631  return list;
632  }
633 
634  Py_RETURN_NONE;
635 }
636 
639 /*@null@*/
640 static PyObject *
642  /*@globals rpmGlobalMacroContext @*/
643  /*@modifies s, rpmGlobalMacroContext @*/
644 {
645  int rc;
646 
647 if (_rpmts_debug)
648 fprintf(stderr, "*** rpmts_Order(%p) ts %p\n", s, s->ts);
649 
650  Py_BEGIN_ALLOW_THREADS
651  rc = rpmtsOrder(s->ts);
652  Py_END_ALLOW_THREADS
653 
654  return Py_BuildValue("i", rc);
655 }
656 
659 /*@null@*/
660 static PyObject *
662  /*@globals _Py_NoneStruct @*/
663  /*@modifies s, _Py_NoneStruct @*/
664 {
665 if (_rpmts_debug)
666 fprintf(stderr, "*** rpmts_Clean(%p) ts %p\n", s, s->ts);
667 
668  rpmtsClean(s->ts);
669 
670  Py_RETURN_NONE;
671 }
672 
675 /*@null@*/
676 static PyObject *
677 rpmts_IDTXload(rpmtsObject * s, PyObject * args, PyObject * kwds)
678  /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
679  /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
680 {
681  PyObject * result = NULL;
683  char * kwlist[] = {"rbtid", NULL};
684  uint32_t rbtid = 0;
685  IDTX idtx;
686 
687 if (_rpmts_debug)
688 fprintf(stderr, "*** rpmts_IDTXload(%p) ts %p\n", s, s->ts);
689 
690  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:IDTXload", kwlist, &rbtid))
691  return NULL;
692 
693  Py_BEGIN_ALLOW_THREADS
694  idtx = IDTXload(s->ts, tag, rbtid);
695  Py_END_ALLOW_THREADS
696 
697 /*@-branchstate@*/
698  if (idtx == NULL || idtx->nidt <= 0) {
699  Py_INCREF(Py_None);
700  result = Py_None;
701  } else {
702  PyObject * tuple;
703  PyObject * ho;
704  IDT idt;
705  int i;
706 
707  result = PyTuple_New(idtx->nidt);
708  for (i = 0; i < idtx->nidt; i++) {
709  idt = idtx->idt + i;
710  ho = (PyObject *) hdr_Wrap(idt->h);
711  tuple = Py_BuildValue("(iOi)", idt->val.u32, ho, idt->instance);
712  PyTuple_SET_ITEM(result, i, tuple);
713  Py_XDECREF(ho);
714  }
715  }
716 /*@=branchstate@*/
717 
718  idtx = IDTXfree(idtx);
719 
720  return result;
721 }
722 
725 /*@null@*/
726 static PyObject *
727 rpmts_IDTXglob(rpmtsObject * s, PyObject * args, PyObject * kwds)
728  /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
729  /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
730 {
731  PyObject * result = NULL;
732  const char * globstr;
733  rpmTag tag = RPMTAG_REMOVETID;
734  char * kwlist[] = {"rbtid", NULL};
735  uint32_t rbtid = 0;
736  IDTX idtx;
737 
738 if (_rpmts_debug)
739 fprintf(stderr, "*** rpmts_IDTXglob(%p) ts %p\n", s, s->ts);
740 
741  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:IDTXglob", kwlist, &rbtid))
742  return NULL;
743 
744  Py_BEGIN_ALLOW_THREADS
745  globstr = rpmExpand("%{_repackage_dir}/*.rpm", NULL);
746  idtx = IDTXglob(s->ts, globstr, tag, rbtid);
747  globstr = _free(globstr);
748  Py_END_ALLOW_THREADS
749 
750 /*@-branchstate@*/
751  if (idtx == NULL || idtx->nidt <= 0) {
752  Py_INCREF(Py_None);
753  result = Py_None;
754  } else {
755  PyObject * tuple;
756  PyObject * ho;
757  IDT idt;
758  int i;
759 
760  result = PyTuple_New(idtx->nidt);
761  for (i = 0; i < idtx->nidt; i++) {
762  idt = idtx->idt + i;
763  ho = (PyObject *) hdr_Wrap(idt->h);
764  tuple = Py_BuildValue("(iOs)", idt->val.u32, ho, idt->key);
765  PyTuple_SET_ITEM(result, i, tuple);
766  Py_XDECREF(ho);
767  }
768  }
769 /*@=branchstate@*/
770 
771  idtx = IDTXfree(idtx);
772 
773  return result;
774 }
775 
778 /*@null@*/
779 static PyObject *
780 rpmts_Rollback(rpmtsObject * s, PyObject * args, PyObject * kwds)
781  /*@globals rpmGlobalMacroContext @*/
782  /*@modifies s, rpmGlobalMacroContext @*/
783 {
784  QVA_t ia = memset(alloca(sizeof(*ia)), 0, sizeof(*ia));
785  rpmtransFlags transFlags;
786  const char ** av = NULL;
787  uint32_t rbtid;
788  int rc;
789  char * kwlist[] = {"transactionId", NULL};
790 
791 if (_rpmts_debug)
792 fprintf(stderr, "*** rpmts_Rollback(%p) ts %p\n", s, s->ts);
793 
794  if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Rollback", kwlist, &rbtid))
795  return NULL;
796 
797  Py_BEGIN_ALLOW_THREADS
802  ia->rbtid = rbtid;
803  ia->relocations = NULL;
805 
806  transFlags = rpmtsSetFlags(s->ts, ia->transFlags);
807  rc = rpmRollback(s->ts, ia, av);
808  transFlags = rpmtsSetFlags(s->ts, transFlags);
809  Py_END_ALLOW_THREADS
810 
811  return Py_BuildValue("i", rc);
812 }
813 
816 /*@null@*/
817 static PyObject *
819  /*@globals rpmGlobalMacroContext @*/
820  /*@modifies s, rpmGlobalMacroContext @*/
821 {
822 
823 if (_rpmts_debug)
824 fprintf(stderr, "*** rpmts_OpenDB(%p) ts %p\n", s, s->ts);
825 
826  if (rpmtsDBMode(s->ts) == -1)
827  (void) rpmtsSetDBMode(s->ts, O_RDONLY);
828 
829  return Py_BuildValue("i", rpmtsOpenDB(s->ts, rpmtsDBMode(s->ts)));
830 }
831 
834 /*@null@*/
835 static PyObject *
837  /*@modifies s @*/
838 {
839  int rc;
840 
841 if (_rpmts_debug)
842 fprintf(stderr, "*** rpmts_CloseDB(%p) ts %p\n", s, s->ts);
843 
844  rc = rpmtsCloseDB(s->ts);
845  (void) rpmtsSetDBMode(s->ts, -1); /* XXX disable lazy opens */
846 
847  return Py_BuildValue("i", rc);
848 }
849 
852 /*@null@*/
853 static PyObject *
855  /*@globals rpmGlobalMacroContext @*/
856  /*@modifies s, rpmGlobalMacroContext @*/
857 {
858  int rc;
859 
860 if (_rpmts_debug)
861 fprintf(stderr, "*** rpmts_InitDB(%p) ts %p\n", s, s->ts);
862 
863  rc = rpmtsInitDB(s->ts, O_RDONLY);
864  if (rc == 0)
865  rc = rpmtsCloseDB(s->ts);
866 
867  return Py_BuildValue("i", rc);
868 }
869 
872 /*@null@*/
873 static PyObject *
875  /*@globals rpmGlobalMacroContext @*/
876  /*@modifies s, rpmGlobalMacroContext @*/
877 {
878  int rc;
879 
880 if (_rpmts_debug)
881 fprintf(stderr, "*** rpmts_RebuildDB(%p) ts %p\n", s, s->ts);
882 
883  Py_BEGIN_ALLOW_THREADS
884  rc = rpmtsRebuildDB(s->ts);
885  Py_END_ALLOW_THREADS
886 
887  return Py_BuildValue("i", rc);
888 }
889 
892 /*@null@*/
893 static PyObject *
895  /*@globals rpmGlobalMacroContext @*/
896  /*@modifies s, rpmGlobalMacroContext @*/
897 {
898  int rc;
899 
900 if (_rpmts_debug)
901 fprintf(stderr, "*** rpmts_VerifyDB(%p) ts %p\n", s, s->ts);
902 
903  Py_BEGIN_ALLOW_THREADS
904  rc = rpmtsVerifyDB(s->ts);
905  Py_END_ALLOW_THREADS
906 
907  return Py_BuildValue("i", rc);
908 }
909 
912 /*@null@*/
913 static PyObject *
914 rpmts_HdrFromFdno(rpmtsObject * s, PyObject * args, PyObject * kwds)
915  /*@globals rpmGlobalMacroContext, fileSystem @*/
916  /*@modifies s, rpmGlobalMacroContext, fileSystem @*/
917 {
918  PyObject * result = NULL;
919  Header h;
920  FD_t fd;
921  int fdno;
922  rpmRC rpmrc;
923  char * kwlist[] = {"fd", NULL};
924 
925  if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:HdrFromFdno", kwlist,
926  &fdno))
927  return NULL;
928 
929  fd = fdDup(fdno);
930  rpmrc = rpmReadPackageFile(s->ts, fd, "rpmts_HdrFromFdno", &h);
931  Fclose(fd);
932 
933 if (_rpmts_debug)
934 fprintf(stderr, "*** rpmts_HdrFromFdno(%p) ts %p rc %d\n", s, s->ts, rpmrc);
935 
936 /*@-branchstate@*/
937  switch (rpmrc) {
938  case RPMRC_OK:
939  if (h)
940  result = Py_BuildValue("N", hdr_Wrap(h));
941  (void)headerFree(h); /* XXX ref held by result */
942  h = NULL;
943  break;
944 
945  case RPMRC_NOKEY:
946  PyErr_SetString(pyrpmError, "public key not available");
947  break;
948 
949  case RPMRC_NOTTRUSTED:
950  PyErr_SetString(pyrpmError, "public key not trusted");
951  break;
952 
953  case RPMRC_NOTFOUND:
954  case RPMRC_FAIL:
955  default:
956  PyErr_SetString(pyrpmError, "error reading package header");
957  break;
958  }
959 /*@=branchstate@*/
960 
961  return result;
962 }
963 
966 /*@null@*/
967 static PyObject *
968 rpmts_HdrCheck(rpmtsObject * s, PyObject * args, PyObject * kwds)
969  /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
970  /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
971 {
972  PyObject * blob;
973  PyObject * result = NULL;
974  const char * msg = NULL;
975  const void * uh;
976  int uc;
977  pgpDig dig;
978  rpmRC rpmrc;
979  char * kwlist[] = {"headers", NULL};
980 
981 if (_rpmts_debug)
982 fprintf(stderr, "*** rpmts_HdrCheck(%p) ts %p\n", s, s->ts);
983 
984  if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:HdrCheck", kwlist, &blob))
985  return NULL;
986 
987  if (blob == Py_None) {
988  Py_RETURN_NONE;
989  }
990  if (!(PyString_Check(blob) || PyUnicode_Check(blob))) {
991  PyErr_SetString(pyrpmError, "hdrCheck takes a string of octets");
992  return result;
993  }
994  uh = PyString_AsString(blob);
995  uc = PyString_Size(blob);
996 
997  dig = pgpDigNew(rpmtsVSFlags(s->ts), 0);
998  rpmrc = headerCheck(dig, uh, uc, &msg);
999  dig = pgpDigFree(dig);
1000 
1001  switch (rpmrc) {
1002  case RPMRC_OK:
1003  Py_INCREF(Py_None);
1004  result = Py_None;
1005  break;
1006 
1007  case RPMRC_NOKEY:
1008  /* XXX note "availaiable", the script kiddies need the misspelling. */
1009  PyErr_SetString(pyrpmError, "public key not availaiable");
1010  break;
1011 
1012  case RPMRC_NOTTRUSTED:
1013  PyErr_SetString(pyrpmError, "public key not trusted");
1014  break;
1015 
1016  case RPMRC_FAIL:
1017  default:
1018  PyErr_SetString(pyrpmError, msg);
1019  break;
1020  }
1021  msg = _free(msg);
1022 
1023  return result;
1024 }
1025 
1028 static PyObject *
1030 {
1031  return Py_BuildValue("i", rpmtsVSFlags(s->ts));
1032 }
1033 
1036 /*@null@*/
1037 static PyObject *
1038 rpmts_SetVSFlags(rpmtsObject * s, PyObject * args, PyObject * kwds)
1039  /*@modifies s @*/
1040 {
1042  char * kwlist[] = {"flags", NULL};
1043 
1044 if (_rpmts_debug)
1045 fprintf(stderr, "*** rpmts_SetVSFlags(%p) ts %p\n", s, s->ts);
1046 
1047  if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:SetVSFlags", kwlist,
1048  &vsflags))
1049  return NULL;
1050 
1051  /* XXX FIXME: value check on vsflags, or build pure python object
1052  * for it, and require an object of that type */
1053 
1054  return Py_BuildValue("i", rpmtsSetVSFlags(s->ts, vsflags));
1055 }
1056 
1059 /*@null@*/
1060 static PyObject *
1061 rpmts_SetColor(rpmtsObject * s, PyObject * args, PyObject * kwds)
1062  /*@modifies s @*/
1063 {
1064  uint32_t tscolor;
1065  char * kwlist[] = {"color", NULL};
1066 
1067 if (_rpmts_debug)
1068 fprintf(stderr, "*** rpmts_SetColor(%p) ts %p\n", s, s->ts);
1069 
1070  if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:Color", kwlist, &tscolor))
1071  return NULL;
1072 
1073  /* XXX FIXME: value check on tscolor, or build pure python object
1074  * for it, and require an object of that type */
1075 
1076  return Py_BuildValue("i", rpmtsSetColor(s->ts, tscolor));
1077 }
1078 
1081 /*@null@*/
1082 static PyObject *
1083 rpmts_PgpPrtPkts(rpmtsObject * s, PyObject * args, PyObject * kwds)
1084  /*@globals _Py_NoneStruct @*/
1085  /*@modifies _Py_NoneStruct @*/
1086 {
1087  PyObject * blob;
1088  unsigned char * pkt;
1089  unsigned int pktlen;
1090  int rc;
1091  char * kwlist[] = {"octets", NULL};
1092 
1093 if (_rpmts_debug)
1094 fprintf(stderr, "*** rpmts_PgpPrtPkts(%p) ts %p\n", s, s->ts);
1095 
1096  if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:PgpPrtPkts", kwlist, &blob))
1097  return NULL;
1098 
1099  if (blob == Py_None) {
1100  Py_RETURN_NONE;
1101  }
1102  if (!(PyString_Check(blob) || PyUnicode_Check(blob))) {
1103  PyErr_SetString(pyrpmError, "pgpPrtPkts takes a string of octets");
1104  return NULL;
1105  }
1106  pkt = (unsigned char *) PyString_AsString(blob);
1107  pktlen = PyString_Size(blob);
1108 
1109  rc = pgpPrtPkts(pkt, pktlen, NULL, 1);
1110 
1111  return Py_BuildValue("i", rc);
1112 }
1113 
1116 /*@null@*/
1117 static PyObject *
1118 rpmts_PgpImportPubkey(rpmtsObject * s, PyObject * args, PyObject * kwds)
1119  /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
1120  /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
1121 {
1122  PyObject * blob;
1123  unsigned char * pkt;
1124  unsigned int pktlen;
1125  int rc;
1126  char * kwlist[] = {"pubkey", NULL};
1127 
1128 if (_rpmts_debug)
1129 fprintf(stderr, "*** rpmts_PgpImportPubkey(%p) ts %p\n", s, s->ts);
1130 
1131  if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:PgpImportPubkey",
1132  kwlist, &blob))
1133  return NULL;
1134 
1135  if (blob == Py_None) {
1136  Py_RETURN_NONE;
1137  }
1138  if (!(PyString_Check(blob) || PyUnicode_Check(blob))) {
1139  PyErr_SetString(pyrpmError, "PgpImportPubkey takes a string of octets");
1140  return NULL;
1141  }
1142  pkt = (unsigned char *) PyString_AsString(blob);
1143  pktlen = PyString_Size(blob);
1144 
1145  rc = rpmcliImportPubkey(s->ts, pkt, pktlen);
1146 
1147  return Py_BuildValue("i", rc);
1148 }
1149 
1152 static PyObject *
1153 rpmts_SetFlags(rpmtsObject * s, PyObject * args, PyObject * kwds)
1154  /*@modifies s @*/
1155 {
1156  rpmtransFlags transFlags = 0;
1157  char * kwlist[] = {"flags", NULL};
1158 
1159  if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:SetFlags", kwlist,
1160  &transFlags))
1161  return NULL;
1162 
1163 if (_rpmts_debug)
1164 fprintf(stderr, "*** rpmts_SetFlags(%p) ts %p transFlags 0x%x\n", s, s->ts, transFlags);
1165 
1166  /* XXX FIXME: value check on flags, or build pure python object
1167  * for it, and require an object of that type */
1168 
1169  return Py_BuildValue("i", rpmtsSetFlags(s->ts, transFlags));
1170 }
1171 
1174 static PyObject *
1175 rpmts_SetDFlags(rpmtsObject * s, PyObject * args, PyObject * kwds)
1176  /*@modifies s @*/
1177 {
1178  rpmdepFlags depFlags = 0;
1179  char * kwlist[] = {"flags", NULL};
1180 
1181  if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:SetDFlags", kwlist,
1182  &depFlags))
1183  return NULL;
1184 
1185 if (_rpmts_debug)
1186 fprintf(stderr, "*** rpmts_SetDFlags(%p) ts %p depFlags 0x%x\n", s, s->ts, depFlags);
1187 
1188  /* XXX FIXME: value check on flags, or build pure python object
1189  * for it, and require an object of that type */
1190 
1191  return Py_BuildValue("i", rpmtsSetDFlags(s->ts, depFlags));
1192 }
1193 
1196 static PyObject *
1197 rpmts_SetProbFilter(rpmtsObject * s, PyObject * args, PyObject * kwds)
1198  /*@modifies s @*/
1199 {
1200  rpmprobFilterFlags ignoreSet = 0;
1201  rpmprobFilterFlags oignoreSet;
1202  char * kwlist[] = {"ignoreSet", NULL};
1203 
1204  if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:ProbFilter", kwlist,
1205  &ignoreSet))
1206  return NULL;
1207 
1208 if (_rpmts_debug)
1209 fprintf(stderr, "*** rpmts_SetProbFilter(%p) ts %p ignoreSet %x\n", s, s->ts, ignoreSet);
1210 
1211  oignoreSet = s->ignoreSet;
1212  s->ignoreSet = ignoreSet;
1213 
1214  return Py_BuildValue("i", oignoreSet);
1215 }
1216 
1219 /*@null@*/
1220 static rpmpsObject *
1222  /*@modifies s @*/
1223 {
1224 
1225 if (_rpmts_debug)
1226 fprintf(stderr, "*** rpmts_Problems(%p) ts %p\n", s, s->ts);
1227 
1228  return rpmps_Wrap( rpmtsProblems(s->ts) );
1229 }
1230 
1233 static PyObject *
1234 rpmts_Run(rpmtsObject * s, PyObject * args, PyObject * kwds)
1235  /*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
1236  /*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
1237 {
1238  int rc;
1239  PyObject * list;
1240  rpmps ps;
1241  rpmpsi psi;
1242  struct rpmtsCallbackType_s cbInfo;
1243  char * kwlist[] = {"callback", "data", NULL};
1244 
1245  if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO:Run", kwlist,
1246  &cbInfo.cb, &cbInfo.data))
1247  return NULL;
1248 
1249  cbInfo.tso = s;
1250  cbInfo.dso = NULL;
1251  cbInfo._save = PyEval_SaveThread();
1252 
1253  if (cbInfo.cb != NULL) {
1254  if (!PyCallable_Check(cbInfo.cb)) {
1255  PyErr_SetString(PyExc_TypeError, "expected a callable");
1256  return NULL;
1257  }
1258  (void) rpmtsSetNotifyCallback(s->ts, rpmtsCallback, (void *) &cbInfo);
1259  }
1260 
1261 if (_rpmts_debug)
1262 fprintf(stderr, "*** rpmts_Run(%p) ts %p ignore %x\n", s, s->ts, s->ignoreSet);
1263 
1264  rc = rpmtsRun(s->ts, NULL, s->ignoreSet);
1265  ps = rpmtsProblems(s->ts);
1266 
1267  if (cbInfo.cb)
1268  (void) rpmtsSetNotifyCallback(s->ts, NULL, NULL);
1269 
1270  PyEval_RestoreThread(cbInfo._save);
1271 
1272  if (rc < 0) {
1273  list = PyList_New(0);
1274  return list;
1275  } else if (!rc) {
1276  Py_RETURN_NONE;
1277  }
1278 
1279  list = PyList_New(0);
1280  if (!list) {
1281  return NULL;
1282  }
1283  psi = rpmpsInitIterator(ps);
1284  while (rpmpsNextIterator(psi) >= 0) {
1285  rpmProblem p = rpmpsProblem(psi);
1286  PyObject * prob = Py_BuildValue("s(isN)", rpmProblemString(p),
1287  rpmProblemGetType(p),
1288  rpmProblemGetStr(p),
1289  PyLong_FromLongLong(rpmProblemGetDiskNeed(p)));
1290  PyList_Append(list, prob);
1291  Py_XDECREF(prob);
1292  }
1293  psi = rpmpsFreeIterator(psi);
1294 
1295  ps = rpmpsFree(ps);
1296 
1297  return list;
1298 }
1299 
1303 static PyObject *
1305  /*@globals _Py_NoneStruct @*/
1306  /*@modifies s, _Py_NoneStruct @*/
1307 {
1308  PyObject * result;
1309 
1310 if (_rpmts_debug)
1311 fprintf(stderr, "*** rpmts_Next(%p) ts %p\n", s, s->ts);
1312 
1313  result = rpmts_iternext(s);
1314 
1315  if (result == NULL) {
1316  Py_RETURN_NONE;
1317  }
1318 
1319  return result;
1320 }
1321 
1324 /*@null@*/
1325 static specObject *
1326 spec_Parse(rpmtsObject * s, PyObject * args, PyObject * kwds)
1327  /*@globals rpmGlobalMacroContext @*/
1328  /*@modifies s, rpmGlobalMacroContext @*/
1329 {
1330  const char * specfile;
1331  Spec spec;
1332  int recursing = 0;
1333  char * passPhrase = "";
1334  char *cookie = NULL;
1335  int anyarch = 1;
1336  int verify;
1337  int force = 1;
1338  char * kwlist[] = {"specfile", NULL};
1339 
1340  if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:Parse", kwlist, &specfile))
1341  return NULL;
1342 
1343  verify = rpmExpandNumeric("%{?_py_parsespec_verify}%{?!_py_parsespec_verify:0}");
1344 
1345  if (parseSpec(s->ts, specfile,"/", recursing, passPhrase,
1346  cookie, anyarch, force, verify)!=0) {
1347  PyErr_SetString(pyrpmError, "can't parse specfile\n");
1348  return NULL;
1349  }
1350 
1351  spec = rpmtsSpec(s->ts);
1352  return spec_Wrap(spec);
1353 }
1354 
1357 /*@null@*/
1358 static rpmmiObject *
1359 rpmts_Match(rpmtsObject * s, PyObject * args, PyObject * kwds)
1360  /*@globals rpmGlobalMacroContext @*/
1361  /*@modifies s, rpmGlobalMacroContext @*/
1362 {
1363  PyObject *TagN = NULL;
1364  PyObject *Key = NULL;
1365  char *key = NULL;
1366 /* XXX lkey *must* be a 32 bit integer, int "works" on all known platforms. */
1367  int lkey = 0;
1368  int len = 0;
1369  int tag = RPMDBI_PACKAGES;
1370  char * kwlist[] = {"tagNumber", "key", NULL};
1371 
1372 if (_rpmts_debug)
1373 fprintf(stderr, "*** rpmts_Match(%p) ts %p\n", s, s->ts);
1374 
1375  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:Match", kwlist,
1376  &TagN, &Key))
1377  return NULL;
1378 
1379  if (TagN && (tag = tagNumFromPyObject (TagN)) == -1) {
1380  PyErr_SetString(PyExc_TypeError, "unknown tag type");
1381  return NULL;
1382  }
1383 
1384  if (Key) {
1385 /*@-branchstate@*/
1386  if (PyString_Check(Key) || PyUnicode_Check(Key)) {
1387  key = PyString_AsString(Key);
1388  len = PyString_Size(Key);
1389  } else if (PyInt_Check(Key)) {
1390  lkey = PyInt_AsLong(Key);
1391  key = (char *)&lkey;
1392  len = sizeof(lkey);
1393  } else {
1394  PyErr_SetString(PyExc_TypeError, "unknown key type");
1395  return NULL;
1396  }
1397 /*@=branchstate@*/
1398  }
1399 
1400  /* XXX If not already opened, open the database O_RDONLY now. */
1401  /* XXX FIXME: lazy default rdonly open also done by rpmtsInitIterator(). */
1402  if (rpmtsGetRdb(s->ts) == NULL) {
1403  int rc = rpmtsOpenDB(s->ts, O_RDONLY);
1404  if (rc || rpmtsGetRdb(s->ts) == NULL) {
1405  PyErr_SetString(PyExc_TypeError, "rpmdb open failed");
1406  return NULL;
1407  }
1408  }
1409 
1410  return rpmmi_Wrap( rpmtsInitIterator(s->ts, tag, key, len) );
1411 }
1412 
1417 /*@-fullinitblock@*/
1418 /*@unchecked@*/ /*@observer@*/
1419 static struct PyMethodDef rpmts_methods[] = {
1420  {"Debug", (PyCFunction)rpmts_Debug, METH_VARARGS|METH_KEYWORDS,
1421  NULL},
1422 
1423  {"addInstall", (PyCFunction) rpmts_AddInstall, METH_VARARGS|METH_KEYWORDS,
1424  NULL },
1425  {"addErase", (PyCFunction) rpmts_AddErase, METH_VARARGS|METH_KEYWORDS,
1426  NULL },
1427  {"setDFlags", (PyCFunction) rpmts_SetDFlags, METH_VARARGS|METH_KEYWORDS,
1428 "ts.setDFlags(depFlags) -> previous depFlags\n\
1429 - Set control bit(s) for executing ts.check() and ts.order().\n" },
1430  {"check", (PyCFunction) rpmts_Check, METH_VARARGS|METH_KEYWORDS,
1431  NULL },
1432  {"order", (PyCFunction) rpmts_Order, METH_NOARGS,
1433  NULL },
1434  {"setFlags", (PyCFunction) rpmts_SetFlags, METH_VARARGS|METH_KEYWORDS,
1435 "ts.setFlags(transFlags) -> previous transFlags\n\
1436 - Set control bit(s) for executing ts.run().\n\
1437  Note: This method replaces the 1st argument to the old ts.run()\n" },
1438  {"setProbFilter", (PyCFunction) rpmts_SetProbFilter, METH_VARARGS|METH_KEYWORDS,
1439 "ts.setProbFilter(ignoreSet) -> previous ignoreSet\n\
1440 - Set control bit(s) for ignoring problems found by ts.run().\n\
1441  Note: This method replaces the 2nd argument to the old ts.run()\n" },
1442  {"problems", (PyCFunction) rpmts_Problems, METH_NOARGS,
1443 "ts.problems() -> ps\n\
1444 - Return current problem set.\n" },
1445  {"run", (PyCFunction) rpmts_Run, METH_VARARGS|METH_KEYWORDS,
1446 "ts.run(callback, data) -> (problems)\n\
1447 - Run a transaction set, returning list of problems found.\n\
1448  Note: The callback may not be None.\n" },
1449  {"clean", (PyCFunction) rpmts_Clean, METH_NOARGS,
1450  NULL },
1451  {"IDTXload", (PyCFunction) rpmts_IDTXload, METH_VARARGS|METH_KEYWORDS,
1452 "ts.IDTXload(rbtid=iid) -> ((tid,hdr,instance)+)\n\
1453 - Return list of installed packages reverse sorted by transaction id.\n" },
1454  {"IDTXglob", (PyCFunction) rpmts_IDTXglob, METH_VARARGS|METH_KEYWORDS,
1455 "ts.IDTXglob(rbtid=rid) -> ((tid,hdr,instance)+)\n\
1456 - Return list of removed packages reverse sorted by transaction id.\n" },
1457  {"rollback", (PyCFunction) rpmts_Rollback, METH_VARARGS|METH_KEYWORDS,
1458  NULL },
1459  {"openDB", (PyCFunction) rpmts_OpenDB, METH_NOARGS,
1460 "ts.openDB() -> None\n\
1461 - Open the default transaction rpmdb.\n\
1462  Note: The transaction rpmdb is lazily opened, so ts.openDB() is seldom needed.\n" },
1463  {"closeDB", (PyCFunction) rpmts_CloseDB, METH_NOARGS,
1464 "ts.closeDB() -> None\n\
1465 - Close the default transaction rpmdb.\n\
1466  Note: ts.closeDB() disables lazy opens, and should hardly ever be used.\n" },
1467  {"initDB", (PyCFunction) rpmts_InitDB, METH_NOARGS,
1468 "ts.initDB() -> None\n\
1469 - Initialize the default transaction rpmdb.\n\
1470  Note: ts.initDB() is seldom needed anymore.\n" },
1471  {"rebuildDB", (PyCFunction) rpmts_RebuildDB, METH_NOARGS,
1472 "ts.rebuildDB() -> None\n\
1473 - Rebuild the default transaction rpmdb.\n" },
1474  {"verifyDB", (PyCFunction) rpmts_VerifyDB, METH_NOARGS,
1475 "ts.verifyDB() -> None\n\
1476 - Verify the default transaction rpmdb.\n" },
1477  {"hdrFromFdno",(PyCFunction) rpmts_HdrFromFdno,METH_VARARGS|METH_KEYWORDS,
1478 "ts.hdrFromFdno(fdno) -> hdr\n\
1479 - Read a package header from a file descriptor.\n" },
1480  {"hdrCheck", (PyCFunction) rpmts_HdrCheck, METH_VARARGS|METH_KEYWORDS,
1481  NULL },
1482 {"getVSFlags",(PyCFunction) rpmts_GetVSFlags, METH_NOARGS,
1483 "ts.getVSFlags() -> vsflags\n\
1484 - Retrieve current signature verification flags from transaction\n" },
1485  {"setVSFlags",(PyCFunction) rpmts_SetVSFlags, METH_VARARGS|METH_KEYWORDS,
1486 "ts.setVSFlags(vsflags) -> ovsflags\n\
1487 - Set signature verification flags. Values for vsflags are:\n\
1488  rpm.RPMVSF_NOHDRCHK if set, don't check rpmdb headers\n\
1489  rpm.RPMVSF_NEEDPAYLOAD if not set, check header+payload (if possible)\n\
1490  rpm.RPMVSF_NOSHA1HEADER if set, don't check header SHA1 digest\n\
1491  rpm.RPMVSF_NODSAHEADER if set, don't check header DSA signature\n\
1492  rpm.RPMVSF_NORSAHEADER if set, don't check header RSA signature\n\
1493  rpm.RPMVSF_NOECDSAHEADER if set, don't check header ECDSA signature\n\
1494  rpm.RPMVSF_NOMD5 if set, don't check header+payload MD5 digest\n\
1495  rpm.RPMVSF_NODSA if set, don't check header+payload DSA signature\n\
1496  rpm.RPMVSF_NORSA if set, don't check header+payload RSA signature\n\
1497  rpm.RPMVSF_NOECDSA if set, don't check header+payload ECDSA signature\n\
1498 " },
1499  {"setColor",(PyCFunction) rpmts_SetColor, METH_VARARGS|METH_KEYWORDS,
1500  NULL },
1501  {"pgpPrtPkts", (PyCFunction) rpmts_PgpPrtPkts, METH_VARARGS|METH_KEYWORDS,
1502  NULL },
1503  {"pgpImportPubkey", (PyCFunction) rpmts_PgpImportPubkey, METH_VARARGS|METH_KEYWORDS,
1504  NULL },
1505  {"parseSpec", (PyCFunction) spec_Parse, METH_VARARGS|METH_KEYWORDS,
1506 "ts.parseSpec(\"/path/to/foo.spec\") -> spec\n\
1507 - Parse a spec file.\n" },
1508  {"dbMatch", (PyCFunction) rpmts_Match, METH_VARARGS|METH_KEYWORDS,
1509 "ts.dbMatch([TagN, [key, [len]]]) -> mi\n\
1510 - Create a match iterator for the default transaction rpmdb.\n" },
1511  {"next", (PyCFunction)rpmts_Next, METH_NOARGS,
1512 "ts.next() -> te\n\
1513 - Retrieve next transaction set element.\n" },
1514  {NULL, NULL} /* sentinel */
1515 };
1516 /*@=fullinitblock@*/
1517 
1520 static void rpmts_dealloc(/*@only@*/ rpmtsObject * s)
1521  /*@modifies *s @*/
1522 {
1523 
1524 if (_rpmts_debug)
1525 fprintf(stderr, "%p -- ts %p db %p\n", s, s->ts, rpmtsGetRdb(s->ts));
1526  (void)rpmtsFree(s->ts);
1527  s->ts = NULL;
1528 
1529  if (s->scriptFd) Fclose(s->scriptFd);
1530  /* this will free the keyList, and decrement the ref count of all
1531  the items on the list as well :-) */
1532  Py_XDECREF(s->keyList);
1533  PyObject_Del((PyObject *)s);
1534 }
1535 
1538 static int rpmts_setattro(PyObject * o, PyObject * n, PyObject * v)
1539  /*@*/
1540 {
1541  rpmtsObject *s = (rpmtsObject *)o;
1542  char * name = PyString_AsString(n);
1543  int fdno;
1544 
1545  if (!strcmp(name, "scriptFd")) {
1546  if (!PyArg_Parse(v, "i", &fdno)) return 0;
1547  if (fdno < 0) {
1548  PyErr_SetString(PyExc_TypeError, "bad file descriptor");
1549  return -1;
1550  } else {
1551  s->scriptFd = fdDup(fdno);
1552  rpmtsSetScriptFd(s->ts, s->scriptFd);
1553  }
1554  } else {
1555  PyErr_SetString(PyExc_AttributeError, name);
1556  return -1;
1557  }
1558 
1559  return 0;
1560 }
1561 
1564 static int rpmts_init(rpmtsObject * s, PyObject *args, PyObject *kwds)
1565  /*@globals rpmGlobalMacroContext @*/
1566  /*@modifies s, rpmGlobalMacroContext @*/
1567 {
1568  /* nothing to do atm... */
1569  return 0;
1570 }
1571 
1574 static void rpmts_free(/*@only@*/ rpmtsObject * s)
1575  /*@modifies s @*/
1576 {
1577 if (_rpmts_debug)
1578 fprintf(stderr, "%p -- ts %p db %p\n", s, s->ts, rpmtsGetRdb(s->ts));
1579  (void)rpmtsFree(s->ts);
1580  s->ts = NULL;
1581 
1582  if (s->scriptFd)
1583  Fclose(s->scriptFd);
1584 
1585  /* this will free the keyList, and decrement the ref count of all
1586  the items on the list as well :-) */
1587  Py_XDECREF(s->keyList);
1588 
1589  PyObject_Del((PyObject *)s);
1590 }
1591 
1594 static PyObject * rpmts_alloc(PyTypeObject * subtype, int nitems)
1595  /*@*/
1596 {
1597  PyObject * s = PyType_GenericAlloc(subtype, nitems);
1598 
1599 if (_rpmts_debug < 0)
1600 fprintf(stderr, "*** rpmts_alloc(%p,%d) ret %p\n", subtype, nitems, s);
1601  return s;
1602 }
1603 
1606 static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
1607  /*@globals rpmGlobalMacroContext @*/
1608  /*@modifies rpmGlobalMacroContext @*/
1609 {
1610  rpmtsObject * s = (void *) PyObject_New(rpmtsObject, subtype);
1611 
1612  char * rootDir = "/";
1613  int vsflags = rpmExpandNumeric("%{?_vsflags}");
1614  char * kwlist[] = {"rootdir", "vsflags", 0};
1615 
1616 if (_rpmts_debug < 0)
1617 fprintf(stderr, "*** rpmts_init(%p,%p,%p)\n", s, args, kwds);
1618 
1619  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|si:rpmts_init", kwlist,
1620  &rootDir, &vsflags))
1621  return NULL;
1622 
1623  s->ts = rpmtsCreate();
1624  /* XXX: Why is there no rpmts_SetRootDir() ? */
1625  (void) rpmtsSetRootDir(s->ts, rootDir);
1626  /* XXX: make this use common code with rpmts_SetVSFlags() to check the
1627  * python objects */
1628  (void) rpmtsSetVSFlags(s->ts, vsflags);
1629  s->keyList = PyList_New(0);
1630  s->ignoreSet = 0;
1631  s->scriptFd = NULL;
1632  s->tsi = NULL;
1633  s->tsiFilter = 0;
1634 
1635 if (_rpmts_debug)
1636 fprintf(stderr, "%p ++ ts %p db %p\n", s, s->ts, rpmtsGetRdb(s->ts));
1637 
1638  return (PyObject *)s;
1639 }
1640 
1643 /*@unchecked@*/ /*@observer@*/
1644 static char rpmts_doc[] =
1645 "";
1646 
1649 /*@-fullinitblock@*/
1650 PyTypeObject rpmts_Type = {
1651  PyVarObject_HEAD_INIT(&PyType_Type, 0)
1652  "rpm.ts", /* tp_name */
1653  sizeof(rpmtsObject), /* tp_size */
1654  0, /* tp_itemsize */
1655  (destructor) rpmts_dealloc, /* tp_dealloc */
1656  0, /* tp_print */
1657  (getattrfunc)0, /* tp_getattr */
1658  (setattrfunc)0, /* tp_setattr */
1659  0, /* tp_compare */
1660  0, /* tp_repr */
1661  0, /* tp_as_number */
1662  0, /* tp_as_sequence */
1663  0, /* tp_as_mapping */
1664  0, /* tp_hash */
1665  0, /* tp_call */
1666  0, /* tp_str */
1667  PyObject_GenericGetAttr, /* tp_getattro */
1668  (setattrofunc) rpmts_setattro, /* tp_setattro */
1669  0, /* tp_as_buffer */
1670  Py_TPFLAGS_DEFAULT, /* tp_flags */
1671  rpmts_doc, /* tp_doc */
1672 #if Py_TPFLAGS_HAVE_ITER
1673  0, /* tp_traverse */
1674  0, /* tp_clear */
1675  0, /* tp_richcompare */
1676  0, /* tp_weaklistoffset */
1677  (getiterfunc) rpmts_iter, /* tp_iter */
1678  (iternextfunc) rpmts_iternext, /* tp_iternext */
1679  rpmts_methods, /* tp_methods */
1680  0, /* tp_members */
1681  0, /* tp_getset */
1682  0, /* tp_base */
1683  0, /* tp_dict */
1684  0, /* tp_descr_get */
1685  0, /* tp_descr_set */
1686  0, /* tp_dictoffset */
1687  (initproc) rpmts_init, /* tp_init */
1688  (allocfunc) rpmts_alloc, /* tp_alloc */
1689  (newfunc) rpmts_new, /* tp_new */
1690  (freefunc) rpmts_free, /* tp_free */
1691  0, /* tp_is_gc */
1692 #endif
1693 };
1694 /*@=fullinitblock@*/
1695 
1698 PyObject *
1699 rpmts_Create(/*@unused@*/ PyObject * s, PyObject * args,
1700  PyObject * kwds)
1701 {
1702  return PyObject_Call((PyObject *) &rpmts_Type, args, kwds);
1703 }
rpmTag tagNumFromPyObject(PyObject *item)
Definition: header-py.c:362
static specObject * spec_Parse(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1326
rpmRelocation relocations
Definition: rpmcli.h:683
const bson * b
Definition: bson.h:280
Spec rpmtsSpec(rpmts ts)
Get spec control structure from transaction set.
Definition: rpmts.c:1378
struct IDTindex_s * IDTX
Definition: rpmrollback.h:17
hdrObject * hdr_Wrap(Header h)
Definition: header-py.c:678
struct rpmpsi_s * rpmpsi
Definition: rpmps.h:29
const char * str
Definition: rpmtag.h:73
rpmTag tag
Definition: rpmtag.h:503
static int rpmts_setattro(PyObject *o, PyObject *n, PyObject *v)
Definition: rpmts-py.c:1538
specObject * spec_Wrap(Spec spec)
Definition: spec-py.c:298
static PyObject * rpmts_SetVSFlags(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1038
static PyObject * rpmts_iter(rpmtsObject *s)
Definition: rpmts-py.c:335
pgpDig pgpDigFree(pgpDig dig)
Destroy a container for parsed OpenPGP packates.
const char const char size_t len
Definition: bson.h:823
const char * rpmProblemString(const rpmProblem prob)
Return formatted string representation of a problem.
Definition: rpmps.c:231
const char bson_timestamp_t * ts
Definition: bson.h:1004
rpmRC rpmcliImportPubkey(const rpmts ts, const unsigned char *pkt, ssize_t pktlen)
Import public key packet(s).
Definition: rpmchecksig.c:515
OpenPGP constants and structures from RFC-2440.
PyObject * keyList
Definition: rpmts-py.h:19
#define EXIT_FAILURE
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
Definition: rpmdb.c:1747
char * xstrdup(const char *str)
Definition: rpmmalloc.c:321
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
Definition: depends.c:547
rpmts ts
Definition: rpmts-py.h:18
static PyObject * rpmts_Check(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:515
struct IDT_s * IDT
Definition: rpmrollback.h:13
enum rpmprobFilterFlags_e rpmprobFilterFlags
struct headerToken_s * Header
Definition: rpmtag.h:22
int headerGet(Header h, HE_t he, unsigned int flags)
Retrieve extension or tag value from a header.
Definition: header.c:2231
rpmpsi rpmpsFreeIterator(rpmpsi psi)
Destroy problem set iterator.
Definition: rpmps.c:91
IDTX IDTXglob(rpmts ts, const char *globstr, rpmTag tag, rpmuint32_t rbtid)
Load tag (instance,value) pairs from packages, and return sorted id index.
Definition: rpmrollback.c:172
The Header data structure.
rpmpsObject * rpmps_Wrap(rpmps ps)
Definition: rpmps-py.c:391
int rpmtsSetSolveCallback(rpmts ts, int(*solve)(rpmts ts, rpmds key, const void *data), const void *solveData)
Definition: rpmts.c:569
rpmQueryFlags qva_flags
Definition: rpmcli.h:633
static PyObject * rpmts_GetVSFlags(rpmtsObject *s)
Definition: rpmts-py.c:1029
static int rpmtsVerifyDB(rpmts ts)
Verify the database used by the transaction.
Definition: rpmts.h:495
static PyObject * rpmts_InitDB(rpmtsObject *s)
Definition: rpmts-py.c:854
char * rpmProblemGetPkgNEVR(rpmProblem prob)
Return the package NEVR causing the problem.
Definition: rpmps.c:398
static rpmmiObject * rpmts_Match(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1359
static rpmVSFlags vsflags
Definition: rpmcache.c:547
Definition: rpmdb.c:436
PyThreadState * _save
Definition: rpmts-py.c:177
int rpmtsSetNotifyCallback(rpmts ts, rpmCallbackFunction notify, rpmCallbackData notifyData)
Set transaction notify callback function and argument.
Definition: rpmts.c:1460
enum rpmCallbackType_e rpmCallbackType
Bit(s) to identify progress callbacks.
rpmRC headerCheck(pgpDig dig, const void *uh, size_t uc, const char **msg)
Check header consistency, performing headerGet() the hard way.
Definition: pkgio.c:1075
static PyObject * rpmts_PgpImportPubkey(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1118
static PyObject * rpmts_SetColor(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1061
static PyObject * rpmts_IDTXload(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:677
rpmtsi tsi
Definition: rpmts-py.h:22
static PyObject * rpmts_HdrCheck(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:968
static PyObject * rpmts_alloc(PyTypeObject *subtype, int nitems)
Definition: rpmts-py.c:1594
rpmtsi rpmtsiFree(rpmtsi tsi)
Destroy transaction element iterator.
static void rpmlog(int code, const char *fmt,...)
Definition: rpmlog.h:299
struct rpmps_s * rpmps
Transaction problems found while processing a transaction set/.
Definition: rpmps.h:25
const char * rpmdsDNEVR(const rpmds ds)
Return current formatted dependency string.
Definition: rpmds.c:657
FD_t fdDup(int fdno)
Definition: rpmio.c:266
static PyObject * rpmts_Clean(rpmtsObject *s)
Definition: rpmts-py.c:661
struct rpmds_s * rpmds
Dependency tag sets from a header, so that a header can be discarded early.
Definition: rpmtypes.h:28
static PyObject * rpmts_Rollback(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:780
static PyObject * rpmts_VerifyDB(rpmtsObject *s)
Definition: rpmts-py.c:894
static PyObject * rpmts_CloseDB(rpmtsObject *s)
Definition: rpmts-py.c:836
rpmmiObject * rpmmi_Wrap(rpmmi mi)
Definition: rpmmi-py.c:260
Command line option information.
Definition: rpmcli.h:630
PyObject * data
Definition: rpmts-py.c:174
static rpmpsObject * rpmts_Problems(rpmtsObject *s)
Definition: rpmts-py.c:1221
int parseSpec(rpmts ts, const char *specFile, const char *rootURL, int recursing, const char *passPhrase, const char *cookie, int anyarch, int force, int verify)
Parse spec file into spec control structure.
Definition: parseSpec.c:530
struct rpmte_s * rpmte
An element of a transaction set, i.e.
Definition: rpmtypes.h:38
int rpmdbCheckTerminate(int terminate)
Check rpmdb signal handler for trapped signal and/or requested exit.
Definition: rpmdb.c:476
static PyObject * rpmts_OpenDB(rpmtsObject *s)
Definition: rpmts-py.c:818
char * alloca()
Header hdrGetHeader(hdrObject *s)
Definition: header-py.c:685
rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
Set transaction flags, i.e.
Definition: rpmts.c:1347
static int rpmts_SolveCallback(rpmts ts, rpmds ds, const void *data)
Definition: rpmts-py.c:199
char * rpmProblemGetStr(rpmProblem prob)
Return a generic data string from a problem.
Definition: rpmps.c:408
rpmtsObject * tso
Definition: rpmts-py.c:175
void * ptr
Definition: rpmtag.h:67
static void rpmts_Die(PyObject *cb)
Definition: rpmts-py.c:183
const char const bson_bool_t v
Definition: bson.h:919
PyObject * rpmts_Create(PyObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1699
int rpmpsNextIterator(rpmpsi psi)
Return next problem set iterator index.
Definition: rpmps.c:100
int _rpmts_debug
Definition: rpmts.c:93
rpmdsObject * dso
Definition: rpmts-py.c:176
char * rpmProblemGetAltNEVR(rpmProblem prob)
Return the second package NEVR causing the problem.
Definition: rpmps.c:403
const char const bson * data
Definition: mongo.h:463
static char rpmts_doc[]
Definition: rpmts-py.c:1644
rpmTagData p
Definition: rpmtag.h:506
static int rpmtsInitDB(rpmts ts, int dbmode)
Initialize the database used by the transaction.
Definition: rpmts.h:473
enum rpmdepFlags_e rpmdepFlags
Bit(s) to control rpmtsCheck() and rpmtsOrder() operation.
unsigned long long rpmuint64_t
Definition: rpmiotypes.h:29
static PyObject * rpmts_Debug(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:390
static void fdSetOpen(FD_t fd, const char *path, int flags, mode_t mode)
static void rpmts_dealloc(rpmtsObject *s)
Definition: rpmts-py.c:1520
static int rpmts_init(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1564
rpmtransFlags transFlags
Definition: rpmcli.h:672
rpmuint32_t rbtid
Definition: rpmcli.h:676
rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char *fn, Header *hdrp)
Return package header from file handle, verifying digests/signatures.
Definition: package.c:114
static PyObject * rpmts_AddErase(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:454
int rpmtsRebuildDB(rpmts ts)
Rebuild the database used by the transaction.
Definition: rpmts.c:136
The FD_t File Handle data structure.
static PyObject * rpmts_SetDFlags(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1175
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
Definition: rpmts.c:212
struct pgpDig_s * pgpDig
Definition: rpmiotypes.h:97
int rpmRollback(rpmts ts, QVA_t ia, const char **argv)
Rollback transactions, erasing new, reinstalling old, package(s).
Definition: rpmrollback.c:421
rpmprobFilterFlags ignoreSet
Definition: rpmts-py.h:24
int rpmtsSolve(rpmts ts, rpmds ds, const void *data)
Attempt to solve a needed dependency using the solve database.
Definition: rpmts.c:351
rpmpsi rpmpsInitIterator(rpmps ps)
Initialize problem set iterator.
Definition: rpmps.c:78
rpmdsObject * rpmds_Wrap(rpmds ds)
Definition: rpmds-py.c:792
The structure used to store values parsed from a spec file.
Definition: rpmspec.h:113
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
Definition: rpmts.h:35
Header headerFree(Header h)
Dereference a header instance.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
Definition: macro.c:3252
static PyObject * rpmts_iternext(rpmtsObject *s)
Definition: rpmts-py.c:351
PyTypeObject hdr_Type
Definition: header-py.c:633
void rpmtsSetRootDir(rpmts ts, const char *rootDir)
Set transaction rootDir, i.e.
Definition: rpmts.c:927
IDTX IDTXfree(IDTX idtx)
Destroy id index.
Definition: rpmrollback.c:74
int rpmtsSetDBMode(rpmts ts, int dbmode)
Set dbmode of transaction set.
Definition: rpmts.c:1430
rpmInstallInterfaceFlags installInterfaceFlags
Definition: rpmcli.h:674
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
int Fclose(FD_t fd)
fclose(3) clone.
Definition: rpmio.c:2534
rpmuint64_t rpmProblemGetDiskNeed(rpmProblem prob)
Return generic pointer/long attribute from a problem.
Definition: rpmps.c:413
static PyObject * rpmts_AddInstall(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:410
rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
Return next transaction element of type.
Definition: rpmte.c:831
rpmprobFilterFlags probFilter
Definition: rpmcli.h:673
static PyObject * rpmts_Next(rpmtsObject *s)
Definition: rpmts-py.c:1304
rpmps rpmpsFree(rpmps ps)
Destroy a problem set.
rpmteObject * rpmte_Wrap(rpmte te)
Definition: rpmte-py.c:486
IDTX IDTXload(rpmts ts, rpmTag tag, rpmuint32_t rbtid)
Load tag (instance,value) pairs from rpm databse, and return sorted id index.
Definition: rpmrollback.c:123
void * rpmCallbackData
Definition: rpmiotypes.h:162
static PyObject * rpmts_HdrFromFdno(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:914
rpmdb rpmtsGetRdb(rpmts ts)
Get transaction set database handle.
Definition: pkgio.c:151
static PyObject * rpmts_IDTXglob(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:727
enum rpmRC_e rpmRC
RPM return codes.
pgpDig pgpDigNew(pgpVSFlags vsflags, pgpPubkeyAlgo pubkey_algo)
Create a container for parsed OpenPGP packates.
Definition: rpmpgp.c:1314
static PyObject * rpmts_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1606
Definition: rpmtag.h:502
const char const int i
Definition: bson.h:778
static PyObject * rpmts_Run(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1234
const char const bson * key
Definition: mongo.h:717
This is the only module users of librpmbuild should need to include.
rpmdepFlags rpmtsSetDFlags(rpmts ts, rpmdepFlags depFlags)
Set dependency flags, i.e.
Definition: rpmts.c:1368
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
struct rpmtsObject_s rpmtsObject
rpmts rpmtsCreate(void)
Create an empty transaction set.
Definition: rpmts.c:1470
rpmProblem rpmpsProblem(rpmpsi psi)
Return current problem from problem set.
Definition: rpmps.c:114
Methods to handle package elements.
rpmps rpmtsProblems(rpmts ts)
Return current transaction set problems.
Definition: rpmts.c:584
enum rpmtransFlags_e rpmtransFlags
Bit(s) to control rpmtsRun() operation.
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
Definition: rpmts.c:845
rpmElementType tsiFilter
Definition: rpmts-py.h:23
struct rpmts_s * rpmts
The RPM Transaction Set.
Definition: rpmtypes.h:14
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Definition: rpmiotypes.h:756
static PyObject * rpmts_RebuildDB(rpmtsObject *s)
Definition: rpmts-py.c:874
const void * fnpyKey
Definition: rpmiotypes.h:134
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
Definition: rpmdb.c:2252
int(* rpmtsRun)(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
Process all package elements in a transaction set.
Definition: transaction.c:2307
static PyObject * rpmts_SetProbFilter(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1197
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
Definition: rpmts.c:840
static PyObject * rpmts_PgpPrtPkts(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1083
struct rpmProblem_s * rpmProblem
Raw data for an element of a problem set.
Definition: rpmps.h:20
PyTypeObject rpmts_Type
Definition: rpmts-py.c:1650
int rpmtsAddEraseElement(rpmts ts, Header h, uint32_t hdrNum)
Add package to be erased to transaction set.
Definition: depends.c:834
rpmProblemType rpmProblemGetType(rpmProblem prob)
Return the problem type.
Definition: rpmps.c:418
int(* rpmtsCheck)(rpmts ts)
Perform dependency resolution on the transaction set.
Definition: depends.c:2097
int rpmtsOpenDB(rpmts ts, int dbmode)
Open the database used by the transaction.
Definition: rpmts.c:115
PyObject * pyrpmError
Definition: rpmmodule.c:51
int pgpPrtPkts(const rpmuint8_t *pkts, size_t pktlen, pgpDig dig, int printing)
Print/parse a OpenPGP packet(s).
Definition: rpmpgp.c:1518
int Fileno(FD_t fd)
fileno(3) clone.
Definition: rpmio.c:2998
static const char * name
#define _(Text)
Definition: system.h:29
fnpyKey rpmProblemKey(rpmProblem prob)
Return the transaction key causing the problem.
Definition: rpmps.c:423
rpmtsi rpmtsiInit(rpmts ts)
Create transaction element iterator.
Access RPM indices using Berkeley DB interface(s).
enum rpmTag_e rpmTag
Definition: rpmtag.h:470
static struct PyMethodDef rpmts_methods[]
Definition: rpmts-py.c:1419
PyObject * cb
Definition: rpmts-py.c:173
static PyObject * rpmts_SetFlags(rpmtsObject *s, PyObject *args, PyObject *kwds)
Definition: rpmts-py.c:1153
static PyObject * rpmts_Order(rpmtsObject *s)
Definition: rpmts-py.c:641
unsigned int rpmmiCount(rpmmi mi)
Return number of elements in rpm database iterator.
Definition: rpmdb.c:1763
int rpmtsDBMode(rpmts ts)
Retrieve dbmode of transaction set.
Definition: rpmts.c:1425
rpmuint32_t rpmtsSetColor(rpmts ts, rpmuint32_t color)
Set color bits of transaction set.
Definition: rpmts.c:1445
int rpmtsCloseDB(rpmts ts)
Close the database used by the transaction.
Definition: rpmts.c:101
int(* rpmtsOrder)(rpmts ts)
Determine package order in a transaction set according to dependencies.
Definition: order.c:2311
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
Definition: macro.c:3326
static void * rpmtsCallback(const void *hd, const rpmCallbackType what, const rpmuint64_t amount, const rpmuint64_t total, fnpyKey pkgKey, rpmCallbackData data)
Definition: rpmts-py.c:239
static void rpmts_free(rpmtsObject *s)
Definition: rpmts-py.c:1574
void rpmtsSetScriptFd(rpmts ts, FD_t scriptFd)
Definition: rpmts.c:982
#define RPMDBI_PACKAGES
Pseudo-tags used by the rpmdb and rpmgi iterator API's.
Definition: rpmtag.h:479
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.
Definition: rpmts.c:598
static int nitems
Definition: rpmcache.c:81
FD_t scriptFd
Definition: rpmts-py.h:20