rpm  5.4.10
rpmts.c
Go to the documentation of this file.
1 
5 #include "system.h"
6 
7 #include <rpmio.h>
8 #include <rpmiotypes.h> /* XXX fnpyKey */
9 #include <rpmlog.h>
10 #include <iosm.h> /* XXX iosmFileAction */
11 #include <rpmurl.h>
12 #include <rpmpgp.h>
13 #include <rpmmacro.h> /* XXX rpmtsOpenDB() needs rpmGetPath */
14 #include <rpmkeyring.h>
15 #include <rpmhkp.h>
16 #include <rpmsx.h>
17 
18 #include <rpmtypes.h>
19 #define _RPMTAG_INTERNAL /* XXX tagStore_s */
20 #include <rpmtag.h>
21 #include <pkgio.h>
22 
23 #define _RPMDB_INTERNAL /* XXX almost opaque sigh */
24 #include "rpmdb.h" /* XXX stealing db->db_mode. */
25 
26 #include "rpmal.h"
27 #include "rpmds.h"
28 #include "rpmfi.h"
29 #include "rpmlock.h"
30 #include "rpmns.h"
31 
32 #define _RPMTE_INTERNAL /* XXX te->h */
33 #include "rpmte.h"
34 
35 #define _RPMTS_INTERNAL
36 #define _RPMBAG_INTERNAL
37 #include "rpmts.h"
38 
39 #include <rpmcli.h>
40 
41 #include "fs.h"
42 
43 /* XXX FIXME: merge with existing (broken?) tests in system.h */
44 /* portability fiddles */
45 #if STATFS_IN_SYS_STATVFS
46 /*@-incondefs@*/
47 #if defined(__LCLINT__)
48 /*@-declundef -exportheader -protoparammatch @*/ /* LCL: missing annotation */
49 extern int statvfs (const char * file, /*@out@*/ struct statvfs * buf)
50  /*@globals fileSystem @*/
51  /*@modifies *buf, fileSystem @*/;
52 /*@=declundef =exportheader =protoparammatch @*/
53 /*@=incondefs@*/
54 #else
55 # include <sys/statvfs.h>
56 #endif
57 #else
58 # if STATFS_IN_SYS_VFS
59 # include <sys/vfs.h>
60 # else
61 # if STATFS_IN_SYS_MOUNT
62 # include <sys/mount.h>
63 # else
64 # if STATFS_IN_SYS_STATFS
65 # include <sys/statfs.h>
66 # endif
67 # endif
68 # endif
69 #endif
70 
71 #include "debug.h"
72 
73 /*@access FD_t @*/ /* XXX void * arg */
74 /*@access rpmdb @*/ /* XXX db->db_chrootDone, NULL */
75 
76 /*@access rpmDiskSpaceInfo @*/
77 /*@access rpmKeyring @*/
78 /*@access rpmps @*/
79 /*@access rpmte @*/
80 /*@access rpmtsi @*/
81 /*@access fnpyKey @*/
82 /*@access pgpDig @*/
83 /*@access pgpDigParams @*/
84 
85 #ifdef __cplusplus
86 GENfree(rpmDiskSpaceInfo)
87 GENfree(uint32_t *)
88 GENfree(fnpyKey *)
89 GENfree(rpmte *)
90 #endif /* __cplusplus */
91 
92 /*@unchecked@*/
93 int _rpmts_debug = 0;
94 
95 /*@unchecked@*/
96 int _rpmts_stats = 0;
97 
98 /*@unchecked@*/
99 int _rpmts_macros = 0;
100 
102 {
103  int rc = 0;
104 
105  if (ts->rdb != NULL) {
106  (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBGET), &ts->rdb->db_getops);
107  (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBPUT), &ts->rdb->db_putops);
108  (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBDEL), &ts->rdb->db_delops);
109  rc = rpmdbClose(ts->rdb);
110  ts->rdb = NULL;
111  }
112  return rc;
113 }
114 
115 int rpmtsOpenDB(rpmts ts, int dbmode)
116 {
117  int rc = 0;
118 
119  if (ts->rdb != NULL && ts->dbmode == dbmode)
120  return 0;
121 
122  (void) rpmtsCloseDB(ts);
123 
124  /* XXX there's a db lock race here that is the callers responsibility. */
125 
126  ts->dbmode = dbmode;
127  rc = rpmdbOpen(ts->rootDir, &ts->rdb, ts->dbmode, (mode_t)0644);
128  if (rc) {
129  const char * dn = rpmGetPath(ts->rootDir, "%{_dbpath}", NULL);
130  rpmlog(RPMLOG_ERR, _("cannot open Packages database in %s\n"), dn);
131  dn = _free(dn);
132  }
133  return rc;
134 }
135 
137 {
138  void * lock = rpmtsAcquireLock(ts);
139  rpmdb db = NULL;
140  const char * fn;
141  struct stat sb;
142  int rc;
143  int xx;
144 
145  /* XXX Seqno update needs O_RDWR. */
146  rc = rpmtsOpenDB(ts, O_RDWR);
147  if (rc) goto exit;
148  db = rpmtsGetRdb(ts);
149 
150  if (!(db->db_api == 3 || db->db_api == 4))
151  goto exit;
152 
153  rc = rpmtxnCheckpoint(db);
154  if (rc) goto exit;
155 
156  { size_t dbix;
157  for (dbix = 0; dbix < db->db_ndbi; dbix++) {
158  tagStore_t dbiTags = &db->db_tags[dbix];
159 
160  /* Remove configured secondary indices. */
161  switch (dbiTags->tag) {
162  case RPMDBI_PACKAGES:
163  case RPMDBI_AVAILABLE:
164  case RPMDBI_ADDED:
165  case RPMDBI_REMOVED:
166  case RPMDBI_DEPCACHE:
167  case RPMDBI_SEQNO:
168  case RPMDBI_BTREE:
169  case RPMDBI_HASH:
170  case RPMDBI_QUEUE:
171  case RPMDBI_RECNO:
172  continue;
173  /*@notreached@*/ /*@switchbreak@*/ break;
174  default:
175  fn = rpmGetPath(db->db_root, db->db_home, "/",
176  (dbiTags->str != NULL ? dbiTags->str : tagName(dbiTags->tag)),
177  NULL);
178  if (!Stat(fn, &sb))
179  xx = Unlink(fn);
180  fn = _free(fn);
181  /*@switchbreak@*/ break;
182  }
183 
184  /* Open (and re-create) each index. */
185  (void) dbiOpen(db, dbiTags->tag, db->db_flags);
186  }
187  }
188 
189  /* Unreference header used by associated secondary index callbacks. */
190  (void) headerFree(db->db_h);
191  db->db_h = NULL;
192 
193  /* Reset the Seqno counter to the maximum primary key */
194  rpmlog(RPMLOG_DEBUG, D_("rpmdb: max. primary key %u\n"),
195  (unsigned)db->db_maxkey);
196  fn = rpmGetPath(db->db_root, db->db_home, "/Seqno", NULL);
197  if (!Stat(fn, &sb))
198  xx = Unlink(fn);
199  (void) dbiOpen(db, RPMDBI_SEQNO, db->db_flags);
200  fn = _free(fn);
201 
202  rc = rpmtxnCheckpoint(db);
203 
204  xx = rpmtsCloseDB(ts);
205 
206 exit:
207  lock = rpmtsFreeLock(lock);
208  return rc;
209 }
210 
211 /*@-compdef@*/ /* keyp might not be defined. */
213  const void * keyp, size_t keylen)
214 {
215  rpmmi mi = (ts->rdb == NULL && rpmtsOpenDB(ts, ts->dbmode))
216  ? NULL
217  : rpmmiInit(ts->rdb, rpmtag, keyp, keylen);
218  return mi;
219 }
220 /*@=compdef@*/
221 
223 {
224  rpmbag bag = ts->bag;
225  int rc = 0;
226 
227  if (bag != NULL) {
228  rpmsdb * sdbp = bag->sdbp;
229  int i = bag->nsdbp;
230  if (sdbp)
231  while (--i >= 0) {
232  rpmdb sdb;
233  if (sdbp[i] == NULL)
234  continue;
235  sdb = (rpmdb) sdbp[i]->_db;
236  if (sdb) {
237  int xx;
238  (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBGET), &sdb->db_getops);
239  (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBPUT), &sdb->db_putops);
240  (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBDEL), &sdb->db_delops);
241  xx = rpmdbClose(sdb);
242  if (xx && rc == 0)
243  rc = xx;
244  }
245  (void) rpmbagDel(bag, i);
246  }
247  ts->bag = rpmbagFree(ts->bag);
248  }
249  return rc;
250 }
251 
252 int rpmtsOpenSDB(rpmts ts, int dbmode)
253 {
254  static int has_sdbpath = -1;
255  rpmbag bag = ts->bag;
256  rpmsdb * sdbp = NULL;
257  rpmdb sdb = NULL;
258  int sdbmode = O_RDONLY;
259  const char * s = NULL;
260 #ifdef DYING /* XXX solevedb's never need chroot prefix. */
261  const char * rootDir = ts->rootDir;
262 #else
263  const char * rootDir = "/";
264 #endif
265  ARGV_t av = NULL;
266  int ac = 0;
267  int rc = 0;
268  int xx;
269  int i;
270 
271  if (bag == NULL) {
272  bag = ts->bag = rpmbagNew(NULL, 0);
273  if (bag == NULL)
274  goto exit;
275  }
276  sdbp = bag->sdbp;
277  sdb = (rpmdb) (sdbp[0] ? sdbp[0]->_db : NULL);
278  sdbmode = (sdbp[0] ? sdbp[0]->dbmode : O_RDONLY);
279 
280  if (sdb != NULL && sdbmode == dbmode) {
281  rc = 0;
282  goto exit;
283  }
284 
285  if (has_sdbpath < 0)
286  has_sdbpath = rpmExpandNumeric("%{?_solve_dbpath:1}");
287 
288  /* If not configured, don't try to open. */
289  if (has_sdbpath <= 0) {
290  rc = 1;
291  goto exit;
292  }
293 
294  s = rpmExpand("%{?_solve_dbpath}", NULL);
295  xx = argvSplit(&av, s, ":");
296  ac = argvCount(av);
297 
298  for (i = 0; i < ac; i++) {
299  const char * fn;
300  urltype ut;
301 
302  if (av[i] == NULL || *av[i] == '\0')
303  continue;
304 
305  fn = NULL;
306  ut = urlPath(av[i], &fn);
307 
308  /* XXX Lstat(fn, &sb) to ensure a directory? */
309  addMacro(NULL, "_dbpath", NULL, fn, RMIL_DEFAULT);
310  xx = rpmdbOpen(rootDir, &sdb, dbmode, (mode_t)0644);
311  delMacro(NULL, "_dbpath");
312 
313  if (xx) {
314  const char * dn = rpmGetPath(rootDir, "/", fn, NULL);
315  rpmlog(RPMLOG_WARNING, _("cannot open Solve database in %s\n"), dn);
316  dn = _free(dn);
317  if (rc == 0)
318  rc = xx;
319 
320  /* XXX only try to open the solvedb once. */
321  has_sdbpath = 0;
322  continue;
323  }
324 
325  xx = rpmbagAdd(bag, sdb, dbmode);
326  }
327 
328  av = argvFree(av);
329  s = _free(s);
330 
331 exit:
332 if (_rpmts_debug)
333 fprintf(stderr, "<-- %s(%p, 0%o) rc %d\n", __FUNCTION__, ts, dbmode, rc);
334  return rc;
335 }
336 
343 static int sugcmp(const void * a, const void * b)
344  /*@*/
345 {
346  const char * astr = *(const char **)a;
347  const char * bstr = *(const char **)b;
348  return strcmp(astr, bstr);
349 }
350 
351 int rpmtsSolve(rpmts ts, rpmds ds, /*@unused@*/ const void * data)
352 {
353  HE_t he = (HE_t) memset(alloca(sizeof(*he)), 0, sizeof(*he));
354  rpmbag bag = ts->bag;
355  rpmsdb * sdbp = NULL;
356  const char * errstr = NULL;
357  const char * str = NULL;
358  rpmmi mi;
359  Header bh = NULL;
360  Header h = NULL;
361  size_t bhnamelen = 0;
362  time_t bhtime = 0;
363  rpmTag rpmtag;
364  const char * keyp;
365  size_t keylen = 0;
366  int rc = 1; /* assume not found */
367  int xx;
368  int i;
369 
370 if (_rpmts_debug)
371 fprintf(stderr, "--> %s(%p,%p,%p)\n", __FUNCTION__, ts, ds, data);
372 
373  /* Make suggestions only for installing Requires: */
374  if (ts->goal != TSM_INSTALL)
375  goto exit;
376 
377  switch (rpmdsTagN(ds)) {
378  case RPMTAG_CONFLICTNAME:
379  default:
380  goto exit;
381  /*@notreached@*/ break;
382  case RPMTAG_DIRNAMES: /* XXX perhaps too many wrong answers? */
383  case RPMTAG_REQUIRENAME:
384  case RPMTAG_FILELINKTOS:
385  break;
386  }
387 
388  keyp = rpmdsN(ds);
389  if (keyp == NULL)
390  goto exit;
391 
392  if (bag == NULL) {
393  xx = rpmtsOpenSDB(ts, O_RDONLY);
394  if (xx)
395  goto exit;
396  bag = ts->bag;
397  if (bag == NULL)
398  goto exit;
399  }
400 
401  sdbp = bag->sdbp;
402 
403  if (sdbp)
404  for (i = 0; i < (int)bag->nsdbp; i++) {
405  rpmdb sdb = NULL;
406 
407  if (sdbp[i] == NULL)
408  continue;
409  sdb = (rpmdb) sdbp[i]->_db;
410  if (sdb == NULL)
411  continue;
412 
413  /* Look for a matching Provides: in suggested universe. */
414  rpmtag = (*keyp == '/' ? RPMTAG_FILEPATHS : RPMTAG_PROVIDENAME);
415  mi = rpmmiInit(sdb, rpmtag, keyp, keylen);
416  while ((h = rpmmiNext(mi)) != NULL) {
417  size_t hnamelen;
418  time_t htime;
419 
420  if (rpmtag == RPMTAG_PROVIDENAME && !rpmdsAnyMatchesDep(h, ds, 1))
421  continue;
422 
423  he->tag = RPMTAG_NAME;
424  xx = headerGet(h, he, 0);
425  hnamelen = ((xx && he->p.str) ? strlen(he->p.str) : 0);
426  he->p.ptr = _free(he->p.ptr);
427 
428  /* XXX Prefer the shortest pkg N for basenames/provides resp. */
429  if (bhnamelen > 0 && hnamelen > bhnamelen)
430  continue;
431 
432  /* XXX Prefer the newest build if given alternatives. */
433  he->tag = RPMTAG_BUILDTIME;
434  xx = headerGet(h, he, 0);
435  htime = (xx && he->p.ui32p ? he->p.ui32p[0] : 0);
436  he->p.ptr = _free(he->p.ptr);
437 
438  if (htime <= bhtime)
439  continue;
440 
441  /* Save new "best" candidate. */
442  (void)headerFree(bh);
443  bh = NULL;
444  bh = headerLink(h);
445  bhtime = htime;
446  bhnamelen = hnamelen;
447  }
448  mi = rpmmiFree(mi);
449  }
450 
451  /* Is there a suggested resolution? */
452  if (bh == NULL)
453  goto exit;
454 
455  /* Get the path to the package file. */
457  he->p.ptr = NULL;
458  xx = headerGet(bh, he, 0);
459  if (he->p.str) {
460  str = he->p.str;
461  he->p.str = NULL;
462  } else {
463  /* Format the suggested resolution path. */
464  const char * qfmt = rpmExpand("%{?_solve_name_fmt}", NULL);
465  if (qfmt == NULL || *qfmt == '\0')
466  goto exit;
467  str = headerSprintf(bh, qfmt, NULL, rpmHeaderFormats, &errstr);
468  qfmt = _free(qfmt);
469  }
470 
471  (void) headerFree(bh);
472  bh = NULL;
473  if (errstr) {
474  rpmlog(RPMLOG_ERR, _("incorrect solve path format: %s\n"), errstr);
475  goto exit;
476  }
477 
478  if (ts->depFlags & RPMDEPS_FLAG_ADDINDEPS) {
479  FD_t fd;
480  rpmRC rpmrc;
481 
482  fd = Fopen(str, "r.fdio");
483  if (fd == NULL || Ferror(fd)) {
484  rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), str,
485  Fstrerror(fd));
486  if (fd != NULL) {
487  xx = Fclose(fd);
488  fd = NULL;
489  }
490  str = _free(str);
491  goto exit;
492  }
493  rpmrc = rpmReadPackageFile(ts, fd, str, &h);
494  xx = Fclose(fd);
495  switch (rpmrc) {
496  default:
497  str = _free(str);
498  break;
499  case RPMRC_NOTTRUSTED:
500  case RPMRC_NOKEY:
501  case RPMRC_OK:
502  if (h != NULL &&
503  !rpmtsAddInstallElement(ts, h, (fnpyKey)str, 1, NULL))
504  {
505  rpmlog(RPMLOG_DEBUG, D_("Adding: %s\n"), str);
506  rc = -1; /* XXX restart unsatisfiedDepends() */
507  break;
508  }
509  break;
510  }
511  (void)headerFree(h);
512  h = NULL;
513  goto exit;
514  }
515 
516  rpmlog(RPMLOG_DEBUG, D_("Suggesting: %s\n"), str);
517  /* If suggestion is already present, don't bother. */
518  if (ts->suggests != NULL && ts->nsuggests > 0) {
519  if (bsearch(&str, ts->suggests, ts->nsuggests,
520  sizeof(*ts->suggests), sugcmp))
521  {
522  str = _free(str);
523  goto exit;
524  }
525  }
526 
527  /* Add a new (unique) suggestion. */
528  ts->suggests = (const void **) xrealloc(ts->suggests,
529  sizeof(*ts->suggests) * (ts->nsuggests + 2));
530  ts->suggests[ts->nsuggests] = str;
531  ts->nsuggests++;
532  ts->suggests[ts->nsuggests] = NULL;
533 
534  if (ts->nsuggests > 1)
535  qsort(ts->suggests, ts->nsuggests, sizeof(*ts->suggests), sugcmp);
536 
537 exit:
538 if (_rpmts_debug)
539 fprintf(stderr, "<-- %s(%p,%p,%p) rc %d N %s EVR %s F 0x%x\n", __FUNCTION__, ts, ds, data, rc, rpmdsN(ds), rpmdsEVR(ds), rpmdsFlags(ds));
540  return rc;
541 }
542 
543 int rpmtsAvailable(rpmts ts, const rpmds ds)
544 {
545  fnpyKey * sugkey;
546  int rc = 1; /* assume not found */
547 
548  if (ts->availablePackages == NULL)
549  return rc;
550  sugkey = rpmalAllSatisfiesDepend(ts->availablePackages, ds, NULL);
551  if (sugkey == NULL)
552  return rc;
553 
554  /* XXX no alternatives yet */
555  if (sugkey[0] != NULL) {
556  ts->suggests = (const void **) xrealloc(ts->suggests,
557  sizeof(*ts->suggests) * (ts->nsuggests + 2));
558  ts->suggests[ts->nsuggests] = sugkey[0];
559  sugkey[0] = NULL;
560  ts->nsuggests++;
561  ts->suggests[ts->nsuggests] = NULL;
562  }
563  sugkey = _free(sugkey);
564  return rc;
565 }
566 
568  int (*solve) (rpmts ts, rpmds key, const void * data),
569  const void * solveData)
570 {
571  int rc = 0;
572 
573  if (ts) {
574 /*@-assignexpose -temptrans @*/
575  ts->solve = solve;
576  ts->solveData = solveData;
577 /*@=assignexpose =temptrans @*/
578  }
579  return rc;
580 }
581 
583 {
584  static const char msg[] = "rpmtsProblems";
585  rpmps ps = NULL;
586  if (ts) {
587  if (ts->probs == NULL)
588  ts->probs = rpmpsCreate();
589 /*@-castexpose@*/
590  ps = rpmpsLink(ts->probs, msg);
591 /*@=castexpose@*/
592  }
593  return ps;
594 }
595 
597 {
598  rpmtsi pi; rpmte p;
599 
600  if (ts == NULL)
601  return;
602 
603  /* Clean up after dependency checks. */
604  pi = rpmtsiInit(ts);
605  while ((p = rpmtsiNext(pi, (rpmElementType)0)) != NULL)
606  rpmteCleanDS(p);
607  pi = rpmtsiFree(pi);
608 
609  ts->addedPackages = rpmalFree(ts->addedPackages);
610  ts->numAddedPackages = 0;
611 
612  ts->erasedPackages = rpmalFree(ts->erasedPackages);
613  ts->numErasedPackages = 0;
614 
615  ts->suggests = _free(ts->suggests);
616  ts->nsuggests = 0;
617 
618  ts->probs = rpmpsFree(ts->probs);
619 
620  rpmtsCleanDig(ts);
621 }
622 
624 {
625  rpmtsi pi; rpmte p;
626  int oc;
627 
628  if (ts == NULL)
629  return;
630 
631 /*@-nullstate@*/ /* FIX: partial annotations */
632  rpmtsClean(ts);
633 /*@=nullstate@*/
634 
635  for (pi = rpmtsiInit(ts), oc = 0; (p = rpmtsiNext(pi, (rpmElementType)0)) != NULL; oc++) {
636 /*@-type -unqualifiedtrans @*/
637  ts->order[oc] = rpmteFree(ts->order[oc]);
638 /*@=type =unqualifiedtrans @*/
639  }
640  pi = rpmtsiFree(pi);
641  ts->numAddedFiles = 0;
642  ts->numErasedFiles = 0;
643 
644  ts->orderCount = 0;
645  ts->ntrees = 0;
646  ts->maxDepth = 0;
647 
648  ts->numRemovedPackages = 0;
649 /*@-nullstate@*/ /* FIX: partial annotations */
650  return;
651 /*@=nullstate@*/
652 }
653 
654 static void rpmtsPrintStat(const char * name, /*@null@*/ struct rpmop_s * op)
655  /*@globals fileSystem @*/
656  /*@modifies fileSystem @*/
657 {
658  static unsigned int scale = (1000 * 1000);
659  if (op != NULL && op->count > 0)
660  fprintf(stderr, " %s %8d %6lu.%06lu MB %6lu.%06lu secs\n",
661  name, op->count,
662  (unsigned long)op->bytes/scale, (unsigned long)op->bytes%scale,
663  op->usecs/scale, op->usecs%scale);
664 }
665 
666 /*@unchecked@*/ /*@relnull@*/
667 extern rpmop _hdr_loadops;
668 /*@unchecked@*/ /*@relnull@*/
669 extern rpmop _hdr_getops;
670 
671 static void rpmtsPrintStats(rpmts ts)
672  /*@globals fileSystem, internalState @*/
673  /*@modifies fileSystem, internalState @*/
674 {
675  (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_TOTAL), 0);
676 
677  if (_hdr_loadops)
679  if (_hdr_getops)
681 
682  rpmtsPrintStat("total: ", rpmtsOp(ts, RPMTS_OP_TOTAL));
683  rpmtsPrintStat("check: ", rpmtsOp(ts, RPMTS_OP_CHECK));
684  rpmtsPrintStat("order: ", rpmtsOp(ts, RPMTS_OP_ORDER));
685  rpmtsPrintStat("fingerprint: ", rpmtsOp(ts, RPMTS_OP_FINGERPRINT));
686  rpmtsPrintStat("repackage: ", rpmtsOp(ts, RPMTS_OP_REPACKAGE));
687  rpmtsPrintStat("install: ", rpmtsOp(ts, RPMTS_OP_INSTALL));
688  rpmtsPrintStat("erase: ", rpmtsOp(ts, RPMTS_OP_ERASE));
689  rpmtsPrintStat("scriptlets: ", rpmtsOp(ts, RPMTS_OP_SCRIPTLETS));
690  rpmtsPrintStat("compress: ", rpmtsOp(ts, RPMTS_OP_COMPRESS));
691  rpmtsPrintStat("uncompress: ", rpmtsOp(ts, RPMTS_OP_UNCOMPRESS));
692  rpmtsPrintStat("digest: ", rpmtsOp(ts, RPMTS_OP_DIGEST));
693  rpmtsPrintStat("signature: ", rpmtsOp(ts, RPMTS_OP_SIGNATURE));
694  rpmtsPrintStat("dbadd: ", rpmtsOp(ts, RPMTS_OP_DBADD));
695  rpmtsPrintStat("dbremove: ", rpmtsOp(ts, RPMTS_OP_DBREMOVE));
696  rpmtsPrintStat("dbget: ", rpmtsOp(ts, RPMTS_OP_DBGET));
697  rpmtsPrintStat("dbput: ", rpmtsOp(ts, RPMTS_OP_DBPUT));
698  rpmtsPrintStat("dbdel: ", rpmtsOp(ts, RPMTS_OP_DBDEL));
699  rpmtsPrintStat("readhdr: ", rpmtsOp(ts, RPMTS_OP_READHDR));
700  rpmtsPrintStat("hdrload: ", rpmtsOp(ts, RPMTS_OP_HDRLOAD));
701  rpmtsPrintStat("hdrget: ", rpmtsOp(ts, RPMTS_OP_HDRGET));
702 /*@-globstate@*/
703  return;
704 /*@=globstate@*/
705 }
706 
707 static void rpmtsFini(void * _ts)
708  /*@modifies _ts @*/
709 {
710  rpmts ts = (rpmts) _ts;
711 
712 /*@-nullstate@*/ /* FIX: partial annotations */
713  /* XXX there's a recursion here ... release and reacquire the lock */
714 #ifndef BUGGY
715  yarnRelease(ts->_item.use); /* XXX hack-o-round */
716 #endif
717  rpmtsEmpty(ts);
718 #ifndef BUGGY
719  yarnPossess(ts->_item.use); /* XXX hack-o-round */
720 #endif
721 /*@=nullstate@*/
722 
723  ts->PRCO = rpmdsFreePRCO(ts->PRCO);
724 
725  (void) rpmtsCloseDB(ts);
726 assert(ts->txn == NULL); /* XXX FIXME */
727  ts->txn = NULL;
728 
729  (void) rpmtsCloseSDB(ts);
730 
731  (void) rpmbfFree(ts->rbf);
732  ts->rbf = NULL;
733  ts->removedPackages = _free(ts->removedPackages);
734 
735  ts->availablePackages = rpmalFree(ts->availablePackages);
736  ts->numAvailablePackages = 0;
737 
738  ts->dsi = _free(ts->dsi);
739 
740  if (ts->scriptFd != NULL) {
741 /*@-refcounttrans@*/ /* FIX: XfdFree annotation */
742  ts->scriptFd = fdFree(ts->scriptFd, __FUNCTION__);
743 /*@=refcounttrans@*/
744  ts->scriptFd = NULL;
745  }
746  ts->rootDir = _free(ts->rootDir);
747  ts->currDir = _free(ts->currDir);
748 
749 /*@-type +voidabstract @*/ /* FIX: double indirection */
750  ts->order = _free(ts->order);
751 /*@=type =voidabstract @*/
752  ts->orderAlloced = 0;
753 
754  ts->keyring = rpmKeyringFree(ts->keyring);
755  (void) rpmhkpFree(ts->hkp);
756  ts->hkp = NULL;
757 
758  if (_rpmts_stats)
759  rpmtsPrintStats(ts);
760 
761  if (_rpmts_macros) {
762  const char ** av = NULL;
763 /*@-globs@*/ /* Avoid rpmGlobalMcroContext et al. */
764  (void)rpmGetMacroEntries(NULL, NULL, 1, &av);
765 /*@=globs@*/
766  argvPrint("macros used", av, NULL);
767  av = argvFree(av);
768  }
769 }
770 
771 /*@unchecked@*/ /*@only@*/ /*@null@*/
773 
774 static rpmts rpmtsGetPool(/*@null@*/ rpmioPool pool)
775  /*@globals _rpmtsPool, fileSystem, internalState @*/
776  /*@modifies pool, _rpmtsPool, fileSystem, internalState @*/
777 {
778  rpmts ts;
779 
780  if (_rpmtsPool == NULL) {
781  _rpmtsPool = rpmioNewPool("ts", sizeof(*ts), -1, _rpmts_debug,
782  NULL, NULL, rpmtsFini);
783  pool = _rpmtsPool;
784  }
785  ts = (rpmts) rpmioGetPool(pool, sizeof(*ts));
786  memset(((char *)ts)+sizeof(ts->_item), 0, sizeof(*ts)-sizeof(ts->_item));
787  return ts;
788 }
789 
790 void * rpmtsGetKeyring(rpmts ts, /*@unused@*/ int autoload)
791 {
792  rpmKeyring keyring = NULL;
793  if (ts) {
794 #ifdef NOTYET
795  if (ts->keyring == NULL && autoload)
796  loadKeyring(ts);
797  keyring = rpmKeyringLink(ts->keyring);
798 #else
799  keyring = ts->keyring;
800 #endif
801  }
802 /*@-refcounttrans@*/
803  return (void *)keyring;
804 /*@=refcounttrans@*/
805 }
806 
807 int rpmtsSetKeyring(rpmts ts, void * _keyring)
808 {
809  rpmKeyring keyring = (rpmKeyring) _keyring;
810 
811  if (ts == NULL)
812  return -1;
813 
814 #ifdef NOTYET
815  /*
816  * Should we permit switching keyring on the fly? For now, require
817  * rpmdb isn't open yet (fairly arbitrary limitation)...
818  */
819  if (rpmtsGetRdb(ts) != NULL)
820  return -1;
821 #endif
822 
823 /*@-modnomods@*/
824  ts->keyring = rpmKeyringFree(ts->keyring);
825 /*@=modnomods@*/
826 
827 #ifdef NOTYET
828  ts->keyring = rpmKeyringLink(keyring);
829 #else
830 /*@-assignexpose -newreftrans @*/
831 /*@i@*/ ts->keyring = keyring;
832 /*@=assignexpose =newreftrans @*/
833 #endif
834 
835  return 0;
836 }
837 
838 rpmVSFlags rpmtsVSFlags(/*@unused@*/ rpmts ts)
839 {
840  return pgpDigVSFlags;
841 }
842 
844  /*@globals pgpDigVSFlags @*/
845  /*@modifies pgpDigVSFlags @*/
846 {
847  rpmVSFlags ovsflags;
848  ovsflags = pgpDigVSFlags;
850  return ovsflags;
851 }
852 
853 /*
854  * This allows us to mark transactions as being of a certain type.
855  * The three types are:
856  *
857  * RPM_TRANS_NORMAL
858  * RPM_TRANS_ROLLBACK
859  * RPM_TRANS_AUTOROLLBACK
860  *
861  * ROLLBACK and AUTOROLLBACK transactions should always be ran as
862  * a best effort. In particular this is important to the autorollback
863  * feature to avoid rolling back a rollback (otherwise known as
864  * dueling rollbacks (-;). AUTOROLLBACK's additionally need instance
865  * counts passed to scriptlets to be altered.
866  */
867 /* Let them know what type of transaction we are */
869 {
870  return (rpmTSType) ((ts != NULL) ? ts->type : 0);
871 }
872 
874 {
875  if (ts != NULL)
876  ts->type = type;
877 }
878 
880 {
881  return ((ts != NULL) ? ts->arbgoal : 0);
882 }
883 
885 {
886  if (ts != NULL)
887  ts->arbgoal = goal;
888 }
889 
890 int rpmtsUnorderedSuccessors(rpmts ts, int first)
891 {
892  int unorderedSuccessors = 0;
893  if (ts != NULL) {
894  unorderedSuccessors = ts->unorderedSuccessors;
895  if (first >= 0)
896  ts->unorderedSuccessors = first;
897  }
898  return unorderedSuccessors;
899 }
900 
901 const char * rpmtsRootDir(rpmts ts)
902 {
903  const char * rootDir = NULL;
904 
905  if (ts != NULL && ts->rootDir != NULL) {
906  urltype ut = urlPath(ts->rootDir, &rootDir);
907  switch (ut) {
908  case URL_IS_UNKNOWN:
909  case URL_IS_PATH:
910  break;
911  case URL_IS_DASH:
912  case URL_IS_HKP:
913  case URL_IS_FTP:
914  case URL_IS_HTTP:
915  case URL_IS_HTTPS:
916  case URL_IS_MONGO: /* XXX FIXME */
917  default:
918  rootDir = "/";
919  break;
920  }
921  }
922  return rootDir;
923 }
924 
925 void rpmtsSetRootDir(rpmts ts, const char * rootDir)
926 {
927  if (ts != NULL) {
928  size_t rootLen;
929 
930  ts->rootDir = _free(ts->rootDir);
931 
932  if (rootDir == NULL) {
933 #ifdef DYING
934  ts->rootDir = xstrdup("");
935 #endif
936  return;
937  }
938  rootLen = strlen(rootDir);
939 
940  /* Make sure that rootDir has trailing / */
941  if (!(rootLen && rootDir[rootLen - 1] == '/')) {
942  char * t = (char *) alloca(rootLen + 2);
943  *t = '\0';
944  (void) stpcpy( stpcpy(t, rootDir), "/");
945  rootDir = t;
946  }
947  ts->rootDir = xstrdup(rootDir);
948  }
949 }
950 
951 const char * rpmtsCurrDir(rpmts ts)
952 {
953  const char * currDir = NULL;
954  if (ts != NULL) {
955  currDir = ts->currDir;
956  }
957  return currDir;
958 }
959 
960 void rpmtsSetCurrDir(rpmts ts, const char * currDir)
961 {
962  if (ts != NULL) {
963  ts->currDir = _free(ts->currDir);
964  if (currDir)
965  ts->currDir = xstrdup(currDir);
966  }
967 }
968 
970 {
971  FD_t scriptFd = NULL;
972  if (ts != NULL) {
973  scriptFd = ts->scriptFd;
974  }
975 /*@-compdef -refcounttrans -usereleased@*/
976  return scriptFd;
977 /*@=compdef =refcounttrans =usereleased@*/
978 }
979 
980 void rpmtsSetScriptFd(rpmts ts, FD_t scriptFd)
981 {
982 
983  if (ts != NULL) {
984  if (ts->scriptFd != NULL) {
985 /*@-assignexpose@*/
986  ts->scriptFd = fdFree(ts->scriptFd, "rpmtsSetScriptFd");
987 /*@=assignexpose@*/
988  ts->scriptFd = NULL;
989  }
990 /*@-assignexpose -castexpose @*/
991  if (scriptFd != NULL)
992  ts->scriptFd = fdLink((void *)scriptFd, "rpmtsSetScriptFd");
993 /*@=assignexpose =castexpose @*/
994  }
995 }
996 
998 {
999  int selinuxEnabled = 0;
1000  if (ts)
1001  selinuxEnabled = (ts->selinuxEnabled > 0);
1002  return selinuxEnabled;
1003 }
1004 
1006 {
1007  return (ts != NULL ? ts->chrootDone : 0);
1008 }
1009 
1010 int rpmtsSetChrootDone(rpmts ts, int chrootDone)
1011 {
1012  int ochrootDone = 0;
1013  if (ts != NULL) {
1014  ochrootDone = ts->chrootDone;
1015  if (ts->rdb != NULL)
1016  ts->rdb->db_chrootDone = chrootDone;
1017  ts->chrootDone = chrootDone;
1018  }
1019  return ochrootDone;
1020 }
1021 
1023 {
1024  rpmuint32_t tid = 0; /* XXX -1 is time(2) error return. */
1025  if (ts != NULL) {
1026  tid = ts->tid[0];
1027  }
1028  return tid;
1029 }
1030 
1032 {
1033  rpmuint32_t otid = 0; /* XXX -1 is time(2) error return. */
1034  if (ts != NULL) {
1035  otid = ts->tid[0];
1036  ts->tid[0] = tid;
1037  ts->tid[1] = 0;
1038  }
1039  return otid;
1040 }
1041 
1043 {
1044  rpmPRCO PRCO = NULL;
1045 
1046  if (ts != NULL) {
1047  static int oneshot = 0;
1048  if (!oneshot) {
1049  const char * fn = rpmGetPath("%{?_rpmds_sysinfo_path}", NULL);
1050  int xx;
1051 
1052  ts->PRCO = rpmdsNewPRCO(NULL);
1053  if (fn && *fn != '\0' && !rpmioAccess(fn, NULL, R_OK))
1054  xx = rpmdsSysinfo(ts->PRCO, NULL);
1055  fn = _free(fn);
1056  oneshot++;
1057  }
1058  PRCO = ts->PRCO;
1059  }
1060 /*@-compdef -retexpose -usereleased @*/
1061  return PRCO;
1062 /*@=compdef =retexpose =usereleased @*/
1063 }
1064 
1065 int rpmtsInitDSI(const rpmts ts)
1066 {
1067  rpmDiskSpaceInfo dsi;
1068  struct stat sb;
1069  int rc;
1070  size_t i;
1071 
1073  return 0;
1074  if (ts->filesystems != NULL)
1075  return 0;
1076 
1077  rpmlog(RPMLOG_DEBUG, D_("mounted filesystems:\n"));
1079  D_(" i dev bsize bavail iavail mount point\n"));
1080 
1081  rc = rpmGetFilesystemList(&ts->filesystems, &ts->filesystemCount);
1082  if (rc || ts->filesystems == NULL || ts->filesystemCount == 0)
1083  return rc;
1084 
1085  /* Get available space on mounted file systems. */
1086 
1087  ts->dsi = _free(ts->dsi);
1088  ts->dsi = (rpmDiskSpaceInfo) xcalloc((ts->filesystemCount + 1), sizeof(*ts->dsi));
1089 
1090  dsi = ts->dsi;
1091 
1092  if (dsi != NULL)
1093  for (i = 0; (i < ts->filesystemCount) && dsi; i++, dsi++) {
1094 #if STATFS_IN_SYS_STATVFS
1095  struct statvfs sfb;
1096  memset(&sfb, 0, sizeof(sfb));
1097  rc = statvfs(ts->filesystems[i], &sfb);
1098 #else
1099  struct statfs sfb;
1100  memset(&sfb, 0, sizeof(sfb));
1101 # if STAT_STATFS4
1102 /* This platform has the 4-argument version of the statfs call. The last two
1103  * should be the size of struct statfs and 0, respectively. The 0 is the
1104  * filesystem type, and is always 0 when statfs is called on a mounted
1105  * filesystem, as we're doing.
1106  */
1107  rc = statfs(ts->filesystems[i], &sfb, sizeof(sfb), 0);
1108 # else
1109  rc = statfs(ts->filesystems[i], &sfb);
1110 # endif
1111 #endif
1112  if (rc)
1113  break;
1114 
1115  rc = stat(ts->filesystems[i], &sb);
1116  if (rc)
1117  break;
1118  dsi->dev = sb.st_dev;
1119 /* XXX figger out how to get this info for non-statvfs systems. */
1120 #if STATFS_IN_SYS_STATVFS
1121  dsi->f_frsize = sfb.f_frsize;
1122 #if defined(RPM_OS_AIX)
1123  dsi->f_fsid = 0; /* sfb.f_fsid is a structure on AIX */
1124 #else
1125  dsi->f_fsid = sfb.f_fsid;
1126 #endif
1127  dsi->f_flag = sfb.f_flag;
1128  dsi->f_favail = (long long) sfb.f_favail;
1129  dsi->f_namemax = sfb.f_namemax;
1130 #elif defined(__APPLE__) && defined(__MACH__) && !defined(_SYS_STATVFS_H_)
1131  dsi->f_fsid = 0; /* "Not meaningful in this implementation." */
1132  dsi->f_namemax = pathconf(ts->filesystems[i], _PC_NAME_MAX);
1133 #elif defined(__OpenBSD__)
1134  dsi->f_fsid = 0; /* sfb.f_fsid is a structure on OpenBSD */
1135  dsi->f_namemax = pathconf(ts->filesystems[i], _PC_NAME_MAX);
1136 #else
1137  dsi->f_fsid = sfb.f_fsid;
1138  dsi->f_namemax = sfb.f_namelen;
1139 #endif
1140 
1141  dsi->f_bsize = sfb.f_bsize;
1142  dsi->f_blocks = (unsigned long long)sfb.f_blocks;
1143  dsi->f_bfree = (unsigned long long)sfb.f_bfree;
1144  dsi->f_files = (unsigned long long)sfb.f_files;
1145  dsi->f_ffree = (unsigned long long)sfb.f_ffree;
1146 
1147  dsi->bneeded = 0;
1148  dsi->ineeded = 0;
1149 #ifdef STATFS_HAS_F_BAVAIL
1150  dsi->f_bavail = (long long)(sfb.f_bavail ? sfb.f_bavail : 1);
1151  if (sfb.f_ffree > 0 && sfb.f_files > 0 && sfb.f_favail > 0)
1152  dsi->f_favail = (long long)sfb.f_favail;
1153  else /* XXX who knows what evil lurks here? */
1154  dsi->f_favail = !(sfb.f_ffree == 0 && sfb.f_files == 0)
1155  ? (signed long long) sfb.f_ffree : -1;
1156 #else
1157 /* FIXME: the statfs struct doesn't have a member to tell how many blocks are
1158  * available for non-superusers. f_blocks - f_bfree is probably too big, but
1159  * it's about all we can do.
1160  */
1161  dsi->f_bavail = sfb.f_blocks - sfb.f_bfree;
1162  /* XXX Avoid FAT and other file systems that have not inodes. */
1163  dsi->f_favail = !(sfb.f_ffree == 0 && sfb.f_files == 0)
1164  ? sfb.f_ffree : -1;
1165 #endif
1166 
1167 #if !defined(ST_RDONLY)
1168 #define ST_RDONLY 1
1169 #endif
1170  rpmlog(RPMLOG_DEBUG, "%5u 0x%08x %8u %12ld %12ld %s %s\n",
1171  (unsigned)i, (unsigned) dsi->dev, (unsigned) dsi->f_bsize,
1172  (signed long) dsi->f_bavail, (signed long) dsi->f_favail,
1173  ((dsi->f_flag & ST_RDONLY) ? "ro" : "rw"),
1174  ts->filesystems[i]);
1175  }
1176  return rc;
1177 }
1178 
1179 void rpmtsUpdateDSI(const rpmts ts, dev_t dev,
1180  rpmuint32_t fileSize, rpmuint32_t prevSize, rpmuint32_t fixupSize,
1181  int _action)
1182 {
1183  iosmFileAction action = (iosmFileAction) _action;
1184  rpmDiskSpaceInfo dsi;
1185  rpmuint64_t bneeded;
1186 
1187  dsi = ts->dsi;
1188  if (dsi) {
1189  while (dsi->f_bsize && dsi->dev != dev)
1190  dsi++;
1191  if (dsi->f_bsize == 0)
1192  dsi = NULL;
1193  }
1194  if (dsi == NULL)
1195  return;
1196 
1197  bneeded = BLOCK_ROUND(fileSize, dsi->f_bsize);
1198 
1199  switch (action) {
1200  case FA_BACKUP:
1201  case FA_SAVE:
1202  case FA_ALTNAME:
1203  dsi->ineeded++;
1204  dsi->bneeded += bneeded;
1205  /*@switchbreak@*/ break;
1206 
1207  /*
1208  * FIXME: If two packages share a file (same md5sum), and
1209  * that file is being replaced on disk, will dsi->bneeded get
1210  * adjusted twice? Quite probably!
1211  */
1212  case FA_CREATE:
1213  dsi->bneeded += bneeded;
1214  bneeded = BLOCK_ROUND(prevSize, dsi->f_bsize);
1215  if (dsi->bneeded > bneeded)
1216  dsi->bneeded -= bneeded;
1217  else
1218  dsi->bneeded = 0;
1219  /*@switchbreak@*/ break;
1220 
1221  case FA_ERASE:
1222  dsi->ineeded--;
1223  if (dsi->bneeded > bneeded)
1224  dsi->bneeded -= bneeded;
1225  else
1226  dsi->bneeded = 0;
1227  /*@switchbreak@*/ break;
1228 
1229  default:
1230  /*@switchbreak@*/ break;
1231  }
1232 
1233  if (fixupSize) {
1234  bneeded = BLOCK_ROUND(fixupSize, dsi->f_bsize);
1235  if (dsi->bneeded > bneeded)
1236  dsi->bneeded -= bneeded;
1237  else
1238  dsi->bneeded = 0;
1239  }
1240 }
1241 
1242 void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
1243 {
1244  rpmDiskSpaceInfo dsi;
1245  rpmps ps;
1246  int fc;
1247  size_t i;
1248 
1249  if (ts->filesystems == NULL || ts->filesystemCount == 0)
1250  return;
1251 
1252  dsi = ts->dsi;
1253  if (dsi == NULL)
1254  return;
1255  fc = rpmfiFC( rpmteFI(te, RPMTAG_BASENAMES) );
1256  if (fc <= 0)
1257  return;
1258 
1259  ps = rpmtsProblems(ts);
1260  for (i = 0; i < ts->filesystemCount; i++, dsi++) {
1261 
1262  if (dsi->f_bavail > 0 && adj_fs_blocks(dsi->bneeded) > dsi->f_bavail) {
1263  if (dsi->bneeded != dsi->obneeded) {
1265  rpmteNEVR(te), rpmteKey(te),
1266  ts->filesystems[i], NULL, NULL,
1267  (adj_fs_blocks(dsi->bneeded) - dsi->f_bavail) * dsi->f_bsize);
1268  dsi->obneeded = dsi->bneeded;
1269  }
1270  }
1271 
1272  if (dsi->f_favail > 0 && adj_fs_blocks(dsi->ineeded) > dsi->f_favail) {
1273  if (dsi->ineeded != dsi->oineeded) {
1275  rpmteNEVR(te), rpmteKey(te),
1276  ts->filesystems[i], NULL, NULL,
1277  (adj_fs_blocks(dsi->ineeded) - dsi->f_favail));
1278  dsi->oineeded = dsi->ineeded;
1279  }
1280  }
1281 
1282  if ((dsi->bneeded || dsi->ineeded) && (dsi->f_flag & ST_RDONLY)) {
1284  rpmteNEVR(te), rpmteKey(te),
1285  ts->filesystems[i], NULL, NULL, 0);
1286  }
1287  }
1288  ps = rpmpsFree(ps);
1289 }
1290 
1291 void * rpmtsNotify(rpmts ts, rpmte te,
1292  rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
1293 {
1294  void * ptr = NULL;
1295  if (ts && ts->notify) {
1296  Header h;
1297  fnpyKey cbkey;
1298  /*@-type@*/ /* FIX: cast? */
1299  /*@-noeffectuncon @*/ /* FIX: check rc */
1300  if (te) {
1301 /*@-castexpose -mods@*/ /* XXX noisy in transaction.c */
1302  h = headerLink(te->h);
1303 /*@=castexpose =mods@*/
1304  cbkey = rpmteKey(te);
1305  } else {
1306  h = NULL;
1307  cbkey = NULL;
1308  }
1309  ptr = ts->notify(h, what, amount, total, cbkey, ts->notifyData);
1310  (void)headerFree(h);
1311  h = NULL;
1312  /*@=noeffectuncon @*/
1313  /*@=type@*/
1314  }
1315  return ptr;
1316 }
1317 
1319 {
1320  int nelements = 0;
1321  if (ts != NULL && ts->order != NULL) {
1322  nelements = ts->orderCount;
1323  }
1324  return nelements;
1325 }
1326 
1328 {
1329  rpmte te = NULL;
1330  if (ts != NULL && ts->order != NULL) {
1331  if (ix >= 0 && ix < ts->orderCount)
1332  te = ts->order[ix];
1333  }
1334  /*@-compdef@*/
1335  return te;
1336  /*@=compdef@*/
1337 }
1338 
1340 {
1341  return (rpmprobFilterFlags) (ts != NULL ? ts->ignoreSet : 0);
1342 }
1343 
1345 {
1346  rpmtransFlags transFlags = (rpmtransFlags)0;
1347  if (ts != NULL) {
1348  transFlags = ts->transFlags;
1349  if (rpmtsSELinuxEnabled(ts) > 0)
1350  transFlags = (rpmtransFlags)(transFlags & ~RPMTRANS_FLAG_NOCONTEXTS);
1351  else
1352  transFlags = (rpmtransFlags)(transFlags | RPMTRANS_FLAG_NOCONTEXTS);
1353  }
1354  return transFlags;
1355 }
1356 
1358 {
1359  rpmtransFlags otransFlags = (rpmtransFlags) 0;
1360  if (ts != NULL) {
1361  otransFlags = ts->transFlags;
1362  if (rpmtsSELinuxEnabled(ts) > 0)
1363  transFlags = (rpmtransFlags)
1364  (transFlags & ~RPMTRANS_FLAG_NOCONTEXTS);
1365  else
1366  transFlags = (rpmtransFlags)
1367  (transFlags | RPMTRANS_FLAG_NOCONTEXTS);
1368  ts->transFlags = transFlags;
1369  }
1370  return otransFlags;
1371 }
1372 
1374 {
1375  return (rpmdepFlags) (ts != NULL ? ts->depFlags : 0);
1376 }
1377 
1379 {
1380  rpmdepFlags odepFlags = (rpmdepFlags) 0;
1381  if (ts != NULL) {
1382  odepFlags = ts->depFlags;
1383  ts->depFlags = depFlags;
1384  }
1385  return odepFlags;
1386 }
1387 
1389 {
1390 /*@-compdef -retexpose -usereleased@*/
1391  return ts->spec;
1392 /*@=compdef =retexpose =usereleased@*/
1393 }
1394 
1396 {
1397  Spec ospec = ts->spec;
1398 /*@-assignexpose -temptrans@*/
1399  ts->spec = spec;
1400 /*@=assignexpose =temptrans@*/
1401  return ospec;
1402 }
1403 
1405 {
1406 /*@-compdef -retexpose -usereleased@*/
1407  return ts->relocateElement;
1408 /*@=compdef =retexpose =usereleased@*/
1409 }
1410 
1412 {
1413  rpmte orelocateElement = ts->relocateElement;
1414 /*@-assignexpose -temptrans@*/
1415  ts->relocateElement = relocateElement;
1416 /*@=assignexpose =temptrans@*/
1417  return orelocateElement;
1418 }
1419 
1421 {
1422  return (ts != NULL ? ts->goal : TSM_UNKNOWN);
1423 }
1424 
1426 {
1427  tsmStage ogoal = TSM_UNKNOWN;
1428  if (ts != NULL) {
1429  ogoal = ts->goal;
1430  ts->goal = goal;
1431  }
1432  return ogoal;
1433 }
1434 
1436 {
1437  return (ts != NULL ? ts->dbmode : 0);
1438 }
1439 
1440 int rpmtsSetDBMode(rpmts ts, int dbmode)
1441 {
1442  int odbmode = 0;
1443  if (ts != NULL) {
1444  odbmode = ts->dbmode;
1445  ts->dbmode = dbmode;
1446  }
1447  return odbmode;
1448 }
1449 
1451 {
1452  return (ts != NULL ? ts->color : 0);
1453 }
1454 
1456 {
1457  rpmuint32_t ocolor = 0;
1458  if (ts != NULL) {
1459  ocolor = ts->color;
1460  ts->color = color;
1461  }
1462  return ocolor;
1463 }
1464 
1466 {
1467  return (ts != NULL ? ts->prefcolor : 0);
1468 }
1469 
1471  rpmCallbackFunction notify, rpmCallbackData notifyData)
1472 {
1473  if (ts != NULL) {
1474  ts->notify = notify;
1475  ts->notifyData = notifyData;
1476  }
1477  return 0;
1478 }
1479 
1481 {
1482  rpmts ts = rpmtsGetPool(_rpmtsPool);
1483  int xx;
1484 
1485  memset(&ts->ops, 0, sizeof(ts->ops));
1486  (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_TOTAL), -1);
1487  ts->type = RPMTRANS_TYPE_NORMAL;
1488  ts->goal = TSM_UNKNOWN;
1489  ts->filesystemCount = 0;
1490  ts->filesystems = NULL;
1491  ts->dsi = NULL;
1492 
1493  ts->solve = rpmtsSolve;
1494  ts->solveData = NULL;
1495  ts->nsuggests = 0;
1496  ts->suggests = NULL;
1497 
1498  ts->PRCO = NULL;
1499 
1500  ts->bag = NULL;
1501 
1502  ts->rdb = NULL;
1503  ts->dbmode = O_RDONLY;
1504  ts->txn = NULL;
1505 
1506  ts->scriptFd = NULL;
1507  { struct timeval tv;
1508  xx = gettimeofday(&tv, NULL);
1509  ts->tid[0] = (rpmuint32_t) tv.tv_sec;
1510  ts->tid[1] = (rpmuint32_t) tv.tv_usec;
1511  }
1512  ts->delta = 5;
1513 
1514  ts->color = rpmExpandNumeric("%{?_transaction_color}");
1515  ts->prefcolor = rpmExpandNumeric("%{?_prefer_color}");
1516  if (!ts->prefcolor) ts->prefcolor = 0x2;
1517 
1518  ts->rbf = NULL;
1519  ts->numRemovedPackages = 0;
1520  ts->allocedRemovedPackages = ts->delta;
1521  ts->removedPackages = (uint32_t *) xcalloc(ts->allocedRemovedPackages,
1522  sizeof(*ts->removedPackages));
1523 
1524  ts->rootDir = NULL;
1525  ts->currDir = NULL;
1526  ts->chrootDone = 0;
1527 
1528  ts->selinuxEnabled = rpmsxEnabled(NULL);
1529 
1530  ts->numAddedPackages = 0;
1531  ts->addedPackages = NULL;
1532 
1533  ts->numErasedPackages = 0;
1534  ts->erasedPackages = NULL;
1535 
1536  ts->numAvailablePackages = 0;
1537  ts->availablePackages = NULL;
1538 
1539  ts->orderAlloced = 0;
1540  ts->orderCount = 0;
1541  ts->order = NULL;
1542  ts->ntrees = 0;
1543  ts->maxDepth = 0;
1544 
1545  ts->probs = NULL;
1546 
1547  ts->keyring = NULL;
1548  ts->hkp = NULL;
1549  ts->dig = NULL;
1550 
1551  /* Set autorollback goal to the end of time. */
1552  ts->arbgoal = 0xffffffff;
1553 
1554  return rpmtsLink(ts, "tsCreate");
1555 }
Spec rpmtsSpec(rpmts ts)
Get spec control structure from transaction set.
Definition: rpmts.c:1388
evrFlags rpmdsFlags(const rpmds ds)
Return current dependency flags.
Definition: rpmds.c:691
const char * str
Definition: rpmtag.h:72
rpmTag tag
Definition: rpmtag.h:504
rpmPRCO rpmdsFreePRCO(rpmPRCO PRCO)
Free dependency set(s) container.
Definition: rpmds.c:2853
rpmtime_t rpmswExit(rpmop op, ssize_t rc)
Exit timed operation.
Definition: rpmsw.c:264
void * rpmtsNotify(rpmts ts, rpmte te, rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
Perform transaction progress notify callback.
Definition: rpmts.c:1291
void *(* rpmCallbackFunction)(const void *h, const rpmCallbackType what, const rpmuint64_t amount, const rpmuint64_t total, fnpyKey key, rpmCallbackData data)
Definition: rpmiotypes.h:419
rpmte rpmteFree(rpmte te)
Destroy a transaction element.
enum urltype_e urltype
Supported URL types.
rpmtime_t usecs
Definition: rpmsw.h:37
OpenPGP constants and structures from RFC-2440.
const char * rpmtsRootDir(rpmts ts)
Get transaction rootDir, i.e.
Definition: rpmts.c:901
rpmte rpmtsElement(rpmts ts, int ix)
Return (ordered) transaction set element.
Definition: rpmts.c:1327
void rpmpsAppend(rpmps ps, rpmProblemType type, const char *pkgNEVR, fnpyKey key, const char *dn, const char *bn, const char *altNEVR, rpmuint64_t ulong1)
Append a problem to current set of problems.
Definition: rpmps.c:123
enum iosmFileAction_e iosmFileAction
File disposition(s) during package install/erase processing.
static void rpmtsPrintStats(rpmts ts)
Definition: rpmts.c:671
Structures used for an "rpmte" transaction element.
char * xstrdup(const char *str)
Definition: rpmmalloc.c:322
rpmuint32_t * ui32p
Definition: rpmtag.h:69
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
Definition: rpmio.c:2833
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
Definition: depends.c:552
char * rpmGetPath(const char *path,...)
Return (malloc&#39;ed) expanded, canonicalized, file path.
Definition: macro.c:3310
#define RPMDBI_QUEUE
Definition: rpmtag.h:492
Structure(s) used for file info tag sets.
enum rpmprobFilterFlags_e rpmprobFilterFlags
int headerGet(Header h, HE_t he, unsigned int flags)
Retrieve extension or tag value from a header.
Definition: header.c:2222
The Header data structure.
#define RPMDBI_REMOVED
Definition: rpmtag.h:484
int rpmtsSetSolveCallback(rpmts ts, int(*solve)(rpmts ts, rpmds key, const void *data), const void *solveData)
Definition: rpmts.c:567
headerSprintfExtension rpmHeaderFormats
Table of query format extensions.
Definition: formats.c:305
rpmtime_t rpmswAdd(rpmop to, rpmop from)
Sum statistic counters.
Definition: rpmsw.c:280
#define R_OK
Definition: system.h:219
int Stat(const char *path, struct stat *st)
stat(2) clone.
Definition: rpmrpc.c:1361
#define RPMDBI_RECNO
Definition: rpmtag.h:493
FD_t fdLink(void *cookie, const char *msg)
static rpmVSFlags vsflags
Definition: rpmcache.c:547
Definition: rpmdb.c:436
int rpmtsSetNotifyCallback(rpmts ts, rpmCallbackFunction notify, rpmCallbackData notifyData)
Set transaction notify callback function and argument.
Definition: rpmts.c:1470
enum rpmCallbackType_e rpmCallbackType
Bit(s) to identify progress callbacks.
Access mounted file system information.
enum rpmTSType_e rpmTSType
Transaction Types.
void addMacro(MacroContext mc, const char *n, const char *o, const char *b, int level)
Add macro to context.
Definition: macro.c:2684
rpmTag rpmdsTagN(const rpmds ds)
Return current dependency type.
Definition: rpmds.c:702
rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
Retrieve operation timestamp from a transaction set.
Definition: pkgio.c:133
int rpmtsSetChrootDone(rpmts ts, int chrootDone)
Set chrootDone flag, i.e.
Definition: rpmts.c:1010
rpmtsi rpmtsiFree(rpmtsi tsi)
Destroy transaction element iterator.
struct rpmtsi_s * rpmtsi
Transaction element iterator.
Definition: rpmte.h:25
rpmTSType rpmtsType(rpmts ts)
Return the type of a transaction.
Definition: rpmts.c:868
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:22
rpmts rpmtsLink(rpmts ts, const char *msg)
Reference a transaction set instance.
int rpmsxEnabled(rpmsx sx)
Return SELinux enabled state.
Definition: rpmsx.c:134
struct rpmds_s * rpmds
Dependency tag sets from a header, so that a header can be discarded early.
Definition: rpmtypes.h:28
rpmPRCO rpmtsPRCO(rpmts ts)
Get transaction set dependencies.
Definition: rpmts.c:1042
struct rpmPRCO_s * rpmPRCO
Container for commonly extracted dependency set(s).
Definition: rpmtypes.h:33
char * headerSprintf(Header h, const char *fmt, headerTagTableEntry tags, headerSprintfExtension exts, errmsg_t *errmsg)
Return formatted output string from header tags.
Definition: hdrfmt.c:6700
int rpmfiFC(rpmfi fi)
Return file count from file info set.
Definition: rpmfi.c:87
struct rpmte_s * rpmte
An element of a transaction set, i.e.
Definition: rpmtypes.h:38
rpmmi rpmmiInit(rpmdb db, rpmTag tag, const void *keyp, size_t keylen)
Return database iterator.
Definition: rpmdb.c:2491
int rpmtsInitDSI(const rpmts ts)
Initialize disk space info for each and every mounted file systems.
Definition: rpmts.c:1065
const char * rpmtsCurrDir(rpmts ts)
Get transaction currDir, i.e.
Definition: rpmts.c:951
char * alloca()
rpmPRCO rpmdsNewPRCO(Header h)
Create dependency set(s) container.
Definition: rpmds.c:2878
rpmop _hdr_getops
Definition: header.c:94
Yet Another syslog(3) API clone.
enum rpmElementType_e rpmElementType
Transaction element type.
rpmuint32_t rpmtsSetTid(rpmts ts, rpmuint32_t tid)
Set transaction id, i.e.
Definition: rpmts.c:1031
rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
Set transaction flags, i.e.
Definition: rpmts.c:1357
unsigned int rpmuint32_t
Definition: rpmiotypes.h:25
struct _HE_s * HE_t
Definition: rpmtag.h:58
void delMacro(MacroContext mc, const char *n)
Delete macro from context.
Definition: macro.c:2723
pgpVSFlags pgpDigVSFlags
Disabler bits(s) for signature/digest checking.
Definition: rpmpgp.c:1105
void rpmtsCleanDig(rpmts ts)
Free signature verification data.
Definition: pkgio.c:457
const char * rpmteNEVR(rpmte te)
Retrieve name-version-release string from transaction element.
Definition: rpmte.c:536
const char * Fstrerror(FD_t fd)
strerror(3) clone.
Definition: rpmio.c:2401
void * xcalloc(size_t nmemb, size_t size)
Definition: rpmmalloc.c:301
void * ptr
Definition: rpmtag.h:66
#define RPMDBI_SEQNO
Definition: rpmtag.h:489
int count
Definition: rpmsw.h:35
int rpmdsSysinfo(rpmPRCO PRCO, const char *fn)
Load sysinfo dependencies into a dependency set.
Definition: rpmds.c:1758
rpmps rpmpsCreate(void)
Create a problem set.
Definition: rpmps.c:61
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
Definition: rpmmalloc.c:221
int rpmGetMacroEntries(MacroContext mc, void *_mire, int used, const char ***avp)
Return macro entries as string array.
Definition: macro.c:319
rpmfi rpmteFI(rpmte te, rpmTag tag)
Retrieve file info tag set from transaction element.
Definition: rpmte.c:587
FD_t fdFree(FD_t fd, const char *msg)
int argvCount(const ARGV_t argv)
Return no.
Definition: argv.c:71
rpmTagData p
Definition: rpmtag.h:507
int rpmtsCloseSDB(rpmts ts)
Close the database used by the transaction to solve dependencies.
Definition: rpmts.c:222
enum rpmdepFlags_e rpmdepFlags
Bit(s) to control rpmtsCheck() and rpmtsOrder() operation.
unsigned long long rpmuint64_t
Definition: rpmiotypes.h:26
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
Definition: argv.c:44
int rpmtsNElements(rpmts ts)
Return number of (ordered) transaction set elements.
Definition: rpmts.c:1318
const char * rpmdsEVR(const rpmds ds)
Return current dependency epoch-version-release.
Definition: rpmds.c:680
const char * tagName(rpmTag tag)
Return tag name from value.
Definition: tagname.c:436
static const char * file
Definition: parseFiles.c:20
int rpmdbOpen(const char *prefix, rpmdb *dbp, int mode, mode_t perms)
Open rpm database.
Definition: rpmdb.c:1175
int rpmioAccess(const char *FN, const char *path, int mode)
Check FN access, expanding relative paths and twiddles.
Definition: rpmio.c:3072
rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char *fn, Header *hdrp)
Return package header from file handle, verifying digests/signatures.
Definition: package.c:428
enum tsStage_e tsmStage
rpmuint32_t rpmtsPrefColor(rpmts ts)
Retrieve preferred file color.
Definition: rpmts.c:1465
Structure(s) used for dependency tag sets.
void rpmteCleanDS(rpmte te)
Destroy dependency set info of transaction element.
Definition: rpmte.c:38
struct tagStore_s * tagStore_t
Definition: rpmtag.h:522
int rpmtsRebuildDB(rpmts ts)
Rebuild the database used by the transaction.
Definition: rpmts.c:136
The FD_t File Handle data structure.
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
Definition: rpmts.c:212
struct rpmdb_s * rpmdb
Database of headers and tag value indices.
Definition: rpmtypes.h:43
int rpmtsChrootDone(rpmts ts)
Get chrootDone flag, i.e.
Definition: rpmts.c:1005
void rpmtsUpdateDSI(const rpmts ts, dev_t dev, rpmuint32_t fileSize, rpmuint32_t prevSize, rpmuint32_t fixupSize, int _action)
Update disk space info for a file.
Definition: rpmts.c:1179
int rpmtsSolve(rpmts ts, rpmds ds, const void *data)
Attempt to solve a needed dependency using the solve database.
Definition: rpmts.c:351
Definition: iosm.h:32
int rpmtsSetKeyring(rpmts ts, void *_keyring)
Set transaction keyring.
Definition: rpmts.c:807
The structure used to store values parsed from a spec file.
Definition: rpmspec.h:108
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
Definition: rpmts.h:30
Header headerFree(Header h)
Dereference a header instance.
static void rpmtsPrintStat(const char *name, struct rpmop_s *op)
Definition: rpmts.c:654
int rpmswEnter(rpmop op, ssize_t rc)
Enter timed operation.
Definition: rpmsw.c:248
char * rpmExpand(const char *arg,...)
Return (malloc&#39;ed) concatenated macro expansion(s).
Definition: macro.c:3117
rpmuint32_t rpmtsARBGoal(rpmts ts)
Return the autorollback goal.
Definition: rpmts.c:879
static rpmts rpmtsGetPool(rpmioPool pool)
Definition: rpmts.c:774
void rpmtsSetARBGoal(rpmts ts, rpmuint32_t goal)
Set autorollback goal.
Definition: rpmts.c:884
int rpmdsAnyMatchesDep(const Header h, const rpmds req, int nopromote)
Compare package provides dependencies from header with a single dependency.
Definition: rpmds.c:4525
void rpmtsSetType(rpmts ts, rpmTSType type)
Set transaction type.
Definition: rpmts.c:873
void rpmtsSetRootDir(rpmts ts, const char *rootDir)
Set transaction rootDir, i.e.
Definition: rpmts.c:925
int rpmtsSetDBMode(rpmts ts, int dbmode)
Set dbmode of transaction set.
Definition: rpmts.c:1440
void rpmtsSetCurrDir(rpmts ts, const char *currDir)
Set transaction currDir, i.e.
Definition: rpmts.c:960
static int sugcmp(const void *a, const void *b)
Compare suggested package resolutions (qsort/bsearch).
Definition: rpmts.c:343
const char * rpmdsN(const rpmds ds)
Return current dependency name.
Definition: rpmds.c:668
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
int Fclose(FD_t fd)
fclose(3) clone.
Definition: rpmio.c:2534
Cumulative statistics for an operation.
Definition: rpmsw.h:33
#define RPMDBI_DEPCACHE
Definition: rpmtag.h:481
rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
Return next transaction element of type.
Definition: rpmte.c:831
void argvPrint(const char *msg, ARGV_t argv, FILE *fp)
Print argv array elements.
Definition: argv.c:19
Spec rpmtsSetSpec(rpmts ts, Spec spec)
Set a spec control structure in transaction set.
Definition: rpmts.c:1395
rpmps rpmpsFree(rpmps ps)
Destroy a problem set.
Header headerLink(Header h)
Reference a header instance.
int _rpmts_debug
Definition: rpmts.c:93
rpmte rpmtsRelocateElement(rpmts ts)
Get current relocate transaction element.
Definition: rpmts.c:1404
void * rpmCallbackData
Definition: rpmiotypes.h:149
rpmdb rpmtsGetRdb(rpmts ts)
Get transaction set database handle.
Definition: pkgio.c:151
fnpyKey rpmteKey(rpmte te)
Retrieve key from transaction element.
Definition: rpmte.c:568
enum rpmRC_e rpmRC
RPM return codes.
void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
Check a transaction element for disk space problems.
Definition: rpmts.c:1242
int Ferror(FD_t fd)
ferror(3) clone.
Definition: rpmio.c:2944
Definition: rpmtag.h:503
rpmuint32_t rpmtsColor(rpmts ts)
Retrieve color bits of transaction set.
Definition: rpmts.c:1450
#define RPMDBI_BTREE
Definition: rpmtag.h:490
rpmop _hdr_loadops
Definition: header.c:90
int _rpmts_stats
Definition: rpmts.c:96
rpmdepFlags rpmtsDFlags(rpmts ts)
Get dependency flags, i.e.
Definition: rpmts.c:1373
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
Definition: url.c:429
rpmdepFlags rpmtsSetDFlags(rpmts ts, rpmdepFlags depFlags)
Set dependency flags, i.e.
Definition: rpmts.c:1378
Definition: iosm.h:29
dbiIndex dbiOpen(rpmdb db, rpmTag tag, unsigned int flags)
Definition: rpmdb.c:223
rpmts rpmtsCreate(void)
Create an empty transaction set.
Definition: rpmts.c:1480
Methods to handle package elements.
rpmte rpmtsSetRelocateElement(rpmts ts, rpmte relocateElement)
Set current relocate transaction element.
Definition: rpmts.c:1411
rpmioPool rpmioNewPool(const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
Create a memory pool.
Definition: rpmmalloc.c:110
rpmps rpmtsProblems(rpmts ts)
Return current transaction set problems.
Definition: rpmts.c:582
enum rpmtransFlags_e rpmtransFlags
Bit(s) to control rpmtsRun() operation.
int rpmtsOpenSDB(rpmts ts, int dbmode)
Open the database used by the transaction to solve dependencies.
Definition: rpmts.c:252
int _rpmts_macros
Definition: rpmts.c:99
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
Definition: rpmts.c:843
char * stpcpy(char *dest, const char *src)
int rpmGetFilesystemList(const char ***listptr, rpmuint32_t *num)
Return (cached) file system mount points.
Definition: fs.c:294
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:647
const void * fnpyKey
Definition: rpmiotypes.h:118
tsmStage rpmtsGoal(rpmts ts)
Retrieve goal of transaction set.
Definition: rpmts.c:1420
Structures and prototypes used for an "rpmts" transaction set.
Definition: iosm.h:36
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
Definition: rpmdb.c:2248
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
Definition: rpmts.c:838
int argvSplit(ARGV_t *argvp, const char *str, const char *seps)
Split a string into an argv array.
Definition: argv.c:233
int rpmtsUnorderedSuccessors(rpmts ts, int first)
Set index of 1st element of successors.
Definition: rpmts.c:890
#define RPMDBI_AVAILABLE
Definition: rpmtag.h:485
int rpmtsOpenDB(rpmts ts, int dbmode)
Open the database used by the transaction.
Definition: rpmts.c:115
fnpyKey * rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds, alKey *keyp)
Check added package file lists for package(s) that have a provide.
Definition: rpmal.c:391
rpmal rpmalFree(rpmal al)
Destroy available list.
#define RMIL_DEFAULT
Markers for sources of macros added throughout rpm.
Definition: rpmmacro.h:50
unsigned long long bytes
Definition: rpmsw.h:36
void * rpmtsGetKeyring(rpmts ts, int autoload)
Get transaction keyring.
Definition: rpmts.c:790
static const char * name
Structures used for managing added/available package lists.
File state machine to handle archive I/O and system call&#39;s.
rpmprobFilterFlags rpmtsFilterFlags(rpmts ts)
Get problem ignore bit mask, i.e.
Definition: rpmts.c:1339
#define _(Text)
Definition: system.h:30
int rpmtsSELinuxEnabled(rpmts ts)
Get selinuxEnabled flag, i.e.
Definition: rpmts.c:997
rpmps rpmpsLink(rpmps ps, const char *msg)
Reference a problem set instance.
rpmuint32_t rpmtsGetTid(rpmts ts)
Get transaction id, i.e.
Definition: rpmts.c:1022
rpmtsi rpmtsiInit(rpmts ts)
Create transaction element iterator.
ARGstr_t * ARGV_t
Definition: argv.h:9
Access RPM indices using Berkeley DB interface(s).
enum rpmTag_e rpmTag
Definition: rpmtag.h:471
int rpmdbClose(rpmdb db)
Close all database indices and free rpmdb.
Definition: rpmdb.c:866
#define D_(Text)
Definition: system.h:485
rpmioPool _rpmtsPool
Definition: rpmts.c:772
rpmtransFlags rpmtsFlags(rpmts ts)
Get transaction flags, i.e.
Definition: rpmts.c:1344
int rpmtsDBMode(rpmts ts)
Retrieve dbmode of transaction set.
Definition: rpmts.c:1435
rpmuint32_t rpmtsSetColor(rpmts ts, rpmuint32_t color)
Set color bits of transaction set.
Definition: rpmts.c:1455
int rpmtsCloseDB(rpmts ts)
Close the database used by the transaction.
Definition: rpmts.c:101
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
Definition: macro.c:3191
#define RPMDBI_HASH
Definition: rpmtag.h:491
static void rpmtsFini(void *_ts)
Definition: rpmts.c:707
void rpmtsSetScriptFd(rpmts ts, FD_t scriptFd)
Definition: rpmts.c:980
#define RPMDBI_PACKAGES
Pseudo-tags used by the rpmdb and rpmgi iterator API&#39;s.
Definition: rpmtag.h:480
#define xrealloc
Definition: system.h:36
FD_t rpmtsScriptFd(rpmts ts)
Definition: rpmts.c:969
void rpmtsEmpty(rpmts ts)
Re-create an empty transaction set.
Definition: rpmts.c:623
tsmStage rpmtsSetGoal(rpmts ts, tsmStage goal)
Set goal of transaction set.
Definition: rpmts.c:1425
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.
Definition: rpmts.c:596
int rpmtsAvailable(rpmts ts, const rpmds ds)
Attempt to solve a needed dependency using memory resident tables.
Definition: rpmts.c:543
#define RPMDBI_ADDED
Definition: rpmtag.h:483
#define ST_RDONLY
Definition: iosm.h:33
int Unlink(const char *path)
unlink(2) clone.
Definition: rpmrpc.c:397