rpm  5.4.15
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  qfmt = _free(qfmt); /* coverity #1214095 */
467  goto exit;
468  }
469  str = headerSprintf(bh, qfmt, NULL, rpmHeaderFormats, &errstr);
470  qfmt = _free(qfmt);
471  }
472 
473  (void) headerFree(bh);
474  bh = NULL;
475  if (errstr) {
476  rpmlog(RPMLOG_ERR, _("incorrect solve path format: %s\n"), errstr);
477  goto exit;
478  }
479 
480  if (ts->depFlags & RPMDEPS_FLAG_ADDINDEPS) {
481  FD_t fd;
482  rpmRC rpmrc;
483 
484  fd = Fopen(str, "r.fdio");
485  if (fd == NULL || Ferror(fd)) {
486  rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), str,
487  Fstrerror(fd));
488  if (fd != NULL) {
489  xx = Fclose(fd);
490  fd = NULL;
491  }
492  str = _free(str);
493  goto exit;
494  }
495  rpmrc = rpmReadPackageFile(ts, fd, str, &h);
496  xx = Fclose(fd);
497  switch (rpmrc) {
498  default:
499  str = _free(str);
500  break;
501  case RPMRC_NOTTRUSTED:
502  case RPMRC_NOKEY:
503  case RPMRC_OK:
504  if (h != NULL &&
505  !rpmtsAddInstallElement(ts, h, (fnpyKey)str, 1, NULL))
506  {
507  rpmlog(RPMLOG_DEBUG, D_("Adding: %s\n"), str);
508  rc = -1; /* XXX restart unsatisfiedDepends() */
509  break;
510  }
511  break;
512  }
513  (void)headerFree(h);
514  h = NULL;
515  goto exit;
516  }
517 
518  rpmlog(RPMLOG_DEBUG, D_("Suggesting: %s\n"), str);
519  /* If suggestion is already present, don't bother. */
520  if (ts->suggests != NULL && ts->nsuggests > 0) {
521  if (bsearch(&str, ts->suggests, ts->nsuggests,
522  sizeof(*ts->suggests), sugcmp))
523  {
524  str = _free(str);
525  goto exit;
526  }
527  }
528 
529  /* Add a new (unique) suggestion. */
530  ts->suggests = (const void **) xrealloc(ts->suggests,
531  sizeof(*ts->suggests) * (ts->nsuggests + 2));
532  ts->suggests[ts->nsuggests] = str;
533  ts->nsuggests++;
534  ts->suggests[ts->nsuggests] = NULL;
535 
536  if (ts->nsuggests > 1)
537  qsort(ts->suggests, ts->nsuggests, sizeof(*ts->suggests), sugcmp);
538 
539 exit:
540 if (_rpmts_debug)
541 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));
542  return rc;
543 }
544 
545 int rpmtsAvailable(rpmts ts, const rpmds ds)
546 {
547  fnpyKey * sugkey;
548  int rc = 1; /* assume not found */
549 
550  if (ts->availablePackages == NULL)
551  return rc;
552  sugkey = rpmalAllSatisfiesDepend(ts->availablePackages, ds, NULL);
553  if (sugkey == NULL)
554  return rc;
555 
556  /* XXX no alternatives yet */
557  if (sugkey[0] != NULL) {
558  ts->suggests = (const void **) xrealloc(ts->suggests,
559  sizeof(*ts->suggests) * (ts->nsuggests + 2));
560  ts->suggests[ts->nsuggests] = sugkey[0];
561  sugkey[0] = NULL;
562  ts->nsuggests++;
563  ts->suggests[ts->nsuggests] = NULL;
564  }
565  sugkey = _free(sugkey);
566  return rc;
567 }
568 
570  int (*solve) (rpmts ts, rpmds key, const void * data),
571  const void * solveData)
572 {
573  int rc = 0;
574 
575  if (ts) {
576 /*@-assignexpose -temptrans @*/
577  ts->solve = solve;
578  ts->solveData = solveData;
579 /*@=assignexpose =temptrans @*/
580  }
581  return rc;
582 }
583 
585 {
586  static const char msg[] = "rpmtsProblems";
587  rpmps ps = NULL;
588  if (ts) {
589  if (ts->probs == NULL)
590  ts->probs = rpmpsCreate();
591 /*@-castexpose@*/
592  ps = rpmpsLink(ts->probs, msg);
593 /*@=castexpose@*/
594  }
595  return ps;
596 }
597 
599 {
600  rpmtsi pi; rpmte p;
601 
602  if (ts == NULL)
603  return;
604 
605  /* Clean up after dependency checks. */
606  pi = rpmtsiInit(ts);
607  while ((p = rpmtsiNext(pi, (rpmElementType)0)) != NULL)
608  rpmteCleanDS(p);
609  pi = rpmtsiFree(pi);
610 
611  ts->addedPackages = rpmalFree(ts->addedPackages);
612  ts->numAddedPackages = 0;
613 
614  ts->erasedPackages = rpmalFree(ts->erasedPackages);
615  ts->numErasedPackages = 0;
616 
617  ts->suggests = _free(ts->suggests);
618  ts->nsuggests = 0;
619 
620  ts->probs = rpmpsFree(ts->probs);
621 
622  rpmtsCleanDig(ts);
623 }
624 
626 {
627  rpmtsi pi; rpmte p;
628  int oc;
629 
630  if (ts == NULL)
631  return;
632 
633 /*@-nullstate@*/ /* FIX: partial annotations */
634  rpmtsClean(ts);
635 /*@=nullstate@*/
636 
637  for (pi = rpmtsiInit(ts), oc = 0; (p = rpmtsiNext(pi, (rpmElementType)0)) != NULL; oc++) {
638 /*@-type -unqualifiedtrans @*/
639  ts->order[oc] = rpmteFree(ts->order[oc]);
640 /*@=type =unqualifiedtrans @*/
641  }
642  pi = rpmtsiFree(pi);
643  ts->numAddedFiles = 0;
644  ts->numErasedFiles = 0;
645 
646  ts->orderCount = 0;
647  ts->ntrees = 0;
648  ts->maxDepth = 0;
649 
650  ts->numRemovedPackages = 0;
651 /*@-nullstate@*/ /* FIX: partial annotations */
652  return;
653 /*@=nullstate@*/
654 }
655 
656 static void rpmtsPrintStat(const char * name, /*@null@*/ struct rpmop_s * op)
657  /*@globals fileSystem @*/
658  /*@modifies fileSystem @*/
659 {
660  static unsigned int scale = (1000 * 1000);
661  if (op != NULL && op->count > 0)
662  fprintf(stderr, " %s %8d %6lu.%06lu MB %6lu.%06lu secs\n",
663  name, op->count,
664  (unsigned long)op->bytes/scale, (unsigned long)op->bytes%scale,
665  op->usecs/scale, op->usecs%scale);
666 }
667 
668 /*@unchecked@*/ /*@relnull@*/
669 extern rpmop _hdr_loadops;
670 /*@unchecked@*/ /*@relnull@*/
671 extern rpmop _hdr_getops;
672 
673 static void rpmtsPrintStats(rpmts ts)
674  /*@globals fileSystem, internalState @*/
675  /*@modifies fileSystem, internalState @*/
676 {
677  (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_TOTAL), 0);
678 
679  if (_hdr_loadops)
681  if (_hdr_getops)
683 
684  rpmtsPrintStat("total: ", rpmtsOp(ts, RPMTS_OP_TOTAL));
685  rpmtsPrintStat("check: ", rpmtsOp(ts, RPMTS_OP_CHECK));
686  rpmtsPrintStat("order: ", rpmtsOp(ts, RPMTS_OP_ORDER));
687  rpmtsPrintStat("fingerprint: ", rpmtsOp(ts, RPMTS_OP_FINGERPRINT));
688  rpmtsPrintStat("repackage: ", rpmtsOp(ts, RPMTS_OP_REPACKAGE));
689  rpmtsPrintStat("install: ", rpmtsOp(ts, RPMTS_OP_INSTALL));
690  rpmtsPrintStat("erase: ", rpmtsOp(ts, RPMTS_OP_ERASE));
691  rpmtsPrintStat("scriptlets: ", rpmtsOp(ts, RPMTS_OP_SCRIPTLETS));
692  rpmtsPrintStat("compress: ", rpmtsOp(ts, RPMTS_OP_COMPRESS));
693  rpmtsPrintStat("uncompress: ", rpmtsOp(ts, RPMTS_OP_UNCOMPRESS));
694  rpmtsPrintStat("digest: ", rpmtsOp(ts, RPMTS_OP_DIGEST));
695  rpmtsPrintStat("signature: ", rpmtsOp(ts, RPMTS_OP_SIGNATURE));
696  rpmtsPrintStat("dbadd: ", rpmtsOp(ts, RPMTS_OP_DBADD));
697  rpmtsPrintStat("dbremove: ", rpmtsOp(ts, RPMTS_OP_DBREMOVE));
698  rpmtsPrintStat("dbget: ", rpmtsOp(ts, RPMTS_OP_DBGET));
699  rpmtsPrintStat("dbput: ", rpmtsOp(ts, RPMTS_OP_DBPUT));
700  rpmtsPrintStat("dbdel: ", rpmtsOp(ts, RPMTS_OP_DBDEL));
701  rpmtsPrintStat("readhdr: ", rpmtsOp(ts, RPMTS_OP_READHDR));
702  rpmtsPrintStat("hdrload: ", rpmtsOp(ts, RPMTS_OP_HDRLOAD));
703  rpmtsPrintStat("hdrget: ", rpmtsOp(ts, RPMTS_OP_HDRGET));
704 /*@-globstate@*/
705  return;
706 /*@=globstate@*/
707 }
708 
709 static void rpmtsFini(void * _ts)
710  /*@modifies _ts @*/
711 {
712  rpmts ts = (rpmts) _ts;
713 
714 /*@-nullstate@*/ /* FIX: partial annotations */
715  /* XXX there's a recursion here ... release and reacquire the lock */
716 #ifndef BUGGY
717  yarnRelease(ts->_item.use); /* XXX hack-o-round */
718 #endif
719  rpmtsEmpty(ts);
720 #ifndef BUGGY
721  yarnPossess(ts->_item.use); /* XXX hack-o-round */
722 #endif
723 /*@=nullstate@*/
724 
725  ts->PRCO = rpmdsFreePRCO(ts->PRCO);
726 
727  (void) rpmtsCloseDB(ts);
728 assert(ts->txn == NULL); /* XXX FIXME */
729  ts->txn = NULL;
730 
731  (void) rpmtsCloseSDB(ts);
732 
733  (void) rpmbfFree(ts->rbf);
734  ts->rbf = NULL;
735  ts->removedPackages = _free(ts->removedPackages);
736 
737  ts->availablePackages = rpmalFree(ts->availablePackages);
738  ts->numAvailablePackages = 0;
739 
740  ts->dsi = _free(ts->dsi);
741 
742  if (ts->scriptFd != NULL) {
743 /*@-refcounttrans@*/ /* FIX: XfdFree annotation */
744  ts->scriptFd = fdFree(ts->scriptFd, __FUNCTION__);
745 /*@=refcounttrans@*/
746  ts->scriptFd = NULL;
747  }
748  ts->rootDir = _free(ts->rootDir);
749  ts->currDir = _free(ts->currDir);
750 
751 /*@-type +voidabstract @*/ /* FIX: double indirection */
752  ts->order = _free(ts->order);
753 /*@=type =voidabstract @*/
754  ts->orderAlloced = 0;
755 
756  ts->keyring = rpmKeyringFree(ts->keyring);
757  (void) rpmhkpFree(ts->hkp);
758  ts->hkp = NULL;
759 
760  if (_rpmts_stats)
761  rpmtsPrintStats(ts);
762 
763  if (_rpmts_macros) {
764  const char ** av = NULL;
765 /*@-globs@*/ /* Avoid rpmGlobalMcroContext et al. */
766  (void)rpmGetMacroEntries(NULL, NULL, 1, &av);
767 /*@=globs@*/
768  argvPrint("macros used", av, NULL);
769  av = argvFree(av);
770  }
771 }
772 
773 /*@unchecked@*/ /*@only@*/ /*@null@*/
775 
776 static rpmts rpmtsGetPool(/*@null@*/ rpmioPool pool)
777  /*@globals _rpmtsPool, fileSystem, internalState @*/
778  /*@modifies pool, _rpmtsPool, fileSystem, internalState @*/
779 {
780  rpmts ts;
781 
782  if (_rpmtsPool == NULL) {
783  _rpmtsPool = rpmioNewPool("ts", sizeof(*ts), -1, _rpmts_debug,
784  NULL, NULL, rpmtsFini);
785  pool = _rpmtsPool;
786  }
787  ts = (rpmts) rpmioGetPool(pool, sizeof(*ts));
788  memset(((char *)ts)+sizeof(ts->_item), 0, sizeof(*ts)-sizeof(ts->_item));
789  return ts;
790 }
791 
792 void * rpmtsGetKeyring(rpmts ts, /*@unused@*/ int autoload)
793 {
794  rpmKeyring keyring = NULL;
795  if (ts) {
796 #ifdef NOTYET
797  if (ts->keyring == NULL && autoload)
798  loadKeyring(ts);
799  keyring = rpmKeyringLink(ts->keyring);
800 #else
801  keyring = ts->keyring;
802 #endif
803  }
804 /*@-refcounttrans@*/
805  return (void *)keyring;
806 /*@=refcounttrans@*/
807 }
808 
809 int rpmtsSetKeyring(rpmts ts, void * _keyring)
810 {
811  rpmKeyring keyring = (rpmKeyring) _keyring;
812 
813  if (ts == NULL)
814  return -1;
815 
816 #ifdef NOTYET
817  /*
818  * Should we permit switching keyring on the fly? For now, require
819  * rpmdb isn't open yet (fairly arbitrary limitation)...
820  */
821  if (rpmtsGetRdb(ts) != NULL)
822  return -1;
823 #endif
824 
825 /*@-modnomods@*/
826  ts->keyring = rpmKeyringFree(ts->keyring);
827 /*@=modnomods@*/
828 
829 #ifdef NOTYET
830  ts->keyring = rpmKeyringLink(keyring);
831 #else
832 /*@-assignexpose -newreftrans @*/
833 /*@i@*/ ts->keyring = keyring;
834 /*@=assignexpose =newreftrans @*/
835 #endif
836 
837  return 0;
838 }
839 
840 rpmVSFlags rpmtsVSFlags(/*@unused@*/ rpmts ts)
841 {
842  return pgpDigVSFlags;
843 }
844 
846  /*@globals pgpDigVSFlags @*/
847  /*@modifies pgpDigVSFlags @*/
848 {
849  rpmVSFlags ovsflags;
850  ovsflags = pgpDigVSFlags;
852  return ovsflags;
853 }
854 
855 /*
856  * This allows us to mark transactions as being of a certain type.
857  * The three types are:
858  *
859  * RPM_TRANS_NORMAL
860  * RPM_TRANS_ROLLBACK
861  * RPM_TRANS_AUTOROLLBACK
862  *
863  * ROLLBACK and AUTOROLLBACK transactions should always be ran as
864  * a best effort. In particular this is important to the autorollback
865  * feature to avoid rolling back a rollback (otherwise known as
866  * dueling rollbacks (-;). AUTOROLLBACK's additionally need instance
867  * counts passed to scriptlets to be altered.
868  */
869 /* Let them know what type of transaction we are */
871 {
872  return (rpmTSType) ((ts != NULL) ? ts->type : 0);
873 }
874 
876 {
877  if (ts != NULL)
878  ts->type = type;
879 }
880 
882 {
883  return ((ts != NULL) ? ts->arbgoal : 0);
884 }
885 
887 {
888  if (ts != NULL)
889  ts->arbgoal = goal;
890 }
891 
892 int rpmtsUnorderedSuccessors(rpmts ts, int first)
893 {
894  int unorderedSuccessors = 0;
895  if (ts != NULL) {
896  unorderedSuccessors = ts->unorderedSuccessors;
897  if (first >= 0)
898  ts->unorderedSuccessors = first;
899  }
900  return unorderedSuccessors;
901 }
902 
903 const char * rpmtsRootDir(rpmts ts)
904 {
905  const char * rootDir = NULL;
906 
907  if (ts != NULL && ts->rootDir != NULL) {
908  urltype ut = urlPath(ts->rootDir, &rootDir);
909  switch (ut) {
910  case URL_IS_UNKNOWN:
911  case URL_IS_PATH:
912  break;
913  case URL_IS_DASH:
914  case URL_IS_HKP:
915  case URL_IS_FTP:
916  case URL_IS_HTTP:
917  case URL_IS_HTTPS:
918  case URL_IS_MONGO: /* XXX FIXME */
919  default:
920  rootDir = "/";
921  break;
922  }
923  }
924  return rootDir;
925 }
926 
927 void rpmtsSetRootDir(rpmts ts, const char * rootDir)
928 {
929  if (ts != NULL) {
930  size_t rootLen;
931 
932  ts->rootDir = _free(ts->rootDir);
933 
934  if (rootDir == NULL) {
935 #ifdef DYING
936  ts->rootDir = xstrdup("");
937 #endif
938  return;
939  }
940  rootLen = strlen(rootDir);
941 
942  /* Make sure that rootDir has trailing / */
943  if (!(rootLen && rootDir[rootLen - 1] == '/')) {
944  char * t = (char *) alloca(rootLen + 2);
945  *t = '\0';
946  (void) stpcpy( stpcpy(t, rootDir), "/");
947  rootDir = t;
948  }
949  ts->rootDir = xstrdup(rootDir);
950  }
951 }
952 
953 const char * rpmtsCurrDir(rpmts ts)
954 {
955  const char * currDir = NULL;
956  if (ts != NULL) {
957  currDir = ts->currDir;
958  }
959  return currDir;
960 }
961 
962 void rpmtsSetCurrDir(rpmts ts, const char * currDir)
963 {
964  if (ts != NULL) {
965  ts->currDir = _free(ts->currDir);
966  if (currDir)
967  ts->currDir = xstrdup(currDir);
968  }
969 }
970 
972 {
973  FD_t scriptFd = NULL;
974  if (ts != NULL) {
975  scriptFd = ts->scriptFd;
976  }
977 /*@-compdef -refcounttrans -usereleased@*/
978  return scriptFd;
979 /*@=compdef =refcounttrans =usereleased@*/
980 }
981 
982 void rpmtsSetScriptFd(rpmts ts, FD_t scriptFd)
983 {
984 
985  if (ts != NULL) {
986  if (ts->scriptFd != NULL) {
987 /*@-assignexpose@*/
988  ts->scriptFd = fdFree(ts->scriptFd, "rpmtsSetScriptFd");
989 /*@=assignexpose@*/
990  ts->scriptFd = NULL;
991  }
992 /*@-assignexpose -castexpose @*/
993  if (scriptFd != NULL)
994  ts->scriptFd = fdLink((void *)scriptFd, "rpmtsSetScriptFd");
995 /*@=assignexpose =castexpose @*/
996  }
997 }
998 
1000 {
1001  int selinuxEnabled = 0;
1002  if (ts)
1003  selinuxEnabled = (ts->selinuxEnabled > 0);
1004  return selinuxEnabled;
1005 }
1006 
1008 {
1009  return (ts != NULL ? ts->chrootDone : 0);
1010 }
1011 
1012 int rpmtsSetChrootDone(rpmts ts, int chrootDone)
1013 {
1014  int ochrootDone = 0;
1015  if (ts != NULL) {
1016  ochrootDone = ts->chrootDone;
1017  if (ts->rdb != NULL)
1018  ts->rdb->db_chrootDone = chrootDone;
1019  ts->chrootDone = chrootDone;
1020  }
1021  return ochrootDone;
1022 }
1023 
1025 {
1026  rpmuint32_t tid = 0; /* XXX -1 is time(2) error return. */
1027  if (ts != NULL) {
1028  tid = ts->tid[0];
1029  }
1030  return tid;
1031 }
1032 
1034 {
1035  rpmuint32_t otid = 0; /* XXX -1 is time(2) error return. */
1036  if (ts != NULL) {
1037  otid = ts->tid[0];
1038  ts->tid[0] = tid;
1039  ts->tid[1] = 0;
1040  }
1041  return otid;
1042 }
1043 
1045 {
1046  rpmPRCO PRCO = NULL;
1047 
1048  if (ts != NULL) {
1049  static int oneshot = 0;
1050  if (!oneshot) {
1051  const char * fn = rpmGetPath("%{?_rpmds_sysinfo_path}", NULL);
1052  int xx;
1053 
1054  ts->PRCO = rpmdsNewPRCO(NULL);
1055  if (fn && *fn != '\0' && !rpmioAccess(fn, NULL, R_OK))
1056  xx = rpmdsSysinfo(ts->PRCO, NULL);
1057  fn = _free(fn);
1058  oneshot++;
1059  }
1060  PRCO = ts->PRCO;
1061  }
1062 /*@-compdef -retexpose -usereleased @*/
1063  return PRCO;
1064 /*@=compdef =retexpose =usereleased @*/
1065 }
1066 
1067 int rpmtsInitDSI(const rpmts ts)
1068 {
1069  rpmDiskSpaceInfo dsi;
1070  struct stat sb;
1071  int rc;
1072  size_t i;
1073 
1075  return 0;
1076  if (ts->filesystems != NULL)
1077  return 0;
1078 
1079  rpmlog(RPMLOG_DEBUG, D_("mounted filesystems:\n"));
1081  D_(" i dev bsize bavail iavail mount point\n"));
1082 
1083  rc = rpmGetFilesystemList(&ts->filesystems, &ts->filesystemCount);
1084  if (rc || ts->filesystems == NULL || ts->filesystemCount == 0)
1085  return rc;
1086 
1087  /* Get available space on mounted file systems. */
1088 
1089  ts->dsi = _free(ts->dsi);
1090  ts->dsi = (rpmDiskSpaceInfo) xcalloc((ts->filesystemCount + 1), sizeof(*ts->dsi));
1091 
1092  dsi = ts->dsi;
1093 
1094  if (dsi != NULL)
1095  for (i = 0; (i < ts->filesystemCount) && dsi; i++, dsi++) {
1096 #if STATFS_IN_SYS_STATVFS
1097  struct statvfs sfb;
1098  memset(&sfb, 0, sizeof(sfb));
1099  rc = statvfs(ts->filesystems[i], &sfb);
1100 #else
1101  struct statfs sfb;
1102  memset(&sfb, 0, sizeof(sfb));
1103 # if STAT_STATFS4
1104 /* This platform has the 4-argument version of the statfs call. The last two
1105  * should be the size of struct statfs and 0, respectively. The 0 is the
1106  * filesystem type, and is always 0 when statfs is called on a mounted
1107  * filesystem, as we're doing.
1108  */
1109  rc = statfs(ts->filesystems[i], &sfb, sizeof(sfb), 0);
1110 # else
1111  rc = statfs(ts->filesystems[i], &sfb);
1112 # endif
1113 #endif
1114  if (rc)
1115  break;
1116 
1117  rc = stat(ts->filesystems[i], &sb);
1118  if (rc)
1119  break;
1120  dsi->dev = sb.st_dev;
1121 /* XXX figger out how to get this info for non-statvfs systems. */
1122 #if STATFS_IN_SYS_STATVFS
1123  dsi->f_frsize = sfb.f_frsize;
1124 #if defined(RPM_OS_AIX)
1125  dsi->f_fsid = 0; /* sfb.f_fsid is a structure on AIX */
1126 #else
1127  dsi->f_fsid = sfb.f_fsid;
1128 #endif
1129  dsi->f_flag = sfb.f_flag;
1130  dsi->f_favail = (long long) sfb.f_favail;
1131  dsi->f_namemax = sfb.f_namemax;
1132 #elif defined(__APPLE__) && defined(__MACH__) && !defined(_SYS_STATVFS_H_)
1133  dsi->f_fsid = 0; /* "Not meaningful in this implementation." */
1134  dsi->f_namemax = pathconf(ts->filesystems[i], _PC_NAME_MAX);
1135 #elif defined(__OpenBSD__)
1136  dsi->f_fsid = 0; /* sfb.f_fsid is a structure on OpenBSD */
1137  dsi->f_namemax = pathconf(ts->filesystems[i], _PC_NAME_MAX);
1138 #else
1139  dsi->f_fsid = sfb.f_fsid;
1140  dsi->f_namemax = sfb.f_namelen;
1141 #endif
1142 
1143  dsi->f_bsize = sfb.f_bsize;
1144  dsi->f_blocks = (unsigned long long)sfb.f_blocks;
1145  dsi->f_bfree = (unsigned long long)sfb.f_bfree;
1146  dsi->f_files = (unsigned long long)sfb.f_files;
1147  dsi->f_ffree = (unsigned long long)sfb.f_ffree;
1148 
1149  dsi->bneeded = 0;
1150  dsi->ineeded = 0;
1151 #ifdef STATFS_HAS_F_BAVAIL
1152  dsi->f_bavail = (long long)(sfb.f_bavail ? sfb.f_bavail : 1);
1153  if (sfb.f_ffree > 0 && sfb.f_files > 0 && sfb.f_favail > 0)
1154  dsi->f_favail = (long long)sfb.f_favail;
1155  else /* XXX who knows what evil lurks here? */
1156  dsi->f_favail = !(sfb.f_ffree == 0 && sfb.f_files == 0)
1157  ? (signed long long) sfb.f_ffree : -1;
1158 #else
1159 /* FIXME: the statfs struct doesn't have a member to tell how many blocks are
1160  * available for non-superusers. f_blocks - f_bfree is probably too big, but
1161  * it's about all we can do.
1162  */
1163  dsi->f_bavail = sfb.f_blocks - sfb.f_bfree;
1164  /* XXX Avoid FAT and other file systems that have not inodes. */
1165  dsi->f_favail = !(sfb.f_ffree == 0 && sfb.f_files == 0)
1166  ? sfb.f_ffree : -1;
1167 #endif
1168 
1169 #if !defined(ST_RDONLY)
1170 #define ST_RDONLY 1
1171 #endif
1172  rpmlog(RPMLOG_DEBUG, "%5u 0x%08x %8u %12ld %12ld %s %s\n",
1173  (unsigned)i, (unsigned) dsi->dev, (unsigned) dsi->f_bsize,
1174  (signed long) dsi->f_bavail, (signed long) dsi->f_favail,
1175  ((dsi->f_flag & ST_RDONLY) ? "ro" : "rw"),
1176  ts->filesystems[i]);
1177  }
1178  return rc;
1179 }
1180 
1181 void rpmtsUpdateDSI(const rpmts ts, dev_t dev,
1182  rpmuint32_t fileSize, rpmuint32_t prevSize, rpmuint32_t fixupSize,
1183  int _action)
1184 {
1185  iosmFileAction action = (iosmFileAction) _action;
1186  rpmDiskSpaceInfo dsi;
1187  rpmuint64_t bneeded;
1188 
1189  dsi = ts->dsi;
1190  if (dsi) {
1191  while (dsi->f_bsize && dsi->dev != dev)
1192  dsi++;
1193  if (dsi->f_bsize == 0)
1194  dsi = NULL;
1195  }
1196  if (dsi == NULL)
1197  return;
1198 
1199  bneeded = BLOCK_ROUND(fileSize, dsi->f_bsize);
1200 
1201  switch (action) {
1202  case FA_BACKUP:
1203  case FA_SAVE:
1204  case FA_ALTNAME:
1205  dsi->ineeded++;
1206  dsi->bneeded += bneeded;
1207  /*@switchbreak@*/ break;
1208 
1209  /*
1210  * FIXME: If two packages share a file (same md5sum), and
1211  * that file is being replaced on disk, will dsi->bneeded get
1212  * adjusted twice? Quite probably!
1213  */
1214  case FA_CREATE:
1215  dsi->bneeded += bneeded;
1216  dsi->bneeded -= BLOCK_ROUND(prevSize, dsi->f_bsize);
1217  /*@switchbreak@*/ break;
1218 
1219  case FA_ERASE:
1220  dsi->ineeded--;
1221  dsi->bneeded -= bneeded;
1222  /*@switchbreak@*/ break;
1223 
1224  default:
1225  /*@switchbreak@*/ break;
1226  }
1227 
1228  if (fixupSize)
1229  dsi->bneeded -= BLOCK_ROUND(fixupSize, dsi->f_bsize);
1230 }
1231 
1232 void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
1233 {
1234  rpmDiskSpaceInfo dsi;
1235  rpmps ps;
1236  int fc;
1237  size_t i;
1238 
1239  if (ts->filesystems == NULL || ts->filesystemCount == 0)
1240  return;
1241 
1242  dsi = ts->dsi;
1243  if (dsi == NULL)
1244  return;
1245  fc = rpmfiFC( rpmteFI(te, RPMTAG_BASENAMES) );
1246  if (fc <= 0)
1247  return;
1248 
1249  ps = rpmtsProblems(ts);
1250  for (i = 0; i < ts->filesystemCount; i++, dsi++) {
1251 
1252  if (dsi->f_bavail > 0 && adj_fs_blocks(dsi->bneeded) > dsi->f_bavail) {
1253  if (dsi->bneeded != dsi->obneeded) {
1255  rpmteNEVR(te), rpmteKey(te),
1256  ts->filesystems[i], NULL, NULL,
1257  (adj_fs_blocks(dsi->bneeded) - dsi->f_bavail) * dsi->f_bsize);
1258  dsi->obneeded = dsi->bneeded;
1259  }
1260  }
1261 
1262  if (dsi->f_favail > 0 && adj_fs_blocks(dsi->ineeded) > dsi->f_favail) {
1263  if (dsi->ineeded != dsi->oineeded) {
1265  rpmteNEVR(te), rpmteKey(te),
1266  ts->filesystems[i], NULL, NULL,
1267  (adj_fs_blocks(dsi->ineeded) - dsi->f_favail));
1268  dsi->oineeded = dsi->ineeded;
1269  }
1270  }
1271 
1272  if ((dsi->bneeded || dsi->ineeded) && (dsi->f_flag & ST_RDONLY)) {
1274  rpmteNEVR(te), rpmteKey(te),
1275  ts->filesystems[i], NULL, NULL, 0);
1276  }
1277  }
1278  ps = rpmpsFree(ps);
1279 }
1280 
1281 void * rpmtsNotify(rpmts ts, rpmte te,
1282  rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
1283 {
1284  void * ptr = NULL;
1285  if (ts && ts->notify) {
1286  Header h;
1287  fnpyKey cbkey;
1288  /*@-type@*/ /* FIX: cast? */
1289  /*@-noeffectuncon @*/ /* FIX: check rc */
1290  if (te) {
1291 /*@-castexpose -mods@*/ /* XXX noisy in transaction.c */
1292  h = headerLink(te->h);
1293 /*@=castexpose =mods@*/
1294  cbkey = rpmteKey(te);
1295  } else {
1296  h = NULL;
1297  cbkey = NULL;
1298  }
1299  ptr = ts->notify(h, what, amount, total, cbkey, ts->notifyData);
1300  (void)headerFree(h);
1301  h = NULL;
1302  /*@=noeffectuncon @*/
1303  /*@=type@*/
1304  }
1305  return ptr;
1306 }
1307 
1309 {
1310  int nelements = 0;
1311  if (ts != NULL && ts->order != NULL) {
1312  nelements = ts->orderCount;
1313  }
1314  return nelements;
1315 }
1316 
1318 {
1319  rpmte te = NULL;
1320  if (ts != NULL && ts->order != NULL) {
1321  if (ix >= 0 && ix < ts->orderCount)
1322  te = ts->order[ix];
1323  }
1324  /*@-compdef@*/
1325  return te;
1326  /*@=compdef@*/
1327 }
1328 
1330 {
1331  return (rpmprobFilterFlags) (ts != NULL ? ts->ignoreSet : 0);
1332 }
1333 
1335 {
1336  rpmtransFlags transFlags = (rpmtransFlags)0;
1337  if (ts != NULL) {
1338  transFlags = ts->transFlags;
1339  if (rpmtsSELinuxEnabled(ts) > 0)
1340  transFlags = (rpmtransFlags)(transFlags & ~RPMTRANS_FLAG_NOCONTEXTS);
1341  else
1342  transFlags = (rpmtransFlags)(transFlags | RPMTRANS_FLAG_NOCONTEXTS);
1343  }
1344  return transFlags;
1345 }
1346 
1348 {
1349  rpmtransFlags otransFlags = (rpmtransFlags) 0;
1350  if (ts != NULL) {
1351  otransFlags = ts->transFlags;
1352  if (rpmtsSELinuxEnabled(ts) > 0)
1353  transFlags = (rpmtransFlags)
1354  (transFlags & ~RPMTRANS_FLAG_NOCONTEXTS);
1355  else
1356  transFlags = (rpmtransFlags)
1357  (transFlags | RPMTRANS_FLAG_NOCONTEXTS);
1358  ts->transFlags = transFlags;
1359  }
1360  return otransFlags;
1361 }
1362 
1364 {
1365  return (rpmdepFlags) (ts != NULL ? ts->depFlags : 0);
1366 }
1367 
1369 {
1370  rpmdepFlags odepFlags = (rpmdepFlags) 0;
1371  if (ts != NULL) {
1372  odepFlags = ts->depFlags;
1373  ts->depFlags = depFlags;
1374  }
1375  return odepFlags;
1376 }
1377 
1379 {
1380 /*@-compdef -retexpose -usereleased@*/
1381  return ts->spec;
1382 /*@=compdef =retexpose =usereleased@*/
1383 }
1384 
1386 {
1387  Spec ospec = ts->spec;
1388 /*@-assignexpose -temptrans@*/
1389  ts->spec = spec;
1390 /*@=assignexpose =temptrans@*/
1391  return ospec;
1392 }
1393 
1395 {
1396 /*@-compdef -retexpose -usereleased@*/
1397  return ts->relocateElement;
1398 /*@=compdef =retexpose =usereleased@*/
1399 }
1400 
1402 {
1403  rpmte orelocateElement = ts->relocateElement;
1404 /*@-assignexpose -temptrans@*/
1405  ts->relocateElement = relocateElement;
1406 /*@=assignexpose =temptrans@*/
1407  return orelocateElement;
1408 }
1409 
1411 {
1412  return (ts != NULL ? ts->goal : TSM_UNKNOWN);
1413 }
1414 
1416 {
1417  tsmStage ogoal = TSM_UNKNOWN;
1418  if (ts != NULL) {
1419  ogoal = ts->goal;
1420  ts->goal = goal;
1421  }
1422  return ogoal;
1423 }
1424 
1426 {
1427  return (ts != NULL ? ts->dbmode : 0);
1428 }
1429 
1430 int rpmtsSetDBMode(rpmts ts, int dbmode)
1431 {
1432  int odbmode = 0;
1433  if (ts != NULL) {
1434  odbmode = ts->dbmode;
1435  ts->dbmode = dbmode;
1436  }
1437  return odbmode;
1438 }
1439 
1441 {
1442  return (ts != NULL ? ts->color : 0);
1443 }
1444 
1446 {
1447  rpmuint32_t ocolor = 0;
1448  if (ts != NULL) {
1449  ocolor = ts->color;
1450  ts->color = color;
1451  }
1452  return ocolor;
1453 }
1454 
1456 {
1457  return (ts != NULL ? ts->prefcolor : 0);
1458 }
1459 
1461  rpmCallbackFunction notify, rpmCallbackData notifyData)
1462 {
1463  if (ts != NULL) {
1464  ts->notify = notify;
1465  ts->notifyData = notifyData;
1466  }
1467  return 0;
1468 }
1469 
1471 {
1472  rpmts ts = rpmtsGetPool(_rpmtsPool);
1473  int xx;
1474 
1475  memset(&ts->ops, 0, sizeof(ts->ops));
1476  (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_TOTAL), -1);
1477  ts->type = RPMTRANS_TYPE_NORMAL;
1478  ts->goal = TSM_UNKNOWN;
1479  ts->filesystemCount = 0;
1480  ts->filesystems = NULL;
1481  ts->dsi = NULL;
1482 
1483  ts->solve = rpmtsSolve;
1484  ts->solveData = NULL;
1485  ts->nsuggests = 0;
1486  ts->suggests = NULL;
1487 
1488  ts->PRCO = NULL;
1489 
1490  ts->bag = NULL;
1491 
1492  ts->rdb = NULL;
1493  ts->dbmode = O_RDONLY;
1494  ts->txn = NULL;
1495 
1496  ts->scriptFd = NULL;
1497  { struct timeval tv;
1498  xx = gettimeofday(&tv, NULL);
1499  ts->tid[0] = (rpmuint32_t) tv.tv_sec;
1500  ts->tid[1] = (rpmuint32_t) tv.tv_usec;
1501  }
1502  ts->delta = 5;
1503 
1504  ts->color = rpmExpandNumeric("%{?_transaction_color}");
1505  ts->prefcolor = rpmExpandNumeric("%{?_prefer_color}");
1506  if (!ts->prefcolor) ts->prefcolor = 0x2;
1507 
1508  ts->rbf = NULL;
1509  ts->numRemovedPackages = 0;
1510  ts->allocedRemovedPackages = ts->delta;
1511  ts->removedPackages = (uint32_t *) xcalloc(ts->allocedRemovedPackages,
1512  sizeof(*ts->removedPackages));
1513 
1514  ts->rootDir = NULL;
1515  ts->currDir = NULL;
1516  ts->chrootDone = 0;
1517 
1518  ts->selinuxEnabled = rpmsxEnabled(NULL);
1519 
1520  ts->numAddedPackages = 0;
1521  ts->addedPackages = NULL;
1522 
1523  ts->numErasedPackages = 0;
1524  ts->erasedPackages = NULL;
1525 
1526  ts->numAvailablePackages = 0;
1527  ts->availablePackages = NULL;
1528 
1529  ts->orderAlloced = 0;
1530  ts->orderCount = 0;
1531  ts->order = NULL;
1532  ts->ntrees = 0;
1533  ts->maxDepth = 0;
1534 
1535  ts->probs = NULL;
1536 
1537  ts->keyring = NULL;
1538  ts->hkp = NULL;
1539  ts->dig = NULL;
1540 
1541  /* Set autorollback goal to the end of time. */
1542  ts->arbgoal = 0xffffffff;
1543 
1544  return rpmtsLink(ts, "tsCreate");
1545 }
const bson * b
Definition: bson.h:280
Spec rpmtsSpec(rpmts ts)
Get spec control structure from transaction set.
Definition: rpmts.c:1378
evrFlags rpmdsFlags(const rpmds ds)
Return current dependency flags.
Definition: rpmds.c:691
const char * str
Definition: rpmtag.h:73
rpmTag tag
Definition: rpmtag.h:503
rpmPRCO rpmdsFreePRCO(rpmPRCO PRCO)
Free dependency set(s) container.
Definition: rpmds.c:2851
mongo_error_t const char * errstr
Definition: mongo.h:922
rpmtime_t rpmswExit(rpmop op, ssize_t rc)
Exit timed operation.
Definition: rpmsw.c:264
int rpmtxnCheckpoint(rpmdb rpmdb)
Definition: rpmtxn.c:85
void * rpmtsNotify(rpmts ts, rpmte te, rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
Perform transaction progress notify callback.
Definition: rpmts.c:1281
const char bson_timestamp_t * ts
Definition: bson.h:1004
rpmte rpmteFree(rpmte te)
Destroy a transaction element.
enum urltype_e urltype
Supported URL types.
rpmtime_t usecs
Definition: rpmsw.h:43
OpenPGP constants and structures from RFC-2440.
const char * rpmtsRootDir(rpmts ts)
Get transaction rootDir, i.e.
Definition: rpmts.c:903
rpmte rpmtsElement(rpmts ts, int ix)
Return (ordered) transaction set element.
Definition: rpmts.c:1317
void yarnPossess(yarnLock bolt)
Definition: yarn.c:262
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:673
Structures used for an "rpmte" transaction element.
char * xstrdup(const char *str)
Definition: rpmmalloc.c:321
rpmuint32_t * ui32p
Definition: rpmtag.h:70
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
Definition: rpmio.c:2840
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
Definition: depends.c:547
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
Definition: macro.c:3443
#define RPMDBI_QUEUE
Definition: rpmtag.h:491
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:2231
The Header data structure.
#define RPMDBI_REMOVED
Definition: rpmtag.h:483
int rpmtsSetSolveCallback(rpmts ts, int(*solve)(rpmts ts, rpmds key, const void *data), const void *solveData)
Definition: rpmts.c:569
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:234
int Stat(const char *path, struct stat *st)
stat(2) clone.
Definition: rpmrpc.c:1361
#define RPMDBI_RECNO
Definition: rpmtag.h:492
FD_t fdLink(void *cookie, const char *msg)
static rpmVSFlags vsflags
Definition: rpmcache.c:547
Definition: rpmdb.c:436
void * rpmtsFreeLock(void *lock)
Definition: rpmlock.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.
Structure(s) and routine(s) used for classifying and parsing names.
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:2784
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:1012
rpmtsi rpmtsiFree(rpmtsi tsi)
Destroy transaction element iterator.
struct rpmtsi_s * rpmtsi
Transaction element iterator.
Definition: rpmte.h:31
rpmTSType rpmtsType(rpmts ts)
Return the type of a transaction.
Definition: rpmts.c:870
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
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
rpmhkp rpmhkpFree(rpmhkp hkp)
Destroy a hkp handle.
rpmPRCO rpmtsPRCO(rpmts ts)
Get transaction set dependencies.
Definition: rpmts.c:1044
struct rpmPRCO_s * rpmPRCO
Container for commonly extracted dependency set(s).
Definition: rpmtypes.h:33
rpmbag rpmbagNew(const char *fn, int flags)
Create and load a bag wrapper.
Definition: rpmbag.c:57
char * headerSprintf(Header h, const char *fmt, headerTagTableEntry tags, headerSprintfExtension exts, errmsg_t *errmsg)
Return formatted output string from header tags.
Definition: hdrfmt.c:6730
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:2495
int rpmtsInitDSI(const rpmts ts)
Initialize disk space info for each and every mounted file systems.
Definition: rpmts.c:1067
const char * rpmtsCurrDir(rpmts ts)
Get transaction currDir, i.e.
Definition: rpmts.c:953
struct rpmsdb_s * rpmsdb
Definition: rpmbag.h:16
char * alloca()
const char * str
Definition: bson.h:593
rpmPRCO rpmdsNewPRCO(Header h)
Create dependency set(s) container.
Definition: rpmds.c:2876
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:1033
rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
Set transaction flags, i.e.
Definition: rpmts.c:1347
unsigned int rpmuint32_t
Definition: rpmiotypes.h:28
struct _HE_s * HE_t
Definition: rpmtag.h:59
void delMacro(MacroContext mc, const char *n)
Delete macro from context.
Definition: macro.c:2823
pgpVSFlags pgpDigVSFlags
Disabler bits(s) for signature/digest checking.
Definition: rpmpgp.c:1153
void rpmtsCleanDig(rpmts ts)
Free signature verification data.
Definition: pkgio.c:456
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:300
void * ptr
Definition: rpmtag.h:67
#define RPMDBI_SEQNO
Definition: rpmtag.h:488
int count
Definition: rpmsw.h:41
int rpmdsSysinfo(rpmPRCO PRCO, const char *fn)
Load sysinfo dependencies into a dependency set.
Definition: rpmds.c:1756
rpmps rpmpsCreate(void)
Create a problem set.
Definition: rpmps.c:61
rpmbf rpmbfFree(rpmbf bf)
Destroy a Bloom filter.
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
Definition: rpmmalloc.c:220
void *(* rpmCallbackFunction)(const void *h, const rpmCallbackType what, const rpmuint64_t amount, const rpmuint64_t total, fnpyKey key, rpmCallbackData data)
Definition: rpmiotypes.h:528
int rpmGetMacroEntries(MacroContext mc, void *_mire, int used, const char ***avp)
Return macro entries as string array.
Definition: macro.c:321
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 rpmbagDel(rpmbag bag, int i)
Definition: rpmbag.c:83
int argvCount(const ARGV_t argv)
Return no.
Definition: argv.c:71
const char const bson * data
Definition: mongo.h:463
rpmTagData p
Definition: rpmtag.h:506
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:29
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:1308
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:1179
int rpmioAccess(const char *FN, const char *path, int mode)
Check FN access, expanding relative paths and twiddles.
Definition: rpmio.c:3079
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
enum tsStage_e tsmStage
rpmuint32_t rpmtsPrefColor(rpmts ts)
Retrieve preferred file color.
Definition: rpmts.c:1455
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:521
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:1007
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:1181
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:809
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.
static void rpmtsPrintStat(const char *name, struct rpmop_s *op)
Definition: rpmts.c:656
int rpmswEnter(rpmop op, ssize_t rc)
Enter timed operation.
Definition: rpmsw.c:248
const char const bson const bson * op
Definition: mongo.h:505
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
Definition: macro.c:3250
rpmuint32_t rpmtsARBGoal(rpmts ts)
Return the autorollback goal.
Definition: rpmts.c:881
static rpmts rpmtsGetPool(rpmioPool pool)
Definition: rpmts.c:776
void rpmtsSetARBGoal(rpmts ts, rpmuint32_t goal)
Set autorollback goal.
Definition: rpmts.c:886
int rpmdsAnyMatchesDep(const Header h, const rpmds req, int nopromote)
Compare package provides dependencies from header with a single dependency.
Definition: rpmds.c:4228
void rpmtsSetType(rpmts ts, rpmTSType type)
Set transaction type.
Definition: rpmts.c:875
void rpmtsSetRootDir(rpmts ts, const char *rootDir)
Set transaction rootDir, i.e.
Definition: rpmts.c:927
int rpmtsSetDBMode(rpmts ts, int dbmode)
Set dbmode of transaction set.
Definition: rpmts.c:1430
void rpmtsSetCurrDir(rpmts ts, const char *currDir)
Set transaction currDir, i.e.
Definition: rpmts.c:962
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:39
#define RPMDBI_DEPCACHE
Definition: rpmtag.h:480
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
void yarnRelease(yarnLock bolt)
Definition: yarn.c:270
Spec rpmtsSetSpec(rpmts ts, Spec spec)
Set a spec control structure in transaction set.
Definition: rpmts.c:1385
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:1394
void * rpmCallbackData
Definition: rpmiotypes.h:162
rpmdb rpmtsGetRdb(rpmts ts)
Get transaction set database handle.
Definition: pkgio.c:151
int rpmbagAdd(rpmbag bag, void *_db, int dbmode)
Definition: rpmbag.c:70
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:1232
int Ferror(FD_t fd)
ferror(3) clone.
Definition: rpmio.c:2951
Definition: rpmtag.h:502
rpmuint32_t rpmtsColor(rpmts ts)
Retrieve color bits of transaction set.
Definition: rpmts.c:1440
const char const int i
Definition: bson.h:778
#define RPMDBI_BTREE
Definition: rpmtag.h:489
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:1363
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
Definition: url.c:430
const char const bson * key
Definition: mongo.h:717
rpmdepFlags rpmtsSetDFlags(rpmts ts, rpmdepFlags depFlags)
Set dependency flags, i.e.
Definition: rpmts.c:1368
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:1470
Methods to handle package elements.
rpmte rpmtsSetRelocateElement(rpmts ts, rpmte relocateElement)
Set current relocate transaction element.
Definition: rpmts.c:1401
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:109
rpmps rpmtsProblems(rpmts ts)
Return current transaction set problems.
Definition: rpmts.c:584
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:845
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:756
const void * fnpyKey
Definition: rpmiotypes.h:134
tsmStage rpmtsGoal(rpmts ts)
Retrieve goal of transaction set.
Definition: rpmts.c:1410
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:2252
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
Definition: rpmts.c:840
const char * db
Definition: mongo.h:697
void * rpmtsAcquireLock(rpmts ts)
Definition: rpmlock.c:144
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:892
#define RPMDBI_AVAILABLE
Definition: rpmtag.h:484
int rpmtsOpenDB(rpmts ts, int dbmode)
Open the database used by the transaction.
Definition: rpmts.c:115
const char char type
Definition: bson.h:908
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:419
rpmal rpmalFree(rpmal al)
Destroy available list.
#define RMIL_DEFAULT
Markers for sources of macros added throughout rpm.
Definition: rpmmacro.h:62
unsigned long long bytes
Definition: rpmsw.h:42
void * rpmtsGetKeyring(rpmts ts, int autoload)
Get transaction keyring.
Definition: rpmts.c:792
static const char * name
Structures used for managing added/available package lists.
File state machine to handle archive I/O and system call's.
rpmprobFilterFlags rpmtsFilterFlags(rpmts ts)
Get problem ignore bit mask, i.e.
Definition: rpmts.c:1329
#define _(Text)
Definition: system.h:29
rpmbag rpmbagFree(rpmbag bag)
Destroy a bag wrapper.
int rpmtsSELinuxEnabled(rpmts ts)
Get selinuxEnabled flag, i.e.
Definition: rpmts.c:999
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:1024
rpmtsi rpmtsiInit(rpmts ts)
Create transaction element iterator.
ARGstr_t * ARGV_t
Definition: argv.h:12
Access RPM indices using Berkeley DB interface(s).
enum rpmTag_e rpmTag
Definition: rpmtag.h:470
int rpmdbClose(rpmdb db)
Close all database indices and free rpmdb.
Definition: rpmdb.c:870
#define D_(Text)
Definition: system.h:526
rpmioPool _rpmtsPool
Definition: rpmts.c:774
rpmtransFlags rpmtsFlags(rpmts ts)
Get transaction flags, i.e.
Definition: rpmts.c:1334
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 rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
Definition: macro.c:3324
#define RPMDBI_HASH
Definition: rpmtag.h:490
static void rpmtsFini(void *_ts)
Definition: rpmts.c:709
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
#define xrealloc
Definition: system.h:35
FD_t rpmtsScriptFd(rpmts ts)
Definition: rpmts.c:971
void rpmtsEmpty(rpmts ts)
Re-create an empty transaction set.
Definition: rpmts.c:625
tsmStage rpmtsSetGoal(rpmts ts, tsmStage goal)
Set goal of transaction set.
Definition: rpmts.c:1415
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.
Definition: rpmts.c:598
int rpmtsAvailable(rpmts ts, const rpmds ds)
Attempt to solve a needed dependency using memory resident tables.
Definition: rpmts.c:545
#define RPMDBI_ADDED
Definition: rpmtag.h:482
#define ST_RDONLY
struct rpmbag_s * rpmbag
Definition: rpmbag.h:15
Definition: iosm.h:33
int Unlink(const char *path)
unlink(2) clone.
Definition: rpmrpc.c:397