Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

build/reqprov.c

Go to the documentation of this file.
00001 
00006 #include "system.h"
00007 
00008 #include "rpmbuild.h"
00009 #include "debug.h"
00010 
00011 int addReqProv(/*@unused@*/ Spec spec, Header h,
00012                int depFlags, const char *depName, const char *depEVR, int index)
00013 {
00014     const char **names;
00015     int nametag = 0;
00016     int versiontag = 0;
00017     int flagtag = 0;
00018     int indextag = 0;
00019     int len;
00020     int extra = 0;
00021     
00022     if (depFlags & RPMSENSE_PROVIDES) {
00023         nametag = RPMTAG_PROVIDENAME;
00024         versiontag = RPMTAG_PROVIDEVERSION;
00025         flagtag = RPMTAG_PROVIDEFLAGS;
00026         extra = depFlags & RPMSENSE_FIND_PROVIDES;
00027     } else if (depFlags & RPMSENSE_OBSOLETES) {
00028         nametag = RPMTAG_OBSOLETENAME;
00029         versiontag = RPMTAG_OBSOLETEVERSION;
00030         flagtag = RPMTAG_OBSOLETEFLAGS;
00031     } else if (depFlags & RPMSENSE_CONFLICTS) {
00032         nametag = RPMTAG_CONFLICTNAME;
00033         versiontag = RPMTAG_CONFLICTVERSION;
00034         flagtag = RPMTAG_CONFLICTFLAGS;
00035     } else if (depFlags & RPMSENSE_PREREQ) {
00036         nametag = RPMTAG_REQUIRENAME;
00037         versiontag = RPMTAG_REQUIREVERSION;
00038         flagtag = RPMTAG_REQUIREFLAGS;
00039         extra = depFlags & _ALL_REQUIRES_MASK;
00040     } else if (depFlags & RPMSENSE_TRIGGER) {
00041         nametag = RPMTAG_TRIGGERNAME;
00042         versiontag = RPMTAG_TRIGGERVERSION;
00043         flagtag = RPMTAG_TRIGGERFLAGS;
00044         indextag = RPMTAG_TRIGGERINDEX;
00045         extra = depFlags & RPMSENSE_TRIGGER;
00046     } else {
00047         nametag = RPMTAG_REQUIRENAME;
00048         versiontag = RPMTAG_REQUIREVERSION;
00049         flagtag = RPMTAG_REQUIREFLAGS;
00050         extra = depFlags & _ALL_REQUIRES_MASK;
00051     }
00052 
00053     depFlags = (depFlags & (RPMSENSE_SENSEMASK | RPMSENSE_MULTILIB)) | extra;
00054 
00055     if (depEVR == NULL)
00056         depEVR = "";
00057     
00058     /* Check for duplicate dependencies. */
00059     if (headerGetEntry(h, nametag, NULL, (void **) &names, &len)) {
00060         const char **versions = NULL;
00061         int *flags = NULL;
00062         int *indexes = NULL;
00063         int duplicate = 0;
00064 
00065         if (flagtag) {
00066             headerGetEntry(h, versiontag, NULL, (void **) &versions, NULL);
00067             headerGetEntry(h, flagtag, NULL, (void **) &flags, NULL);
00068         }
00069         if (indextag)
00070             headerGetEntry(h, indextag, NULL, (void **) &indexes, NULL);
00071 
00072         while (len > 0) {
00073             len--;
00074             if (strcmp(names[len], depName))
00075                 continue;
00076             if (flagtag && versions != NULL &&
00077                 (strcmp(versions[len], depEVR) ||
00078         ((flags[len] | RPMSENSE_MULTILIB) != (depFlags | RPMSENSE_MULTILIB))))
00079                 continue;
00080             if (indextag && indexes != NULL && indexes[len] != index)
00081                 continue;
00082 
00083             /* This is a duplicate dependency. */
00084             duplicate = 1;
00085 
00086             if (flagtag && isDependsMULTILIB(depFlags) &&
00087                 !isDependsMULTILIB(flags[len]))
00088                     flags[len] |= RPMSENSE_MULTILIB;
00089 
00090             break;
00091         }
00092         FREE(names);
00093         FREE(versions);
00094         if (duplicate)
00095             return 0;
00096     }
00097 
00098     /* Add this dependency. */
00099     headerAddOrAppendEntry(h, nametag, RPM_STRING_ARRAY_TYPE, &depName, 1);
00100     if (flagtag) {
00101         headerAddOrAppendEntry(h, versiontag,
00102                                RPM_STRING_ARRAY_TYPE, &depEVR, 1);
00103         headerAddOrAppendEntry(h, flagtag,
00104                                RPM_INT32_TYPE, &depFlags, 1);
00105     }
00106     if (indextag)
00107         headerAddOrAppendEntry(h, indextag, RPM_INT32_TYPE, &index, 1);
00108 
00109     return 0;
00110 }
00111 
00112 int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR)
00113 {
00114     char * reqname = alloca(sizeof("rpmlib()") + strlen(feature));
00115 
00116     (void) stpcpy( stpcpy( stpcpy(reqname, "rpmlib("), feature), ")");
00117 
00118     /* XXX 1st arg is unused */
00119    return addReqProv(NULL, h, RPMSENSE_RPMLIB|(RPMSENSE_LESS|RPMSENSE_EQUAL),
00120         reqname, featureEVR, 0);
00121 }

Generated at Mon May 21 08:53:38 2001 for rpm by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001