rpm 5.2.1

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