2 * \file build/reqprov.c
3 * Add dependency tags to package header(s).
11 int addReqProv(/*@unused@*/ Spec spec, Header h,
12 rpmsenseFlags depFlags, const char *depName, const char *depEVR,
15 HGE_t hge = (HGE_t)headerGetEntryMinMemory;
16 HFD_t hfd = headerFreeData;
20 rpmTag versiontag = 0;
24 rpmsenseFlags extra = RPMSENSE_ANY;
26 if (depFlags & RPMSENSE_PROVIDES) {
27 nametag = RPMTAG_PROVIDENAME;
28 versiontag = RPMTAG_PROVIDEVERSION;
29 flagtag = RPMTAG_PROVIDEFLAGS;
30 extra = depFlags & RPMSENSE_FIND_PROVIDES;
31 } else if (depFlags & RPMSENSE_OBSOLETES) {
32 nametag = RPMTAG_OBSOLETENAME;
33 versiontag = RPMTAG_OBSOLETEVERSION;
34 flagtag = RPMTAG_OBSOLETEFLAGS;
35 } else if (depFlags & RPMSENSE_CONFLICTS) {
36 nametag = RPMTAG_CONFLICTNAME;
37 versiontag = RPMTAG_CONFLICTVERSION;
38 flagtag = RPMTAG_CONFLICTFLAGS;
39 } else if (depFlags & RPMSENSE_PREREQ) {
40 nametag = RPMTAG_REQUIRENAME;
41 versiontag = RPMTAG_REQUIREVERSION;
42 flagtag = RPMTAG_REQUIREFLAGS;
43 extra = depFlags & _ALL_REQUIRES_MASK;
44 } else if (depFlags & RPMSENSE_TRIGGER) {
45 nametag = RPMTAG_TRIGGERNAME;
46 versiontag = RPMTAG_TRIGGERVERSION;
47 flagtag = RPMTAG_TRIGGERFLAGS;
48 indextag = RPMTAG_TRIGGERINDEX;
49 extra = depFlags & RPMSENSE_TRIGGER;
51 nametag = RPMTAG_REQUIRENAME;
52 versiontag = RPMTAG_REQUIREVERSION;
53 flagtag = RPMTAG_REQUIREFLAGS;
54 extra = depFlags & _ALL_REQUIRES_MASK;
57 depFlags = (depFlags & (RPMSENSE_SENSEMASK | RPMSENSE_MULTILIB)) | extra;
62 /* Check for duplicate dependencies. */
63 if (hge(h, nametag, &dnt, (void **) &names, &len)) {
64 const char ** versions = NULL;
65 rpmTagType dvt = RPM_STRING_ARRAY_TYPE;
71 (void) hge(h, versiontag, &dvt, (void **) &versions, NULL);
72 (void) hge(h, flagtag, NULL, (void **) &flags, NULL);
75 (void) hge(h, indextag, NULL, (void **) &indexes, NULL);
79 if (strcmp(names[len], depName))
81 if (flagtag && versions != NULL &&
82 (strcmp(versions[len], depEVR) ||
83 ((flags[len] | RPMSENSE_MULTILIB) != (depFlags | RPMSENSE_MULTILIB))))
85 if (indextag && indexes != NULL && indexes[len] != index)
88 /* This is a duplicate dependency. */
91 if (flagtag && isDependsMULTILIB(depFlags) &&
92 !isDependsMULTILIB(flags[len]))
93 flags[len] |= RPMSENSE_MULTILIB;
97 names = hfd(names, dnt);
98 versions = hfd(versions, dvt);
103 /* Add this dependency. */
104 (void) headerAddOrAppendEntry(h, nametag, RPM_STRING_ARRAY_TYPE, &depName, 1);
106 (void) headerAddOrAppendEntry(h, versiontag,
107 RPM_STRING_ARRAY_TYPE, &depEVR, 1);
108 (void) headerAddOrAppendEntry(h, flagtag,
109 RPM_INT32_TYPE, &depFlags, 1);
112 (void) headerAddOrAppendEntry(h, indextag, RPM_INT32_TYPE, &index, 1);
117 int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR)
119 char * reqname = alloca(sizeof("rpmlib()") + strlen(feature));
121 (void) stpcpy( stpcpy( stpcpy(reqname, "rpmlib("), feature), ")");
123 /* XXX 1st arg is unused */
124 return addReqProv(NULL, h, RPMSENSE_RPMLIB|(RPMSENSE_LESS|RPMSENSE_EQUAL),
125 reqname, featureEVR, 0);