- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# build/reqprov.c

Go to the documentation of this file.

    00001
    00006 #include "system.h"
    00007
    00008 #include <rpmio.h>
    00009 #define _RPMEVR_INTERNAL
    00010 #include "rpmbuild.h"
    00011 #include "debug.h"
    00012
    00013 int addReqProv(/*@unused@*/ Spec spec, Header h, /*@unused@*/ rpmTag tagN,
    00014                 const char * N, const char * EVR, rpmsenseFlags Flags,
    00015                 uint32_t index)
    00016 {
    00017     HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
    00018     const char ** names;
    00019     rpmTag nametag = 0;
    00020     rpmTag versiontag = 0;
    00021     rpmTag flagtag = 0;
    00022     rpmTag indextag = 0;
    00023     int len;
    00024     rpmsenseFlags extra = RPMSENSE_ANY;
    00025     int xx;
    00026
    00027     if (Flags & RPMSENSE_PROVIDES) {
    00028         nametag = RPMTAG_PROVIDENAME;
    00029         versiontag = RPMTAG_PROVIDEVERSION;
    00030         flagtag = RPMTAG_PROVIDEFLAGS;
    00031         extra = Flags & RPMSENSE_FIND_PROVIDES;
    00032     } else if (Flags & RPMSENSE_OBSOLETES) {
    00033         nametag = RPMTAG_OBSOLETENAME;
    00034         versiontag = RPMTAG_OBSOLETEVERSION;
    00035         flagtag = RPMTAG_OBSOLETEFLAGS;
    00036     } else if (Flags & RPMSENSE_CONFLICTS) {
    00037         nametag = RPMTAG_CONFLICTNAME;
    00038         versiontag = RPMTAG_CONFLICTVERSION;
    00039         flagtag = RPMTAG_CONFLICTFLAGS;
    00040     } else if (Flags & RPMSENSE_TRIGGER) {
    00041         nametag = RPMTAG_TRIGGERNAME;
    00042         versiontag = RPMTAG_TRIGGERVERSION;
    00043         flagtag = RPMTAG_TRIGGERFLAGS;
    00044         indextag = RPMTAG_TRIGGERINDEX;
    00045         extra = Flags & RPMSENSE_TRIGGER;
    00046     } else {
    00047         nametag = RPMTAG_REQUIRENAME;
    00048         versiontag = RPMTAG_REQUIREVERSION;
    00049         flagtag = RPMTAG_REQUIREFLAGS;
    00050         extra = Flags & _ALL_REQUIRES_MASK;
    00051     }
    00052
    00053     Flags = (Flags & RPMSENSE_SENSEMASK) | extra;
    00054
    00055     if (EVR == NULL)
    00056         EVR = "";
    00057
    00058     /* Check for duplicate dependencies. */
    00059     he->tag = nametag;
    00060     xx = headerGet(h, he, 0);
    00061     names = he->p.argv;
    00062     len = he->c;
    00063     if (xx) {
    00064         const char ** versions = NULL;
    00065         uint32_t * flags = NULL;
    00066         uint32_t * indexes = NULL;
    00067         int duplicate = 0;
    00068
    00069         if (flagtag) {
    00070             he->tag = versiontag;
    00071             xx = headerGet(h, he, 0);
    00072             versions = he->p.argv;
    00073             he->tag = flagtag;
    00074             xx = headerGet(h, he, 0);
    00075             flags = he->p.ui32p;
    00076         }
    00077         if (indextag) {
    00078             he->tag = indextag;
    00079             xx = headerGet(h, he, 0);
    00080             indexes = he->p.ui32p;
    00081         }
    00082
    00083         while (len > 0) {
    00084             len--;
    00085             if (strcmp(names[len], N))
    00086                 continue;
    00087             if (flagtag && versions != NULL &&
    00088                 (strcmp(versions[len], EVR) || flags[len] != Flags))
    00089                 continue;
    00090             if (indextag && indexes != NULL && indexes[len] != index)
    00091                 continue;
    00092
    00093             /* This is a duplicate dependency. */
    00094             duplicate = 1;
    00095
    00096             break;
    00097         }
    00098         names = _free(names);
    00099         versions = _free(versions);
    00100         flags = _free(flags);
    00101         indexes = _free(indexes);
    00102         if (duplicate)
    00103             return 0;
    00104     }
    00105
    00106     /* Add this dependency. */
    00107     he->tag = nametag;
    00108     he->t = RPM_STRING_ARRAY_TYPE;
    00109     he->p.argv = &N;
    00110     he->c = 1;
    00111     he->append = 1;
    00112     xx = headerPut(h, he, 0);
    00113     he->append = 0;
    00114
    00115     if (flagtag) {
    00116         he->tag = versiontag;
    00117         he->t = RPM_STRING_ARRAY_TYPE;
    00118         he->p.argv = &EVR;
    00119         he->c = 1;
    00120         he->append = 1;
    00121         xx = headerPut(h, he, 0);
    00122         he->append = 0;
    00123
    00124         he->tag = flagtag;
    00125         he->t = RPM_UINT32_TYPE;
    00126         he->p.ui32p = (uint32_t *) &Flags;
    00127         he->c = 1;
    00128         he->append = 1;
    00129         xx = headerPut(h, he, 0);
    00130         he->append = 0;
    00131     }
    00132     if (indextag) {
    00133         he->tag = indextag;
    00134         he->t = RPM_UINT32_TYPE;
    00135         he->p.ui32p = &index;
    00136         he->c = 1;
    00137         he->append = 1;
    00138         xx = headerPut(h, he, 0);
    00139         he->append = 0;
    00140     }
    00141
    00142     return 0;
    00143 }
    00144
    00145 int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR)
    00146 {
    00147     char * reqname = alloca(sizeof("rpmlib()") + strlen(feature));
    00148
    00149     (void) stpcpy( stpcpy( stpcpy(reqname, "rpmlib("), feature), ")");
    00150
    00151     /* XXX 1st arg is unused */
    00152    return addReqProv(NULL, h, RPMTAG_REQUIRENAME, reqname, featureEVR,
    00153         RPMSENSE_RPMLIB|(RPMSENSE_LESS|RPMSENSE_EQUAL), 0);
    00154 }