6 #include <rpm/rpmtag.h>
7 #include <rpm/rpmlib.h> /* rpmvercmp */
8 #include <rpm/rpmstring.h>
9 #include <rpm/rpmlog.h>
10 #include <rpm/rpmds.h>
15 * Enable noisy range comparison debugging message?
17 static int _noisy_range_comparison_debug_message = 0;
21 int _rpmds_nopromote = 1;
23 int _rpmds_unspecified_epoch_noise = 0;
26 * A package dependency set.
29 const char * Type; /*!< Tag name. */
30 char * DNEVR; /*!< Formatted dependency string. */
31 Header h; /*!< Header for dependency set (or NULL) */
32 const char ** N; /*!< Name. */
33 const char ** EVR; /*!< Epoch-Version-Release. */
34 rpmsenseFlags * Flags; /*!< Bit(s) identifying context/comparison. */
35 uint32_t * Color; /*!< Bit(s) calculated from file color(s). */
36 int32_t * Refs; /*!< No. of file refs. */
37 time_t BT; /*!< Package build time tie breaker. */
38 rpm_tag_t tagN; /*!< Header tag. */
39 rpm_tagtype_t Nt, EVRt, Ft; /*!< Tag data types. */
40 int32_t Count; /*!< No. of elements */
41 int i; /*!< Element index. */
42 unsigned l; /*!< Low element (bsearch). */
43 unsigned u; /*!< High element (bsearch). */
44 int nopromote; /*!< Don't promote Epoch: in rpmdsCompare()? */
45 int nrefs; /*!< Reference count. */
47 rpmds rpmdsUnlink(rpmds ds, const char * msg)
49 if (ds == NULL) return NULL;
50 if (_rpmds_debug && msg != NULL)
51 fprintf(stderr, "--> ds %p -- %d %s\n", ds, ds->nrefs, msg);
56 rpmds rpmdsLink(rpmds ds, const char * msg)
58 if (ds == NULL) return NULL;
61 if (_rpmds_debug && msg != NULL)
62 fprintf(stderr, "--> ds %p ++ %d %s\n", ds, ds->nrefs, msg);
67 rpmds rpmdsFree(rpmds ds)
69 HFD_t hfd = headerFreeData;
70 rpm_tag_t tagEVR, tagF;
76 return rpmdsUnlink(ds, ds->Type);
79 fprintf(stderr, "*** ds %p\t%s[%d]\n", ds, ds->Type, ds->Count);
81 if (ds->tagN == RPMTAG_PROVIDENAME) {
82 tagEVR = RPMTAG_PROVIDEVERSION;
83 tagF = RPMTAG_PROVIDEFLAGS;
85 if (ds->tagN == RPMTAG_REQUIRENAME) {
86 tagEVR = RPMTAG_REQUIREVERSION;
87 tagF = RPMTAG_REQUIREFLAGS;
89 if (ds->tagN == RPMTAG_CONFLICTNAME) {
90 tagEVR = RPMTAG_CONFLICTVERSION;
91 tagF = RPMTAG_CONFLICTFLAGS;
93 if (ds->tagN == RPMTAG_OBSOLETENAME) {
94 tagEVR = RPMTAG_OBSOLETEVERSION;
95 tagF = RPMTAG_OBSOLETEFLAGS;
97 if (ds->tagN == RPMTAG_TRIGGERNAME) {
98 tagEVR = RPMTAG_TRIGGERVERSION;
99 tagF = RPMTAG_TRIGGERFLAGS;
104 ds->N = hfd(ds->N, ds->Nt);
105 ds->EVR = hfd(ds->EVR, ds->EVRt);
106 ds->Flags = (ds->h != NULL ? hfd(ds->Flags, ds->Ft) : _free(ds->Flags));
107 ds->h = headerFree(ds->h);
110 ds->DNEVR = _free(ds->DNEVR);
111 ds->Color = _free(ds->Color);
112 ds->Refs = _free(ds->Refs);
114 (void) rpmdsUnlink(ds, ds->Type);
115 memset(ds, 0, sizeof(*ds)); /* XXX trash and burn */
120 rpmds rpmdsNew(Header h, rpm_tag_t tagN, int flags)
122 int scareMem = (flags & 0x1);
124 (scareMem ? (HGE_t) headerGetEntryMinMemory : (HGE_t) headerGetEntry);
125 rpm_tag_t tagBT = RPMTAG_BUILDTIME;
128 rpm_tag_t tagEVR, tagF;
135 if (tagN == RPMTAG_PROVIDENAME) {
137 tagEVR = RPMTAG_PROVIDEVERSION;
138 tagF = RPMTAG_PROVIDEFLAGS;
140 if (tagN == RPMTAG_REQUIRENAME) {
142 tagEVR = RPMTAG_REQUIREVERSION;
143 tagF = RPMTAG_REQUIREFLAGS;
145 if (tagN == RPMTAG_CONFLICTNAME) {
147 tagEVR = RPMTAG_CONFLICTVERSION;
148 tagF = RPMTAG_CONFLICTFLAGS;
150 if (tagN == RPMTAG_OBSOLETENAME) {
152 tagEVR = RPMTAG_OBSOLETEVERSION;
153 tagF = RPMTAG_OBSOLETEFLAGS;
155 if (tagN == RPMTAG_TRIGGERNAME) {
157 tagEVR = RPMTAG_TRIGGERVERSION;
158 tagF = RPMTAG_TRIGGERFLAGS;
162 if (hge(h, tagN, &Nt, (rpm_data_t *) &N, &Count)
163 && N != NULL && Count > 0)
167 ds = xcalloc(1, sizeof(*ds));
169 ds->h = (scareMem ? headerLink(h) : NULL);
176 ds->nopromote = _rpmds_nopromote;
178 xx = hge(h, tagEVR, &ds->EVRt, (rpm_data_t *) &ds->EVR, NULL);
179 xx = hge(h, tagF, &ds->Ft, (rpm_data_t *) &ds->Flags, NULL);
180 if (!scareMem && ds->Flags != NULL)
181 ds->Flags = memcpy(xmalloc(ds->Count * sizeof(*ds->Flags)),
182 ds->Flags, ds->Count * sizeof(*ds->Flags));
183 xx = hge(h, tagBT, &BTt, (rpm_data_t *) &BTp, NULL);
184 ds->BT = (xx && BTp != NULL && BTt == RPM_INT32_TYPE ? *BTp : 0);
185 ds->Color = xcalloc(Count, sizeof(*ds->Color));
186 ds->Refs = xcalloc(Count, sizeof(*ds->Refs));
188 if (_rpmds_debug < 0)
189 fprintf(stderr, "*** ds %p\t%s[%d]\n", ds, ds->Type, ds->Count);
194 /* FIX: ds->Flags may be NULL */
195 ds = rpmdsLink(ds, (ds ? ds->Type : RPMDBG()));
200 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds)
206 if (dspfx) nb += strlen(dspfx) + 1;
207 if (ds->N[ds->i]) nb += strlen(ds->N[ds->i]);
208 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
209 if (ds->Flags != NULL && (ds->Flags[ds->i] & RPMSENSE_SENSEMASK)) {
211 if (ds->Flags[ds->i] & RPMSENSE_LESS) nb++;
212 if (ds->Flags[ds->i] & RPMSENSE_GREATER) nb++;
213 if (ds->Flags[ds->i] & RPMSENSE_EQUAL) nb++;
215 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
216 if (ds->EVR != NULL && ds->EVR[ds->i] && *ds->EVR[ds->i]) {
218 nb += strlen(ds->EVR[ds->i]);
221 t = tbuf = xmalloc(nb + 1);
223 t = stpcpy(t, dspfx);
227 t = stpcpy(t, ds->N[ds->i]);
228 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
229 if (ds->Flags != NULL && (ds->Flags[ds->i] & RPMSENSE_SENSEMASK)) {
230 if (t != tbuf) *t++ = ' ';
231 if (ds->Flags[ds->i] & RPMSENSE_LESS) *t++ = '<';
232 if (ds->Flags[ds->i] & RPMSENSE_GREATER) *t++ = '>';
233 if (ds->Flags[ds->i] & RPMSENSE_EQUAL) *t++ = '=';
235 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
236 if (ds->EVR != NULL && ds->EVR[ds->i] && *ds->EVR[ds->i]) {
237 if (t != tbuf) *t++ = ' ';
238 t = stpcpy(t, ds->EVR[ds->i]);
244 rpmds rpmdsThis(Header h, rpm_tag_t tagN, rpmsenseFlags Flags)
246 HGE_t hge = (HGE_t) headerGetEntryMinMemory;
249 const char * n, * v, * r;
251 const char ** N, ** EVR;
255 if (tagN == RPMTAG_PROVIDENAME) {
258 if (tagN == RPMTAG_REQUIRENAME) {
261 if (tagN == RPMTAG_CONFLICTNAME) {
264 if (tagN == RPMTAG_OBSOLETENAME) {
267 if (tagN == RPMTAG_TRIGGERNAME) {
272 xx = headerNVR(h, &n, &v, &r);
274 xx = hge(h, RPMTAG_EPOCH, NULL, (rpm_data_t *)&ep, NULL);
276 t = xmalloc(sizeof(*N) + strlen(n) + 1);
277 N = (const char **) t;
283 t = xmalloc(sizeof(*EVR) +
284 (ep ? 20 : 0) + strlen(v) + strlen(r) + sizeof("-"));
285 EVR = (const char **) t;
290 sprintf(t, "%d:", *ep);
293 t = stpcpy( stpcpy( stpcpy( t, v), "-"), r);
295 ds = xcalloc(1, sizeof(*ds));
301 ds->Nt = RPM_FORCEFREE_TYPE; /* XXX to insure that hfd will free */
303 ds->EVRt = RPM_FORCEFREE_TYPE; /* XXX to insure that hfd will free */
304 ds->Flags = xmalloc(sizeof(*ds->Flags)); ds->Flags[0] = Flags;
307 pre[0] = ds->Type[0];
309 /* LCL: ds->Type may be NULL ??? */
310 ds->DNEVR = rpmdsNewDNEVR(pre, ds);
314 return rpmdsLink(ds, (ds ? ds->Type : RPMDBG()));
317 rpmds rpmdsSingle(rpm_tag_t tagN, const char * N, const char * EVR, rpmsenseFlags Flags)
322 if (tagN == RPMTAG_PROVIDENAME) {
325 if (tagN == RPMTAG_REQUIRENAME) {
328 if (tagN == RPMTAG_CONFLICTNAME) {
331 if (tagN == RPMTAG_OBSOLETENAME) {
334 if (tagN == RPMTAG_TRIGGERNAME) {
339 ds = xcalloc(1, sizeof(*ds));
343 { time_t now = time(NULL);
347 ds->N = xmalloc(sizeof(*ds->N)); ds->N[0] = N;
348 ds->Nt = RPM_FORCEFREE_TYPE; /* XXX to insure that hfd will free */
349 ds->EVR = xmalloc(sizeof(*ds->EVR)); ds->EVR[0] = EVR;
350 ds->EVRt = RPM_FORCEFREE_TYPE; /* XXX to insure that hfd will free */
351 ds->Flags = xmalloc(sizeof(*ds->Flags)); ds->Flags[0] = Flags;
356 ds->DNEVR = rpmdsNewDNEVR(t, ds);
360 return rpmdsLink(ds, (ds ? ds->Type : NULL));
363 int rpmdsCount(const rpmds ds)
365 return (ds != NULL ? ds->Count : 0);
368 int rpmdsIx(const rpmds ds)
370 return (ds != NULL ? ds->i : -1);
373 int rpmdsSetIx(rpmds ds, int ix)
384 const char * rpmdsDNEVR(const rpmds ds)
386 const char * DNEVR = NULL;
388 if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
389 if (ds->DNEVR != NULL)
395 const char * rpmdsN(const rpmds ds)
397 const char * N = NULL;
399 if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
406 const char * rpmdsEVR(const rpmds ds)
408 const char * EVR = NULL;
410 if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
412 EVR = ds->EVR[ds->i];
417 rpmsenseFlags rpmdsFlags(const rpmds ds)
419 rpmsenseFlags Flags = 0;
421 if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
422 if (ds->Flags != NULL)
423 Flags = ds->Flags[ds->i];
428 rpm_tag_t rpmdsTagN(const rpmds ds)
437 time_t rpmdsBT(const rpmds ds)
440 if (ds != NULL && ds->BT > 0)
445 time_t rpmdsSetBT(const rpmds ds, time_t BT)
455 int rpmdsNoPromote(const rpmds ds)
460 nopromote = ds->nopromote;
464 int rpmdsSetNoPromote(rpmds ds, int nopromote)
469 onopromote = ds->nopromote;
470 ds->nopromote = nopromote;
475 uint32_t rpmdsColor(const rpmds ds)
479 if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
480 if (ds->Color != NULL)
481 Color = ds->Color[ds->i];
486 uint32_t rpmdsSetColor(const rpmds ds, uint32_t color)
490 if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
491 if (ds->Color != NULL) {
492 ocolor = ds->Color[ds->i];
493 ds->Color[ds->i] = color;
499 int32_t rpmdsRefs(const rpmds ds)
503 if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
504 if (ds->Refs != NULL)
505 Refs = ds->Refs[ds->i];
510 int32_t rpmdsSetRefs(const rpmds ds, int32_t refs)
514 if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) {
515 if (ds->Refs != NULL) {
516 orefs = ds->Refs[ds->i];
517 ds->Refs[ds->i] = refs;
523 void rpmdsNotify(rpmds ds, const char * where, int rc)
525 if (!(ds != NULL && ds->i >= 0 && ds->i < ds->Count))
527 if (!(ds->Type != NULL && ds->DNEVR != NULL))
530 rpmlog(RPMLOG_DEBUG, "%9s: %-45s %-s %s\n", ds->Type,
531 (!strcmp(ds->DNEVR, "cached") ? ds->DNEVR : ds->DNEVR+2),
532 (rc ? _("NO ") : _("YES")),
533 (where != NULL ? where : ""));
536 int rpmdsNext(rpmds ds)
540 if (ds != NULL && ++ds->i >= 0) {
541 if (ds->i < ds->Count) {
544 ds->DNEVR = _free(ds->DNEVR);
545 t[0] = ((ds->Type != NULL) ? ds->Type[0] : '\0');
547 ds->DNEVR = rpmdsNewDNEVR(t, ds);
552 if (_rpmds_debug < 0 && i != -1)
553 fprintf(stderr, "*** ds %p\t%s[%d]: %s\n", ds, (ds->Type ? ds->Type : "?Type?"), i, (ds->DNEVR ? ds->DNEVR : "?DNEVR?"));
560 rpmds rpmdsInit(rpmds ds)
568 const char ** rpmdsDupArgv(const char ** argv, int argc)
577 for (ac = 0; ac < argc; ac++) {
578 assert(argv[ac] != NULL);
579 nb += strlen(argv[ac]) + 1;
581 nb += (ac + 1) * sizeof(*av);
584 t = (char *) (av + ac + 1);
585 for (ac = 0; ac < argc; ac++) {
587 t = stpcpy(t, argv[ac]) + 1;
593 static rpmds rpmdsDup(const rpmds ods)
595 rpmds ds = xcalloc(1, sizeof(*ds));
598 ds->h = (ods->h != NULL ? headerLink(ods->h) : NULL);
599 ds->Type = ods->Type;
600 ds->tagN = ods->tagN;
601 ds->Count = ods->Count;
606 nb = (ds->Count+1) * sizeof(*ds->N);
607 ds->N = (ds->h != NULL
608 ? memcpy(xmalloc(nb), ods->N, nb)
609 : rpmdsDupArgv(ods->N, ods->Count) );
612 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
613 assert(ods->EVR != NULL);
614 assert(ods->Flags != NULL);
616 nb = (ds->Count+1) * sizeof(*ds->EVR);
617 ds->EVR = (ds->h != NULL
618 ? memcpy(xmalloc(nb), ods->EVR, nb)
619 : rpmdsDupArgv(ods->EVR, ods->Count) );
620 ds->EVRt = ods->EVRt;
622 nb = (ds->Count * sizeof(*ds->Flags));
623 ds->Flags = (ds->h != NULL
625 : memcpy(xmalloc(nb), ods->Flags, nb) );
628 /* FIX: ds->Flags is kept, not only */
629 return rpmdsLink(ds, (ds ? ds->Type : NULL));
633 int rpmdsFind(rpmds ds, const rpmds ods)
637 if (ds == NULL || ods == NULL)
642 while (ds->l < ds->u) {
643 ds->i = (ds->l + ds->u) / 2;
645 comparison = strcmp(ods->N[ods->i], ds->N[ds->i]);
647 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
648 if (comparison == 0 && ods->EVR && ds->EVR)
649 comparison = strcmp(ods->EVR[ods->i], ds->EVR[ds->i]);
650 if (comparison == 0 && ods->Flags && ds->Flags)
651 comparison = (ods->Flags[ods->i] - ds->Flags[ds->i]);
655 else if (comparison > 0)
663 int rpmdsMerge(rpmds * dsp, rpmds ods)
668 rpmsenseFlags * Flags;
672 if (dsp == NULL || ods == NULL)
675 /* If not initialized yet, dup the 1st entry. */
679 *dsp = rpmdsDup(ods);
690 ods = rpmdsInit(ods);
692 while (rpmdsNext(ods) >= 0) {
694 * If this entry is already present, don't bother.
696 if (rpmdsFind(ds, ods) >= 0)
702 for (j = ds->Count; j > ds->u; j--)
703 ds->N[j] = ds->N[j-1];
704 ds->N[ds->u] = ods->N[ods->i];
705 N = rpmdsDupArgv(ds->N, ds->Count+1);
706 ds->N = _free(ds->N);
709 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
710 assert(ods->EVR != NULL);
711 assert(ods->Flags != NULL);
713 for (j = ds->Count; j > ds->u; j--)
714 ds->EVR[j] = ds->EVR[j-1];
715 ds->EVR[ds->u] = ods->EVR[ods->i];
716 EVR = rpmdsDupArgv(ds->EVR, ds->Count+1);
717 ds->EVR = _free(ds->EVR);
720 Flags = xmalloc((ds->Count+1) * sizeof(*Flags));
722 memcpy(Flags, ds->Flags, ds->u * sizeof(*Flags));
723 if (ds->u < ds->Count)
724 memcpy(Flags + ds->u + 1, ds->Flags + ds->u, (ds->Count - ds->u) * sizeof(*Flags));
725 Flags[ds->u] = ods->Flags[ods->i];
726 ds->Flags = _free(ds->Flags);
738 * Split EVR into epoch, version, and release components.
739 * @param evr [epoch:]version[-release] string
740 * @retval *ep pointer to epoch
741 * @retval *vp pointer to version
742 * @retval *rp pointer to release
745 void parseEVR(char * evr,
751 const char *version; /* assume only version is present */
756 while (*s && xisdigit(*s)) s++; /* s points to epoch terminator */
757 se = strrchr(s, '-'); /* se points to version terminator */
763 if (*epoch == '\0') epoch = "0";
765 epoch = NULL; /* XXX disable epoch compare if missing */
776 if (vp) *vp = version;
777 if (rp) *rp = release;
780 int rpmdsCompare(const rpmds A, const rpmds B)
782 char *aDepend = (A->DNEVR != NULL ? xstrdup(A->DNEVR+2) : "");
783 char *bDepend = (B->DNEVR != NULL ? xstrdup(B->DNEVR+2) : "");
785 const char *aE, *aV, *aR, *bE, *bV, *bR;
789 /* Different names don't overlap. */
790 if (strcmp(A->N[A->i], B->N[B->i])) {
795 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
796 if (!(A->EVR && A->Flags && B->EVR && B->Flags)) {
801 /* Same name. If either A or B is an existence test, always overlap. */
802 if (!((A->Flags[A->i] & RPMSENSE_SENSEMASK) && (B->Flags[B->i] & RPMSENSE_SENSEMASK))) {
807 /* If either EVR is non-existent or empty, always overlap. */
808 if (!(A->EVR[A->i] && *A->EVR[A->i] && B->EVR[B->i] && *B->EVR[B->i])) {
813 /* Both AEVR and BEVR exist. */
814 aEVR = xstrdup(A->EVR[A->i]);
815 parseEVR(aEVR, &aE, &aV, &aR);
816 bEVR = xstrdup(B->EVR[B->i]);
817 parseEVR(bEVR, &bE, &bV, &bR);
819 /* Compare {A,B} [epoch:]version[-release] */
821 if (aE && *aE && bE && *bE)
822 sense = rpmvercmp(aE, bE);
823 else if (aE && *aE && atol(aE) > 0) {
825 int lvl = (_rpmds_unspecified_epoch_noise ? RPMLOG_WARNING : RPMLOG_DEBUG);
826 rpmlog(lvl, _("The \"B\" dependency needs an epoch (assuming same epoch as \"A\")\n\tA = \"%s\"\tB = \"%s\"\n"),
831 } else if (bE && *bE && atol(bE) > 0)
835 sense = rpmvercmp(aV, bV);
836 if (sense == 0 && aR && *aR && bR && *bR)
837 sense = rpmvercmp(aR, bR);
842 /* Detect overlap of {A,B} range. */
844 if (sense < 0 && ((A->Flags[A->i] & RPMSENSE_GREATER) || (B->Flags[B->i] & RPMSENSE_LESS))) {
846 } else if (sense > 0 && ((A->Flags[A->i] & RPMSENSE_LESS) || (B->Flags[B->i] & RPMSENSE_GREATER))) {
848 } else if (sense == 0 &&
849 (((A->Flags[A->i] & RPMSENSE_EQUAL) && (B->Flags[B->i] & RPMSENSE_EQUAL)) ||
850 ((A->Flags[A->i] & RPMSENSE_LESS) && (B->Flags[B->i] & RPMSENSE_LESS)) ||
851 ((A->Flags[A->i] & RPMSENSE_GREATER) && (B->Flags[B->i] & RPMSENSE_GREATER)))) {
856 if (_noisy_range_comparison_debug_message)
857 rpmlog(RPMLOG_DEBUG, _(" %s A %s\tB %s\n"),
858 (result ? _("YES") : _("NO ")), aDepend, bDepend);
859 aDepend = _free(aDepend);
860 bDepend = _free(bDepend);
864 void rpmdsProblem(rpmps ps, const char * pkgNEVR, const rpmds ds,
865 const fnpyKey * suggestedKeys, int adding)
867 const char * Name = rpmdsN(ds);
868 const char * DNEVR = rpmdsDNEVR(ds);
869 const char * EVR = rpmdsEVR(ds);
873 if (ps == NULL) return;
875 if (Name == NULL) Name = "?N?";
876 if (EVR == NULL) EVR = "?EVR?";
877 if (DNEVR == NULL) DNEVR = "? ?N? ?OP? ?EVR?";
879 rpmlog(RPMLOG_DEBUG, _("package %s has unsatisfied %s: %s\n"),
880 pkgNEVR, ds->Type, DNEVR+2);
882 switch ((unsigned)DNEVR[0]) {
883 case 'C': type = RPMPROB_CONFLICT; break;
885 case 'R': type = RPMPROB_REQUIRES; break;
888 key = (suggestedKeys ? suggestedKeys[0] : NULL);
889 rpmpsAppend(ps, type, pkgNEVR, key, NULL, NULL, DNEVR, adding);
892 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote)
895 rpmds provides = NULL;
898 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
899 if (req->EVR == NULL || req->Flags == NULL)
902 if (!(req->Flags[req->i] & RPMSENSE_SENSEMASK) || !req->EVR[req->i] || *req->EVR[req->i] == '\0')
905 /* Get provides information from header */
906 provides = rpmdsInit(rpmdsNew(h, RPMTAG_PROVIDENAME, scareMem));
907 if (provides == NULL)
908 goto exit; /* XXX should never happen */
910 (void) rpmdsSetNoPromote(provides, nopromote);
913 * Rpm prior to 3.0.3 did not have versioned provides.
914 * If no provides version info is available, match any/all requires
917 if (provides->EVR == NULL) {
923 if (provides != NULL)
924 while (rpmdsNext(provides) >= 0) {
926 /* Filter out provides that came along for the ride. */
927 if (strcmp(provides->N[provides->i], req->N[req->i]))
930 result = rpmdsCompare(provides, req);
932 /* If this provide matches the require, we're done. */
938 provides = rpmdsFree(provides);
943 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote)
945 HGE_t hge = (HGE_t)headerGetEntryMinMemory;
946 const char * pkgN, * v, * r;
950 rpmsenseFlags pkgFlags = RPMSENSE_EQUAL;
952 int rc = 1; /* XXX assume match, names already match here */
954 /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
955 if (req->EVR == NULL || req->Flags == NULL)
958 if (!((req->Flags[req->i] & RPMSENSE_SENSEMASK) && req->EVR[req->i] && *req->EVR[req->i]))
961 /* Get package information from header */
962 (void) headerNVR(h, &pkgN, &v, &r);
964 t = alloca(21 + strlen(v) + 1 + strlen(r) + 1);
967 if (hge(h, RPMTAG_EPOCH, NULL, (rpm_data_t *) &epoch, NULL)) {
968 sprintf(t, "%d:", *epoch);
972 (void) stpcpy( stpcpy( stpcpy(t, v) , "-") , r);
974 if ((pkg = rpmdsSingle(RPMTAG_PROVIDENAME, pkgN, pkgEVR, pkgFlags)) != NULL) {
976 (void) rpmdsSetNoPromote(pkg, nopromote);
977 rc = rpmdsCompare(pkg, req);
978 pkg = rpmdsFree(pkg);