- split file info tag sets into rpmfi.c.
[platform/upstream/rpm.git] / lib / rpmds.c
1 /** \ingroup rpmdep
2  * \file lib/rpmds.c
3  */
4 #include "system.h"
5
6 #include <rpmlib.h>
7 #include "rpmds.h"
8
9 #include "debug.h"
10
11 /*@access rpmDepSet @*/
12
13 /**
14  * Enable noisy range comparison debugging message?
15  */
16 /*@unchecked@*/
17 static int _noisy_range_comparison_debug_message = 0;
18
19 /*@unchecked@*/
20 static int _ds_debug = 0;
21
22 rpmDepSet XrpmdsUnlink(rpmDepSet ds, const char * msg, const char * fn, unsigned ln)
23 {
24     if (ds == NULL) return NULL;
25 /*@-modfilesystem@*/
26 if (_ds_debug && msg != NULL)
27 fprintf(stderr, "--> ds %p -- %d %s at %s:%u\n", ds, ds->nrefs, msg, fn, ln);
28 /*@=modfilesystem@*/
29     ds->nrefs--;
30     return NULL;
31 }
32
33 rpmDepSet XrpmdsLink(rpmDepSet ds, const char * msg, const char * fn, unsigned ln)
34 {
35     if (ds == NULL) return NULL;
36     ds->nrefs++;
37
38 /*@-modfilesystem@*/
39 if (_ds_debug && msg != NULL)
40 fprintf(stderr, "--> ds %p ++ %d %s at %s:%u\n", ds, ds->nrefs, msg, fn, ln);
41 /*@=modfilesystem@*/
42
43     /*@-refcounttrans@*/ return ds; /*@=refcounttrans@*/
44 }
45
46 rpmDepSet dsFree(rpmDepSet ds)
47 {
48     HFD_t hfd = headerFreeData;
49     rpmTag tagEVR, tagF;
50
51     if (ds == NULL)
52         return NULL;
53
54     if (ds->nrefs > 1)
55         return rpmdsUnlink(ds, ds->Type);
56
57 /*@-modfilesystem@*/
58 if (_ds_debug < 0)
59 fprintf(stderr, "*** ds %p\t%s[%d]\n", ds, ds->Type, ds->Count);
60 /*@=modfilesystem@*/
61
62
63     if (ds->tagN == RPMTAG_PROVIDENAME) {
64         tagEVR = RPMTAG_PROVIDEVERSION;
65         tagF = RPMTAG_PROVIDEFLAGS;
66     } else
67     if (ds->tagN == RPMTAG_REQUIRENAME) {
68         tagEVR = RPMTAG_REQUIREVERSION;
69         tagF = RPMTAG_REQUIREFLAGS;
70     } else
71     if (ds->tagN == RPMTAG_CONFLICTNAME) {
72         tagEVR = RPMTAG_CONFLICTVERSION;
73         tagF = RPMTAG_CONFLICTFLAGS;
74     } else
75     if (ds->tagN == RPMTAG_OBSOLETENAME) {
76         tagEVR = RPMTAG_OBSOLETEVERSION;
77         tagF = RPMTAG_OBSOLETEFLAGS;
78     } else
79     if (ds->tagN == RPMTAG_TRIGGERNAME) {
80         tagEVR = RPMTAG_TRIGGERVERSION;
81         tagF = RPMTAG_TRIGGERFLAGS;
82     } else
83         return NULL;
84
85     /*@-branchstate@*/
86     if (ds->Count > 0) {
87         ds->N = hfd(ds->N, ds->Nt);
88         ds->EVR = hfd(ds->EVR, ds->EVRt);
89         /*@-evalorder@*/
90         ds->Flags = (ds->h != NULL ? hfd(ds->Flags, ds->Ft) : _free(ds->Flags));
91         /*@=evalorder@*/
92         ds->h = headerFree(ds->h, ds->Type);
93     }
94     /*@=branchstate@*/
95
96     ds->DNEVR = _free(ds->DNEVR);
97
98     (void) rpmdsUnlink(ds, ds->Type);
99     /*@-refcounttrans -usereleased@*/
100     memset(ds, 0, sizeof(*ds));         /* XXX trash and burn */
101     ds = _free(ds);
102     /*@=refcounttrans =usereleased@*/
103     return NULL;
104 }
105
106 rpmDepSet dsNew(Header h, rpmTag tagN, int scareMem)
107 {
108     HGE_t hge =
109         (scareMem ? (HGE_t) headerGetEntryMinMemory : (HGE_t) headerGetEntry);
110     rpmTag tagEVR, tagF;
111     rpmDepSet ds = NULL;
112     const char * Type;
113     const char ** N;
114     rpmTagType Nt;
115     int_32 Count;
116
117     if (tagN == RPMTAG_PROVIDENAME) {
118         Type = "Provides";
119         tagEVR = RPMTAG_PROVIDEVERSION;
120         tagF = RPMTAG_PROVIDEFLAGS;
121     } else
122     if (tagN == RPMTAG_REQUIRENAME) {
123         Type = "Requires";
124         tagEVR = RPMTAG_REQUIREVERSION;
125         tagF = RPMTAG_REQUIREFLAGS;
126     } else
127     if (tagN == RPMTAG_CONFLICTNAME) {
128         Type = "Conflicts";
129         tagEVR = RPMTAG_CONFLICTVERSION;
130         tagF = RPMTAG_CONFLICTFLAGS;
131     } else
132     if (tagN == RPMTAG_OBSOLETENAME) {
133         Type = "Obsoletes";
134         tagEVR = RPMTAG_OBSOLETEVERSION;
135         tagF = RPMTAG_OBSOLETEFLAGS;
136     } else
137     if (tagN == RPMTAG_TRIGGERNAME) {
138         Type = "Trigger";
139         tagEVR = RPMTAG_TRIGGERVERSION;
140         tagF = RPMTAG_TRIGGERFLAGS;
141     } else
142         goto exit;
143
144     /*@-branchstate@*/
145     if (hge(h, tagN, &Nt, (void **) &N, &Count)
146      && N != NULL && Count > 0)
147     {
148         int xx;
149
150         ds = xcalloc(1, sizeof(*ds));
151         ds->Type = Type;
152         ds->h = (scareMem ? headerLink(h, ds->Type) : NULL);
153         ds->i = -1;
154         ds->DNEVR = NULL;
155         ds->tagN = tagN;
156         ds->N = N;
157         ds->Nt = Nt;
158         ds->Count = Count;
159
160         xx = hge(h, tagEVR, &ds->EVRt, (void **) &ds->EVR, NULL);
161         xx = hge(h, tagF, &ds->Ft, (void **) &ds->Flags, NULL);
162         if (!scareMem && ds->Flags != NULL)
163             ds->Flags = memcpy(xmalloc(ds->Count * sizeof(*ds->Flags)),
164                                 ds->Flags, ds->Count * sizeof(*ds->Flags));
165
166 /*@-modfilesystem@*/
167 if (_ds_debug < 0)
168 fprintf(stderr, "*** ds %p\t%s[%d]\n", ds, ds->Type, ds->Count);
169 /*@=modfilesystem@*/
170
171     }
172     /*@=branchstate@*/
173
174 exit:
175     /*@-nullstate@*/ /* FIX: ds->Flags may be NULL */
176     return rpmdsLink(ds, (ds ? ds->Type : NULL));
177     /*@=nullstate@*/
178 }
179
180 char * dsDNEVR(const char * dspfx, const rpmDepSet ds)
181 {
182     char * tbuf, * t;
183     size_t nb;
184
185     nb = 0;
186     if (dspfx)  nb += strlen(dspfx) + 1;
187     if (ds->N[ds->i])   nb += strlen(ds->N[ds->i]);
188     if (ds->Flags[ds->i] & RPMSENSE_SENSEMASK) {
189         if (nb) nb++;
190         if (ds->Flags[ds->i] & RPMSENSE_LESS)   nb++;
191         if (ds->Flags[ds->i] & RPMSENSE_GREATER) nb++;
192         if (ds->Flags[ds->i] & RPMSENSE_EQUAL)  nb++;
193     }
194     if (ds->EVR[ds->i] && *ds->EVR[ds->i]) {
195         if (nb) nb++;
196         nb += strlen(ds->EVR[ds->i]);
197     }
198
199     t = tbuf = xmalloc(nb + 1);
200     if (dspfx) {
201         t = stpcpy(t, dspfx);
202         *t++ = ' ';
203     }
204     if (ds->N[ds->i])
205         t = stpcpy(t, ds->N[ds->i]);
206     if (ds->Flags[ds->i] & RPMSENSE_SENSEMASK) {
207         if (t != tbuf)  *t++ = ' ';
208         if (ds->Flags[ds->i] & RPMSENSE_LESS)   *t++ = '<';
209         if (ds->Flags[ds->i] & RPMSENSE_GREATER) *t++ = '>';
210         if (ds->Flags[ds->i] & RPMSENSE_EQUAL)  *t++ = '=';
211     }
212     if (ds->EVR[ds->i] && *ds->EVR[ds->i]) {
213         if (t != tbuf)  *t++ = ' ';
214         t = stpcpy(t, ds->EVR[ds->i]);
215     }
216     *t = '\0';
217     return tbuf;
218 }
219
220 rpmDepSet dsThis(Header h, rpmTag tagN, int_32 Flags)
221 {
222     HGE_t hge = (HGE_t) headerGetEntryMinMemory;
223     rpmDepSet ds = NULL;
224     const char * Type;
225     const char * n, * v, * r;
226     int_32 * ep;
227     const char ** N, ** EVR;
228     char * t;
229     int xx;
230
231     if (tagN == RPMTAG_PROVIDENAME) {
232         Type = "Provides";
233     } else
234     if (tagN == RPMTAG_REQUIRENAME) {
235         Type = "Requires";
236     } else
237     if (tagN == RPMTAG_CONFLICTNAME) {
238         Type = "Conflicts";
239     } else
240     if (tagN == RPMTAG_OBSOLETENAME) {
241         Type = "Obsoletes";
242     } else
243     if (tagN == RPMTAG_TRIGGERNAME) {
244         Type = "Trigger";
245     } else
246         goto exit;
247
248     xx = headerNVR(h, &n, &v, &r);
249     ep = NULL;
250     xx = hge(h, RPMTAG_EPOCH, NULL, (void **)&ep, NULL);
251
252     t = xmalloc(sizeof(*N) + strlen(n) + 1);
253     N = (const char **) t;
254     t += sizeof(*N);
255     N[0] = t;
256     t = stpcpy(t, n);
257
258     t = xmalloc(sizeof(*EVR) +
259                 (ep ? 20 : 0) + strlen(v) + strlen(r) + sizeof("-"));
260     EVR = (const char **) t;
261     t += sizeof(*EVR);
262     EVR[0] = t;
263     if (ep) {
264         sprintf(t, "%d:", *ep);
265         t += strlen(t);
266     }
267     t = stpcpy( stpcpy( stpcpy( t, v), "-"), r);
268
269     ds = xcalloc(1, sizeof(*ds));
270     ds->h = NULL;
271     ds->Type = Type;
272     ds->tagN = tagN;
273     ds->Count = 1;
274     ds->N = N;
275     ds->EVR = EVR;
276     ds->Flags = xmalloc(sizeof(*ds->Flags));    ds->Flags[0] = Flags;
277     ds->i = 0;
278     {   char pre[2];
279         pre[0] = ds->Type[0];
280         pre[1] = '\0';
281         /*@-nullstate@*/ /* LCL: ds->Type may be NULL ??? */
282         ds->DNEVR = dsDNEVR(pre, ds);
283         /*@=nullstate@*/
284     }
285
286 exit:
287     return rpmdsLink(ds, (ds ? ds->Type : NULL));
288 }
289
290 rpmDepSet dsSingle(rpmTag tagN, const char * N, const char * EVR, int_32 Flags)
291 {
292     rpmDepSet ds = NULL;
293     const char * Type;
294
295     if (tagN == RPMTAG_PROVIDENAME) {
296         Type = "Provides";
297     } else
298     if (tagN == RPMTAG_REQUIRENAME) {
299         Type = "Requires";
300     } else
301     if (tagN == RPMTAG_CONFLICTNAME) {
302         Type = "Conflicts";
303     } else
304     if (tagN == RPMTAG_OBSOLETENAME) {
305         Type = "Obsoletes";
306     } else
307     if (tagN == RPMTAG_TRIGGERNAME) {
308         Type = "Trigger";
309     } else
310         goto exit;
311
312     ds = xcalloc(1, sizeof(*ds));
313     ds->h = NULL;
314     ds->Type = Type;
315     ds->tagN = tagN;
316     ds->Count = 1;
317     /*@-assignexpose@*/
318     ds->N = xmalloc(sizeof(*ds->N));            ds->N[0] = N;
319     ds->EVR = xmalloc(sizeof(*ds->EVR));        ds->EVR[0] = EVR;
320     /*@=assignexpose@*/
321     ds->Flags = xmalloc(sizeof(*ds->Flags));    ds->Flags[0] = Flags;
322     ds->i = 0;
323     {   char t[2];
324         t[0] = ds->Type[0];
325         t[1] = '\0';
326         ds->DNEVR = dsDNEVR(t, ds);
327     }
328
329 exit:
330     return rpmdsLink(ds, (ds ? ds->Type : NULL));
331 }
332
333 int dsiGetCount(rpmDepSet ds)
334 {
335     return (ds != NULL ? ds->Count : 0);
336 }
337
338 int dsiGetIx(rpmDepSet ds)
339 {
340     return (ds != NULL ? ds->i : -1);
341 }
342
343 int dsiSetIx(rpmDepSet ds, int ix)
344 {
345     int i = -1;
346
347     if (ds != NULL) {
348         i = ds->i;
349         ds->i = ix;
350     }
351     return i;
352 }
353
354 const char * dsiGetDNEVR(rpmDepSet ds)
355 {
356     const char * DNEVR = NULL;
357
358     if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
359         if (ds->DNEVR != NULL)
360             DNEVR = ds->DNEVR;
361     }
362     return DNEVR;
363 }
364
365 const char * dsiGetN(rpmDepSet ds)
366 {
367     const char * N = NULL;
368
369     if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
370         if (ds->N != NULL)
371             N = ds->N[ds->i];
372     }
373     return N;
374 }
375
376 const char * dsiGetEVR(rpmDepSet ds)
377 {
378     const char * EVR = NULL;
379
380     if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
381         if (ds->EVR != NULL)
382             EVR = ds->EVR[ds->i];
383     }
384     return EVR;
385 }
386
387 int_32 dsiGetFlags(rpmDepSet ds)
388 {
389     int_32 Flags = 0;
390
391     if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
392         if (ds->Flags != NULL)
393             Flags = ds->Flags[ds->i];
394     }
395     return Flags;
396 }
397
398 void dsiNotify(rpmDepSet ds, const char * where, int rc)
399 {
400     if (!(ds != NULL && ds->i >= 0 && ds->i < ds->Count))
401         return;
402     if (!(ds->Type != NULL && ds->DNEVR != NULL))
403         return;
404
405     rpmMessage(RPMMESS_DEBUG, "%9s: %-45s %-s %s\n", ds->Type,
406                 (!strcmp(ds->DNEVR, "cached") ? ds->DNEVR : ds->DNEVR+2),
407                 (rc ? _("NO ") : _("YES")),
408                 (where != NULL ? where : ""));
409 }
410
411 int dsiNext(/*@null@*/ rpmDepSet ds)
412         /*@modifies ds @*/
413 {
414     int i = -1;
415
416     if (ds != NULL && ++ds->i >= 0) {
417         if (ds->i < ds->Count) {
418             char t[2];
419             i = ds->i;
420             ds->DNEVR = _free(ds->DNEVR);
421             t[0] = ((ds->Type != NULL) ? ds->Type[0] : '\0');
422             t[1] = '\0';
423             /*@-nullstate@*/
424             ds->DNEVR = dsDNEVR(t, ds);
425             /*@=nullstate@*/
426
427         } else
428             ds->i = -1;
429
430 /*@-modfilesystem @*/
431 if (_ds_debug  < 0 && i != -1)
432 fprintf(stderr, "*** ds %p\t%s[%d]: %s\n", ds, (ds->Type ? ds->Type : "?Type?"), i, (ds->DNEVR ? ds->DNEVR : "?DNEVR?"));
433 /*@=modfilesystem @*/
434
435     }
436
437     return i;
438 }
439
440 rpmDepSet dsiInit(/*@returned@*/ /*@null@*/ rpmDepSet ds)
441         /*@modifies ds @*/
442 {
443     if (ds != NULL)
444         ds->i = -1;
445     /*@-refcounttrans@*/
446     return ds;
447     /*@=refcounttrans@*/
448 }
449
450 /**
451  * Split EVR into epoch, version, and release components.
452  * @param evr           [epoch:]version[-release] string
453  * @retval *ep          pointer to epoch
454  * @retval *vp          pointer to version
455  * @retval *rp          pointer to release
456  */
457 static
458 void parseEVR(char * evr,
459                 /*@exposed@*/ /*@out@*/ const char ** ep,
460                 /*@exposed@*/ /*@out@*/ const char ** vp,
461                 /*@exposed@*/ /*@out@*/ const char ** rp)
462         /*@modifies *ep, *vp, *rp @*/
463 {
464     const char *epoch;
465     const char *version;                /* assume only version is present */
466     const char *release;
467     char *s, *se;
468
469     s = evr;
470     while (*s && xisdigit(*s)) s++;     /* s points to epoch terminator */
471     se = strrchr(s, '-');               /* se points to version terminator */
472
473     if (*s == ':') {
474         epoch = evr;
475         *s++ = '\0';
476         version = s;
477         /*@-branchstate@*/
478         if (*epoch == '\0') epoch = "0";
479         /*@=branchstate@*/
480     } else {
481         epoch = NULL;   /* XXX disable epoch compare if missing */
482         version = evr;
483     }
484     if (se) {
485         *se++ = '\0';
486         release = se;
487     } else {
488         release = NULL;
489     }
490
491     if (ep) *ep = epoch;
492     if (vp) *vp = version;
493     if (rp) *rp = release;
494 }
495
496 int dsCompare(const rpmDepSet A, const rpmDepSet B)
497 {
498     const char *aDepend = (A->DNEVR != NULL ? xstrdup(A->DNEVR+2) : "");
499     const char *bDepend = (B->DNEVR != NULL ? xstrdup(B->DNEVR+2) : "");
500     char *aEVR, *bEVR;
501     const char *aE, *aV, *aR, *bE, *bV, *bR;
502     int result;
503     int sense;
504
505     /* Different names don't overlap. */
506     if (strcmp(A->N[A->i], B->N[B->i])) {
507         result = 0;
508         goto exit;
509     }
510
511     /* Same name. If either A or B is an existence test, always overlap. */
512     if (!((A->Flags[A->i] & RPMSENSE_SENSEMASK) && (B->Flags[B->i] & RPMSENSE_SENSEMASK))) {
513         result = 1;
514         goto exit;
515     }
516
517     /* If either EVR is non-existent or empty, always overlap. */
518     if (!(A->EVR[A->i] && *A->EVR[A->i] && B->EVR[B->i] && *B->EVR[B->i])) {
519         result = 1;
520         goto exit;
521     }
522
523     /* Both AEVR and BEVR exist. */
524     aEVR = xstrdup(A->EVR[A->i]);
525     parseEVR(aEVR, &aE, &aV, &aR);
526     bEVR = xstrdup(B->EVR[B->i]);
527     parseEVR(bEVR, &bE, &bV, &bR);
528
529     /* Compare {A,B} [epoch:]version[-release] */
530     sense = 0;
531     if (aE && *aE && bE && *bE)
532         sense = rpmvercmp(aE, bE);
533     else if (aE && *aE && atol(aE) > 0) {
534         /* XXX legacy epoch-less requires/conflicts compatibility */
535         rpmMessage(RPMMESS_DEBUG, _("the \"B\" dependency needs an epoch (assuming same as \"A\")\n\tA %s\tB %s\n"),
536                 aDepend, bDepend);
537         sense = 0;
538     } else if (bE && *bE && atol(bE) > 0)
539         sense = -1;
540
541     if (sense == 0) {
542         sense = rpmvercmp(aV, bV);
543         if (sense == 0 && aR && *aR && bR && *bR) {
544             sense = rpmvercmp(aR, bR);
545         }
546     }
547     aEVR = _free(aEVR);
548     bEVR = _free(bEVR);
549
550     /* Detect overlap of {A,B} range. */
551     result = 0;
552     if (sense < 0 && ((A->Flags[A->i] & RPMSENSE_GREATER) || (B->Flags[B->i] & RPMSENSE_LESS))) {
553         result = 1;
554     } else if (sense > 0 && ((A->Flags[A->i] & RPMSENSE_LESS) || (B->Flags[B->i] & RPMSENSE_GREATER))) {
555         result = 1;
556     } else if (sense == 0 &&
557         (((A->Flags[A->i] & RPMSENSE_EQUAL) && (B->Flags[B->i] & RPMSENSE_EQUAL)) ||
558          ((A->Flags[A->i] & RPMSENSE_LESS) && (B->Flags[B->i] & RPMSENSE_LESS)) ||
559          ((A->Flags[A->i] & RPMSENSE_GREATER) && (B->Flags[B->i] & RPMSENSE_GREATER)))) {
560         result = 1;
561     }
562
563 exit:
564     if (_noisy_range_comparison_debug_message)
565     rpmMessage(RPMMESS_DEBUG, _("  %s    A %s\tB %s\n"),
566         (result ? _("YES") : _("NO ")), aDepend, bDepend);
567     aDepend = _free(aDepend);
568     bDepend = _free(bDepend);
569     return result;
570 }
571
572 void dsProblem(rpmProblemSet tsprobs, const char * pkgNEVR, const rpmDepSet ds,
573                 const fnpyKey * suggestedKeys)
574 {
575     const char * Name =  dsiGetN(ds);
576     const char * DNEVR = dsiGetDNEVR(ds);
577     const char * EVR = dsiGetEVR(ds);
578     rpmProblemType type;
579     fnpyKey key;
580
581     if (tsprobs == NULL) return;
582
583     /*@-branchstate@*/
584     if (Name == NULL) Name = "?N?";
585     if (EVR == NULL) EVR = "?EVR?";
586     if (DNEVR == NULL) DNEVR = "? ?N? ?OP? ?EVR?";
587     /*@=branchstate@*/
588
589     rpmMessage(RPMMESS_DEBUG, _("package %s has unsatisfied %s: %s\n"),
590             pkgNEVR, ds->Type, DNEVR+2);
591
592     type = (DNEVR[0] == 'C' && DNEVR[1] == ' ')
593                 ? RPMPROB_CONFLICT : RPMPROB_REQUIRES;
594     key = (suggestedKeys ? suggestedKeys[0] : NULL);
595     rpmProblemSetAppend(tsprobs, type, pkgNEVR, key,
596                         NULL, NULL, DNEVR, 0);
597 }
598
599 int rangeMatchesDepFlags (Header h, const rpmDepSet req)
600 {
601     int scareMem = 1;
602     rpmDepSet provides = NULL;
603     int result = 0;
604
605     if (!(req->Flags[req->i] & RPMSENSE_SENSEMASK) || !req->EVR[req->i] || *req->EVR[req->i] == '\0')
606         return 1;
607
608     /* Get provides information from header */
609     provides = dsiInit(dsNew(h, RPMTAG_PROVIDENAME, scareMem));
610     if (provides == NULL)
611         goto exit;      /* XXX should never happen */
612
613     /*
614      * Rpm prior to 3.0.3 did not have versioned provides.
615      * If no provides version info is available, match any/all requires
616      * with same name.
617      */
618     if (provides->EVR == NULL) {
619         result = 1;
620         goto exit;
621     }
622
623     result = 0;
624     if (provides != NULL)
625     while (dsiNext(provides) >= 0) {
626
627         /* Filter out provides that came along for the ride. */
628         if (strcmp(provides->N[provides->i], req->N[req->i]))
629             continue;
630
631         result = dsCompare(provides, req);
632
633         /* If this provide matches the require, we're done. */
634         if (result)
635             break;
636     }
637
638 exit:
639     provides = dsFree(provides);
640
641     return result;
642 }
643
644 int headerMatchesDepFlags(const Header h, const rpmDepSet req)
645 {
646     HGE_t hge = (HGE_t)headerGetEntryMinMemory;
647     const char * pkgN, * v, * r;
648     int_32 * epoch;
649     const char * pkgEVR;
650     char * t;
651     int_32 pkgFlags = RPMSENSE_EQUAL;
652     rpmDepSet pkg;
653     int rc = 1; /* XXX assume match as names should be the same already here */
654
655     if (!((req->Flags[req->i] & RPMSENSE_SENSEMASK) && req->EVR[req->i] && *req->EVR[req->i]))
656         return rc;
657
658     /* Get package information from header */
659     (void) headerNVR(h, &pkgN, &v, &r);
660
661     pkgEVR = t = alloca(21 + strlen(v) + 1 + strlen(r) + 1);
662     *t = '\0';
663     if (hge(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) {
664         sprintf(t, "%d:", *epoch);
665         while (*t != '\0')
666             t++;
667     }
668     (void) stpcpy( stpcpy( stpcpy(t, v) , "-") , r);
669
670     if ((pkg = dsSingle(RPMTAG_PROVIDENAME, pkgN, pkgEVR, pkgFlags)) != NULL) {
671         rc = dsCompare(pkg, req);
672         pkg = dsFree(pkg);
673     }
674
675     return rc;
676 }