rpm  5.4.15
rpmcache.c
Go to the documentation of this file.
1 
5 #include "system.h"
6 const char *__progname;
7 
8 #include <fnmatch.h>
9 #include <fts.h>
10 
11 #include <rpmio.h>
12 #include <rpmiotypes.h>
13 #include <poptIO.h>
14 
15 #include <rpmtypes.h>
16 #include <rpmtag.h>
17 #include <rpmdb.h>
18 
19 #include "rpmps.h"
20 
21 #include "misc.h" /* XXX rpmMkdirPath */
22 
23 #define _RPMGI_INTERNAL
24 #include <rpmgi.h>
25 
26 #include <rpmcli.h>
27 
28 #include "debug.h"
29 
30 
31 #ifdef __cplusplus
32 
33 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
34 
35 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
36 #define VSF_SET(_vsflags, _FLAG) \
37  (*((unsigned *)&(_vsflags)) |= (RPMVSF_##_FLAG))
38 #define VSF_CLR(_vsflags, _FLAG) \
39  (*((unsigned *)&(_vsflags)) &= ~(RPMVSF_##_FLAG))
40 
41 #else /* __cplusplus */
42 
43 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
44 
45 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
46 #define VSF_SET(_vsflags, _FLAG) (_vsflags) |= (RPMVSF_##_FLAG)
47 #define VSF_CLR(_vsflags, _FLAG) (_vsflags) &= ~(RPMVSF_##_FLAG)
48 
49 #endif /* __cplusplus */
50 
51 static int _debug = 0;
52 
53 /* XXX should be flag in ts */
54 static int noCache = -1;
55 
56 static ARGV_t ftsSet;
57 
58 const char * bhpath;
59 int bhpathlen = 0;
60 int bhlvl = -1;
61 
62 struct ftsglob_s {
63  const char ** patterns;
64  int fnflags;
65 };
66 
67 static struct ftsglob_s * bhglobs;
68 static int nbhglobs = 5;
69 
70 static int indent = 2;
71 
72 typedef struct Item_s {
73  const char * path;
74  uint32_t size;
75  uint32_t mtime;
76  rpmds this;
78 } * Item;
79 
80 static Item * items = NULL;
81 static int nitems = 0;
82 
83 static inline Item freeItem(Item item) {
84  if (item != NULL) {
85  item->path = _free(item->path);
86  (void)rpmdsFree(item->this);
87  item->this = NULL;
88  (void)headerFree(item->h);
89  item->h = NULL;
90  item = _free(item);
91  }
92  return NULL;
93 }
94 
95 static inline Item newItem(void) {
96  Item item = xcalloc(1, sizeof(*item));
97  return item;
98 }
99 
100 static int cmpItem(const void * a, const void * b) {
101  Item aitem = *(Item *)a;
102  Item bitem = *(Item *)b;
103  int rc = strcmp(rpmdsN(aitem->this), rpmdsN(bitem->this));
104  return rc;
105 }
106 
107 static void freeItems(void) {
108  int i;
109  for (i = 0; i < nitems; i++)
110  items[i] = freeItem(items[i]);
111  items = _free(items);
112  nitems = 0;
113 }
114 
115 static int ftsCachePrint(/*@unused@*/ rpmts ts, FILE * fp)
116 {
117  int rc = 0;
118  int i;
119 
120  if (fp == NULL) fp = stdout;
121  for (i = 0; i < nitems; i++) {
122  Item ip;
123 
124  ip = items[i];
125  if (ip == NULL) {
126  rc = 1;
127  break;
128  }
129 
130  fprintf(fp, "%s\n", ip->path);
131  }
132  return rc;
133 }
134 
136 {
137  HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
138  uint32_t tid = rpmtsGetTid(ts);
139  rpmmi mi;
140  unsigned char * md5;
141  int rc = 0;
142  int xx;
143  int i;
144 
145  rc = rpmtsCloseDB(ts);
146  rc = rpmDefineMacro(NULL, "_dbpath %{_cache_dbpath}", RMIL_CMDLINE);
147  rc = rpmtsOpenDB(ts, O_RDWR);
148  if (rc != 0)
149  return rc;
150 
151  for (i = 0; i < nitems; i++) {
152  Item ip;
153 
154  ip = items[i];
155  if (ip == NULL) {
156  rc = 1;
157  break;
158  }
159 
160  /* --- Check that identical package is not already cached. */
161  he->tag = RPMTAG_SIGMD5;
162  xx = headerGet(ip->h, he, 0);
163  md5 = he->p.ui8p;
164  if (!xx || md5 == NULL) {
165  md5 = _free(md5);
166  rc = 1;
167  break;
168  }
169  mi = rpmtsInitIterator(ts, RPMTAG_SIGMD5, md5, 16);
170  md5 = _free(md5);
171  rc = rpmmiCount(mi);
172  mi = rpmmiFree(mi);
173  if (rc) {
174  rc = 0;
175  continue;
176  }
177 
178  /* --- Add cache tags to new cache header. */
179  he->tag = RPMTAG_CACHECTIME;
180  he->t = RPM_UINT32_TYPE;
181  he->p.ui32p = &tid;
182  he->c = 1;
183  he->append = 1;
184  rc = headerPut(ip->h, he, 0);
185  he->append = 0;
186  if (rc != 1) break;
187 
188  he->tag = RPMTAG_CACHEPKGPATH;
189  he->t = RPM_STRING_ARRAY_TYPE;
190  he->p.argv = &ip->path;
191  he->c = 1;
192  he->append = 1;
193  rc = headerPut(ip->h, he, 0);
194  he->append = 0;
195  if (rc != 1) break;
196 
197  he->tag = RPMTAG_CACHEPKGSIZE;
198  he->t = RPM_UINT32_TYPE;
199  he->p.ui32p = &ip->size;
200  he->c = 1;
201  he->append = 1;
202  rc = headerPut(ip->h, he, 0);
203  he->append = 0;
204  if (rc != 1) break;
205 
207  he->t = RPM_UINT32_TYPE;
208  he->p.ui32p = &ip->mtime;
209  he->c = 1;
210  he->append = 1;
211  rc = headerPut(ip->h, he, 0);
212  he->append = 0;
213  if (rc != 1) break;
214 
215  /* --- Add new cache header to database. */
216  if (!(rpmtsVSFlags(ts) & RPMVSF_NOHDRCHK))
217  rc = rpmdbAdd(rpmtsGetRdb(ts), tid, ip->h, ts);
218  else
219  rc = rpmdbAdd(rpmtsGetRdb(ts), tid, ip->h, NULL);
220  if (rc) break;
221 
222  }
223  xx = rpmtsCloseDB(ts);
224  return rc;
225 }
226 
228 {
229  FTSENT * fts = gi->fts;
230  rpmds add = NULL;
231  struct stat sb, * st;
232  int ec = -1; /* assume not found */
233  int i = 0;
234  int xx;
235 
236  rpmlog(RPMLOG_DEBUG, "============== %s\n", fts->fts_accpath);
237 
238  /* XXX DIEDIEDIE: check platform compatibility. */
239 
241 
242  if (items != NULL && nitems > 0) {
243  Item needle = memset(alloca(sizeof(*needle)), 0, sizeof(*needle));
244  Item * found, * fneedle = &needle;
245 
246  needle->this = add;
247 
248  found = bsearch(fneedle, items, nitems, sizeof(*found), cmpItem);
249 
250  /* Rewind to the first item with same name. */
251  while (found > items && cmpItem(found-1, fneedle) == 0)
252  found--;
253 
254  /* Check that all saved items are newer than this item. */
255  if (found != NULL)
256  while (found < (items + nitems) && cmpItem(found, fneedle) == 0) {
257  ec = rpmdsCompare(needle->this, (*found)->this);
258  if (ec == 0) {
259  found++;
260  continue;
261  }
262  i = found - items;
263  break;
264  }
265  }
266 
267  /*
268  * At this point, ec is
269  * -1 no item with the same name has been seen.
270  * 0 item exists, but already saved item EVR is newer.
271  * 1 item exists, but already saved item EVR is same/older.
272  */
273  if (ec == 0) {
274  goto exit;
275  } else if (ec == 1) {
276  items[i] = freeItem(items[i]);
277  } else {
278  i = nitems++;
279  items = xrealloc(items, nitems * sizeof(*items));
280  }
281 
282  items[i] = newItem();
283  items[i]->path = xstrdup(fts->fts_path);
284  st = fts->fts_statp;
285  if (st == NULL || ((long)st & 0xffff0000) == 0L) {
286  st = &sb;
287  memset(st, 0, sizeof(*st));
288  xx = Stat(fts->fts_accpath, &sb);
289  }
290 
291  if (st != NULL) {
292  items[i]->size = st->st_size;
293  items[i]->mtime = st->st_mtime;
294  }
295  st = NULL;
297  items[i]->h = headerLink(h);
298 
299  if (nitems > 1)
300  qsort(items, nitems, sizeof(*items), cmpItem);
301 
302 #if 0
303  fprintf(stderr, "\t%*s [%d] %s\n",
304  indent * (fts->fts_level < 0 ? 0 : fts->fts_level), "",
305  i, fts->fts_name);
306 #endif
307 
308 exit:
309  (void)rpmdsFree(add);
310  add = NULL;
311  return (ec ? RPMRC_NOTFOUND : RPMRC_OK);
312 }
313 
314 static const char * ftsInfoStrings[] = {
315  "UNKNOWN",
316  "D",
317  "DC",
318  "DEFAULT",
319  "DNR",
320  "DOT",
321  "DP",
322  "ERR",
323  "F",
324  "INIT",
325  "NS",
326  "NSOK",
327  "SL",
328  "SLNONE",
329  "W",
330 };
331 
332 static const char * ftsInfoStr(int fts_info) {
333  if (!(fts_info >= 1 && fts_info <= 14))
334  fts_info = 0;
335  return ftsInfoStrings[ fts_info ];
336 }
337 
339 {
340  FTS * ftsp = gi->ftsp;
341  FTSENT * fts = gi->fts;
342  struct ftsglob_s * bhg;
343  const char ** patterns;
344  const char * pattern;
345  const char * s;
346  int lvl;
347  int xx;
348 
349  switch (fts->fts_info) {
350  case FTS_D: /* preorder directory */
351  if (fts->fts_pathlen < bhpathlen)
352  break;
353 
354  /* Grab the level of the beehive top directory. */
355  if (bhlvl < 0) {
356  if (fts->fts_pathlen == bhpathlen && !strcmp(fts->fts_path, bhpath))
357  bhlvl = fts->fts_level;
358  else
359  break;
360  }
361  lvl = fts->fts_level - bhlvl;
362 
363  if (lvl < 0)
364  break;
365 
366 #if 0
367  if (_debug)
368  fprintf(stderr, "FTS_%s\t%*s %s\n", ftsInfoStr(fts->fts_info),
369  indent * (fts->fts_level < 0 ? 0 : fts->fts_level), "",
370  fts->fts_name);
371 #endif
372 
373  /* Full path glob expression check. */
374  bhg = bhglobs;
375 
376  if ((patterns = bhg->patterns) != NULL)
377  while ((pattern = *patterns++) != NULL) {
378  if (*pattern == '/')
379  xx = fnmatch(pattern, fts->fts_path, bhg->fnflags);
380  else
381  xx = fnmatch(pattern, fts->fts_name, bhg->fnflags);
382  if (xx == 0)
383  break;
384  }
385 
386  /* Level specific glob expression check(s). */
387  if (lvl == 0 || lvl >= nbhglobs)
388  break;
389  bhg += lvl;
390 
391  if ((patterns = bhg->patterns) != NULL)
392  while ((pattern = *patterns++) != NULL) {
393  if (*pattern == '/')
394  xx = fnmatch(pattern, fts->fts_path, bhg->fnflags);
395  else
396  xx = fnmatch(pattern, fts->fts_name, bhg->fnflags);
397  if (xx == 0)
398  break;
399  else
400  xx = Fts_set(ftsp, fts, FTS_SKIP);
401  }
402 
403  break;
404  case FTS_DP: /* postorder directory */
405 #if 0
406  if (_debug)
407  fprintf(stderr, "FTS_%s\t%*s %s\n", ftsInfoStr(fts->fts_info),
408  indent * (fts->fts_level < 0 ? 0 : fts->fts_level), "",
409  fts->fts_name);
410 #endif
411  break;
412  case FTS_F: /* regular file */
413 #if 0
414  if (_debug)
415  fprintf(stderr, "FTS_%s\t%*s %s\n", ftsInfoStr(fts->fts_info),
416  indent * (fts->fts_level < 0 ? 0 : fts->fts_level), "",
417  fts->fts_name);
418 #endif
419  if (fts->fts_level >= 0) {
420  /* Ignore source packages. */
421  if (!strcmp(fts->fts_parent->fts_name, "SRPMS")) {
422  xx = Fts_set(ftsp, fts->fts_parent, FTS_SKIP);
423  break;
424  }
425  }
426 
427  /* Ignore all but *.rpm files. */
428  s = fts->fts_name + fts->fts_namelen + 1 - sizeof(".rpm");
429  if (strcmp(s, ".rpm"))
430  break;
431 
432  break;
433  case FTS_NS: /* stat(2) failed */
434  case FTS_DNR: /* unreadable directory */
435  case FTS_ERR: /* error; errno is set */
436  if (_debug)
437  fprintf(stderr, "FTS_%s\t%*s %s\n", ftsInfoStr(fts->fts_info),
438  indent * (fts->fts_level < 0 ? 0 : fts->fts_level), "",
439  fts->fts_name);
440  break;
441  case FTS_DC: /* directory that causes cycles */
442  case FTS_DEFAULT: /* none of the above */
443  case FTS_DOT: /* dot or dot-dot */
444  case FTS_INIT: /* initialized only */
445  case FTS_NSOK: /* no stat(2) requested */
446  case FTS_SL: /* symbolic link */
447  case FTS_SLNONE: /* symbolic link without target */
448  case FTS_W: /* whiteout object */
449  default:
450  if (_debug)
451  fprintf(stderr, "FTS_%s\t%*s %s\n", ftsInfoStr(fts->fts_info),
452  indent * (fts->fts_level < 0 ? 0 : fts->fts_level), "",
453  fts->fts_name);
454  break;
455  }
456 
457  return RPMRC_OK;
458 }
459 
465 static void initGlobs(/*@unused@*/ rpmts ts, const char ** argv)
466 {
467  char buf[BUFSIZ];
468  int i;
469 
470  buf[0] = '\0';
471  if (argv != NULL && * argv != NULL) {
472  const char * arg;
473  int single = (Glob_pattern_p(argv[0], 0) && argv[1] == NULL);
474  char * t;
475 
476  t = buf;
477  if (!single)
478  t = stpcpy(t, "@(");
479  while ((arg = *argv++) != NULL) {
480  t = stpcpy(t, arg);
481  *t++ = '|';
482  }
483  t[-1] = (char)(single ? '\0' : ')');
484  *t = '\0';
485  }
486 
487  bhpath = rpmExpand("%{_bhpath}", NULL);
488  bhpathlen = strlen(bhpath);
489 
490  ftsSet = xcalloc(2, sizeof(*ftsSet));
491  ftsSet[0] = rpmExpand("%{_bhpath}", NULL);
492 
493  nbhglobs = 5;
494  bhglobs = xcalloc(nbhglobs, sizeof(*bhglobs));
495  for (i = 0; i < nbhglobs; i++) {
496  const char * pattern;
497  const char * macro;
498 
499  switch (i) {
500  case 0:
501  macro = "%{_bhpath}";
502  break;
503  case 1:
504  macro = "%{_bhcoll}";
505  break;
506  case 2:
507  macro = (buf[0] == '\0' ? "%{_bhN}" : buf);
508  break;
509  case 3:
510  macro = "%{_bhVR}";
511  break;
512  case 4:
513  macro = "%{_bhA}";
514  break;
515  default:
516  macro = NULL;
517  break;
518  }
519  bhglobs[i].patterns = xcalloc(2, sizeof(*bhglobs[i].patterns));
520  if (macro == NULL)
521  continue;
522  pattern = rpmExpand(macro, NULL);
523  if (pattern == NULL || *pattern == '\0') {
524  pattern = _free(pattern);
525  continue;
526  }
527  bhglobs[i].patterns[0] = pattern;
528  bhglobs[i].fnflags = (FNM_PATHNAME | FNM_PERIOD | FNM_EXTMATCH);
529  if (bhglobs[i].patterns[0] != NULL)
530  rpmlog(RPMLOG_DEBUG, "\t%d \"%s\"\n",
531  i, bhglobs[i].patterns[0]);
532  }
533 }
534 
535 static void freeGlobs(void)
536 {
537  int i;
538  for (i = 0; i < nbhglobs; i++) {
539  bhglobs[i].patterns[0] = _free(bhglobs[i].patterns[0]);
540  bhglobs[i].patterns = _free(bhglobs[i].patterns);
541  }
542  bhglobs = _free(bhglobs);
543  ftsSet[0] = _free(ftsSet[0]);
544  ftsSet = _free(ftsSet);
545 }
546 
548 
549 static struct poptOption optionsTable[] = {
550  /* XXX FIXME: --nolegacy looks bogus */
551  { "nolegacy", '\0', POPT_BIT_SET, &vsflags, RPMVSF_NEEDPAYLOAD,
552  N_("don't verify header+payload signature"), NULL },
553 
554  { "cache", '\0', POPT_ARG_VAL, &noCache, 0,
555  N_("update cache database"), NULL },
556  { "nocache", '\0', POPT_ARG_VAL, &noCache, -1,
557  N_("don't update cache database, only print package paths"), NULL },
558 
559  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioFtsPoptTable, 0,
560  N_("File tree walk options:"),
561  NULL },
562 
563  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
564  N_("Common options for all rpm modes and executables:"),
565  NULL },
566 
567  POPT_AUTOALIAS
568  POPT_AUTOHELP
569  POPT_TABLEEND
570 };
571 
572 int
573 main(int argc, char *argv[])
574 {
575  poptContext optCon = rpmcliInit(argc, argv, optionsTable);
576  rpmts ts = NULL;
577  rpmgi gi = NULL;
578  const char * s;
579  int ec = 1;
580  rpmRC rpmrc;
581  int xx;
582 
583  if (optCon == NULL)
584  exit(EXIT_FAILURE);
585 
586  /* Configure the path to cache database, creating if necessary. */
587  s = rpmExpand("%{?_cache_dbpath}", NULL);
588  if (!(s && *s))
589  rpmrc = RPMRC_FAIL;
590  else
591  rpmrc = rpmMkdirPath(s, "cache_dbpath");
592  if (rpmrc == RPMRC_OK && Access(s, W_OK))
593  rpmrc = RPMRC_FAIL;
594  s = _free(s);
595  if (rpmrc != RPMRC_OK) {
596  fprintf(stderr, _("%s: %%{_cache_dbpath} macro is mis-configured.\n"),
597  __progname);
598  exit(EXIT_FAILURE);
599  }
600 
601  ts = rpmtsCreate();
602 
603 #if defined(SUPPORT_NOSIGNATURES)
604  if (!QVA_ISSET(rpmcliQueryFlags, DIGEST)) {
605  VSF_SET(vsflags, NOSHA1HEADER);
606  VSF_SET(vsflags, NOMD5HEADER);
607  VSF_SET(vsflags, NOSHA1);
608  VSF_SET(vsflags, NOMD5);
609  }
610  if (!QVA_ISSET(rpmcliQueryFlags, SIGNATURE)) {
611  VSF_SET(vsflags, NODSAHEADER);
612  VSF_SET(vsflags, NORSAHEADER);
613  VSF_SET(vsflags, NODSA);
614  VSF_SET(vsflags, NORSA);
615  }
616  if (!QVA_ISSET(rpmcliQueryFlags, HDRCHK)) {
617  VSF_SET(vsflags, NOHDRCHK);
618  }
619  VSF_CLR(vsflags, NEEDPAYLOAD); /* XXX needed? */
620 #endif
621 
622  (void) rpmtsSetVSFlags(ts, vsflags);
623 
624  { uint32_t tid = (uint32_t) time(NULL);
625  (void) rpmtsSetTid(ts, tid);
626  }
627 
628  initGlobs(ts, poptGetArgs(optCon));
629 
630  gi = rpmgiNew(ts, RPMDBI_FTSWALK, NULL, 0);
631 
632  if (rpmioFtsOpts == 0)
634 
635  if (noCache)
637  else
639 
641 
642  gi->walkPathFilter = cacheWalkPathFilter;
643  gi->stash = cacheStashLatest;
644  while ((rpmrc = rpmgiNext(gi)) == RPMRC_OK)
645  {};
646 
647  if (noCache)
648  ec = ftsCachePrint(ts, stdout);
649  else
650  ec = ftsCacheUpdate(ts);
651  if (ec) {
652  fprintf(stderr, _("%s: cache operation failed: ec %d.\n"),
653  __progname, ec);
654  }
655 
656  freeItems();
657  freeGlobs();
658 
659  gi = rpmgiFree(gi);
660  (void)rpmtsFree(ts);
661  ts = NULL;
662  optCon = rpmcliFini(optCon);
663 
664  return ec;
665 }
const bson * b
Definition: bson.h:280
rpmTagType t
Definition: rpmtag.h:504
#define FTS_SLNONE
Definition: fts.h:141
static rpmRC cacheWalkPathFilter(rpmgi gi)
Definition: rpmcache.c:338
rpmTag tag
Definition: rpmtag.h:503
static Item freeItem(Item item)
Definition: rpmcache.c:83
const char * path
Definition: rpmcache.c:73
const char ** argv
Definition: rpmtag.h:75
uint32_t mtime
Definition: rpmcache.c:75
rpmQueryFlags rpmcliQueryFlags
Bit(s) from common command line options.
Definition: poptALL.c:173
static rpmRC cacheStashLatest(rpmgi gi, Header h)
Definition: rpmcache.c:227
int fnflags
Definition: rpmcache.c:64
#define FNM_PATHNAME
Definition: fnmatch.h:41
const char bson_timestamp_t * ts
Definition: bson.h:1004
const char * bhpath
Definition: rpmcache.c:58
#define EXIT_FAILURE
uint32_t size
Definition: rpmcache.c:74
char * xstrdup(const char *str)
Definition: rpmmalloc.c:321
#define VSF_SET(_vsflags, _FLAG)
Definition: rpmcache.c:46
rpmuint32_t * ui32p
Definition: rpmtag.h:70
rpmgi rpmgiFree(rpmgi gi)
Destroy a generalized iterator.
static void initGlobs(rpmts ts, const char **argv)
Initialize fts and glob structures.
Definition: rpmcache.c:465
int headerGet(Header h, HE_t he, unsigned int flags)
Retrieve extension or tag value from a header.
Definition: header.c:2231
int headerPut(Header h, HE_t he, unsigned int flags)
Add or append tag container to header.
Definition: header.c:2294
int Access(const char *path, int amode)
access(2) clone.
Definition: rpmrpc.c:2196
#define FTS_W
Definition: fts.h:142
const char int time
Definition: bson.h:1005
struct poptOption rpmcliAllPoptTable[]
Popt option table for options shared by all modes and executables.
Definition: poptALL.c:418
The Header data structure.
static ARGV_t patterns
Definition: rpmgrep.c:87
struct poptOption rpmioFtsPoptTable[]
Popt option table for options to set Fts(3) options.
Definition: poptIO.c:542
#define FTS_SL
Definition: fts.h:140
int Stat(const char *path, struct stat *st)
stat(2) clone.
Definition: rpmrpc.c:1361
static rpmVSFlags vsflags
Definition: rpmcache.c:547
Definition: rpmdb.c:436
static int nbhglobs
Definition: rpmcache.c:68
struct _ftsent * fts_parent
Definition: fts.h:106
u_short fts_namelen
Definition: fts.h:119
#define FTS_NS
Definition: fts.h:138
short fts_level
Definition: fts.h:127
int main(int argc, char *argv[])
Definition: rpmcache.c:573
static void rpmlog(int code, const char *fmt,...)
Definition: rpmlog.h:299
poptContext rpmcliInit(int argc, char *const argv[], struct poptOption *optionsTable)
Initialize most everything needed by an rpm CLI executable context.
Definition: poptALL.c:669
struct rpmds_s * rpmds
Dependency tag sets from a header, so that a header can be discarded early.
Definition: rpmtypes.h:28
rpmds rpmdsFree(rpmds ds)
Destroy a dependency set.
static int ftsCacheUpdate(rpmts ts)
Definition: rpmcache.c:135
static int noCache
Definition: rpmcache.c:54
static int indent
Definition: rpmcache.c:70
char * alloca()
rpmuint32_t rpmtsSetTid(rpmts ts, rpmuint32_t tid)
Set transaction id, i.e.
Definition: rpmts.c:1033
u_short fts_info
Definition: fts.h:143
int bhlvl
Definition: rpmcache.c:60
#define FTS_D
Definition: fts.h:129
int bhpathlen
Definition: rpmcache.c:59
void * xcalloc(size_t nmemb, size_t size)
Definition: rpmmalloc.c:300
static struct poptOption optionsTable[]
Definition: rpmcache.c:549
static const char * ftsInfoStrings[]
Definition: rpmcache.c:314
rpmgi rpmgiNew(rpmts ts, int tag, const void *keyp, size_t keylen)
Return a generalized iterator.
Definition: rpmgi.c:543
Structures and prototypes used for an "rpmps" problem set.
#define FTS_NSOK
Definition: fts.h:139
#define N_(Text)
Definition: system.h:531
int rpmdsCompare(const rpmds A, const rpmds B)
Compare two versioned dependency ranges, looking for overlap.
Definition: rpmds.c:4035
rpmgiFlags giFlags
Definition: rpmgi.c:42
#define FTS_COMFOLLOW
Definition: fts.h:87
rpmTagData p
Definition: rpmtag.h:506
int rpmDefineMacro(MacroContext mc, const char *macro, int level)
Define macro in context.
Definition: macro.c:2849
#define FTS_DEFAULT
Definition: fts.h:131
#define FTS_DC
Definition: fts.h:130
#define VSF_CLR(_vsflags, _FLAG)
Definition: rpmcache.c:47
int Glob_pattern_p(const char *pattern, int quote)
glob_pattern_p(3) clone.
Definition: rpmrpc.c:2231
#define RPMDBI_FTSWALK
Definition: rpmtag.h:487
#define QVA_ISSET(_qvaflags, _FLAG)
Definition: rpmcache.c:43
#define FTS_DOT
Definition: fts.h:133
static void freeGlobs(void)
Definition: rpmcache.c:535
rpmRC rpmgiSetArgs(rpmgi gi, ARGV_t argv, int ftsOpts, rpmgiFlags flags)
Load iterator args.
Definition: rpmgi.c:866
char * fts_path
Definition: fts.h:115
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
Definition: rpmts.c:212
rpmTagCount c
Definition: rpmtag.h:507
Definition: fts.h:54
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
Definition: rpmts.h:35
Header headerFree(Header h)
Dereference a header instance.
static int ftsCachePrint(rpmts ts, FILE *fp)
Definition: rpmcache.c:115
const char ** patterns
Definition: rpmcache.c:63
int rpmioFtsOpts
Definition: poptIO.c:539
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
Definition: macro.c:3238
rpmRC rpmMkdirPath(const char *dpath, const char *dname)
Create directory if it does not exist, and make sure path is writable.
Definition: misc.c:19
const char const char int arg
Definition: mongo.h:777
rpmuint8_t * ui8p
Definition: rpmtag.h:68
#define FNM_PERIOD
Definition: fnmatch.h:43
const char * rpmdsN(const rpmds ds)
Return current dependency name.
Definition: rpmds.c:668
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
static int cmpItem(const void *a, const void *b)
Definition: rpmcache.c:100
#define FTS_DNR
Definition: fts.h:132
static void freeItems(void)
Definition: rpmcache.c:107
char * fts_accpath
Definition: fts.h:113
static int _debug
Definition: rpmcache.c:51
int Fts_set(FTS *sp, FTSENT *p, int instr)
Modify the traversal for a file set member.
Definition: fts.c:688
Header headerLink(Header h)
Reference a header instance.
char fts_name[1]
Definition: fts.h:157
rpmdb rpmtsGetRdb(rpmts ts)
Get transaction set database handle.
Definition: pkgio.c:151
static const char * ftsInfoStr(int fts_info)
Definition: rpmcache.c:332
#define FTS_INIT
Definition: fts.h:137
Header h
Definition: rpmcache.c:77
struct rpmgi_s * rpmgi
Generalized iterator.
Definition: rpmtypes.h:53
enum rpmRC_e rpmRC
RPM return codes.
#define L(CS)
Definition: fnmatch.c:161
Definition: rpmtag.h:502
const char const int i
Definition: bson.h:778
static ARGV_t ftsSet
Definition: rpmcache.c:56
Definition: fts.h:102
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
rpmts rpmtsCreate(void)
Create an empty transaction set.
Definition: rpmts.c:1470
struct stat * fts_statp
Definition: fts.h:156
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
Definition: rpmts.c:845
char * stpcpy(char *dest, const char *src)
struct rpmts_s * rpmts
The RPM Transaction Set.
Definition: rpmtypes.h:14
rpmds this
Definition: rpmcache.c:76
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Definition: rpmiotypes.h:756
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
Definition: rpmts.c:840
static Item * items
Definition: rpmcache.c:80
static struct ftsglob_s * bhglobs
Definition: rpmcache.c:67
#define FNM_EXTMATCH
Definition: fnmatch.h:49
#define FTS_LOGICAL
Definition: fts.h:88
int rpmtsOpenDB(rpmts ts, int dbmode)
Open the database used by the transaction.
Definition: rpmts.c:115
const char * __progname
Definition: rpmcache.c:6
rpmRC rpmgiNext(rpmgi gi)
Perform next iteration step.
Definition: rpmgi.c:584
#define FTS_F
Definition: fts.h:136
#define _(Text)
Definition: system.h:29
int rpmdbAdd(rpmdb db, int iid, Header h, rpmts ts)
Add package header to rpm database and indices.
Definition: rpmdb.c:2887
const char const char * pattern
Definition: bson.h:971
#define RMIL_CMDLINE
Definition: rpmmacro.h:66
#define FTS_DP
Definition: fts.h:134
rpmuint32_t rpmtsGetTid(rpmts ts)
Get transaction id, i.e.
Definition: rpmts.c:1024
ARGstr_t * ARGV_t
Definition: argv.h:12
Access RPM indices using Berkeley DB interface(s).
unsigned int rpmmiCount(rpmmi mi)
Return number of elements in rpm database iterator.
Definition: rpmdb.c:1763
int rpmtsCloseDB(rpmts ts)
Close the database used by the transaction.
Definition: rpmts.c:101
#define FTS_NOSTAT
Definition: fts.h:90
int fnmatch(char *pattern, const char *string, int flags) const
Definition: fnmatch.c:279
u_short fts_pathlen
Definition: fts.h:118
#define FTS_ERR
Definition: fts.h:135
rpmds rpmdsThis(Header h, rpmTag tagN, evrFlags Flags)
Create, load and initialize a dependency for this header.
Definition: rpmds.c:513
poptContext rpmcliFini(poptContext optCon)
Destroy most everything needed by an rpm CLI executable context.
Definition: poptALL.c:523
#define xrealloc
Definition: system.h:35
static Item newItem(void)
Definition: rpmcache.c:95
static int nitems
Definition: rpmcache.c:81
#define W_OK
Definition: system.h:233
struct Item_s * Item
unsigned int append
Definition: rpmtag.h:511
#define FTS_SKIP
Definition: fts.h:152