# lib/rpmlibprov.c

Go to the documentation of this file.

    00001
    00005 #include "system.h"
    00006
    00007 #include <rpmlib.h>
    00008 #include "debug.h"
    00009
    00010 static struct rpmlibProvides_s {
    00011 /*@observer@*/ /*@null@*/ const char * featureName;
    00012 /*@observer@*/ /*@null@*/ const char * featureEVR;
    00013     int featureFlags;
    00014 /*@observer@*/ /*@null@*/ const char * featureDescription;
    00015 } rpmlibProvides[] = {
    00016     { "rpmlib(VersionedDependencies)",  "3.0.3-1",
    00017         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
    00018     N_("PreReq:, Provides:, and Obsoletes: dependencies support versions.") },
    00019     { "rpmlib(CompressedFileNames)",    "3.0.4-1",
    00020         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
    00021     N_("file name(s) are stored as (dirName,baseName,dirIndex) tuple, not as path.")},
    00022     { "rpmlib(PayloadIsBzip2)",         "3.0.5-1",
    00023         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
    00024     N_("package payload is compressed using bzip2.") },
    00025     { "rpmlib(PayloadFilesHavePrefix)", "4.0-1",
    00026         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
    00027     N_("package payload file(s) have \"./\" prefix.") },
    00028     { "rpmlib(ExplicitPackageProvide)", "4.0-1",
    00029         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
    00030     N_("package name-version-release is not implicitly provided.") },
    00031     { "rpmlib(HeaderLoadSortsTags)",    "4.0.1-1",
    00032         (                RPMSENSE_EQUAL),
    00033     N_("header tags are always sorted after being loaded.") },
    00034     { "rpmlib(ScriptletInterpreterArgs)",    "4.0.3-1",
    00035         (                RPMSENSE_EQUAL),
    00036     N_("the scriptlet interpreter can use arguments from header.") },
    00037     { "rpmlib(PartialHardlinkSets)",    "4.0.4-1",
    00038         (                RPMSENSE_EQUAL),
    00039     N_("a hardlink file set may be installed without being complete.") },
    00040     { NULL,                             NULL, 0,        NULL }
    00041 };
    00042
    00043 void rpmShowRpmlibProvides(FILE * fp)
    00044 {
    00045     const struct rpmlibProvides_s * rlp;
    00046
    00047     for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
    00048         fprintf(fp, "    %s", rlp->featureName);
    00049         if (rlp->featureEVR && rlp->featureFlags)
    00050             printDepFlags(fp, rlp->featureEVR, rlp->featureFlags);
    00051         fprintf(fp, "\n");
    00052         if (rlp->featureDescription)
    00053             fprintf(fp, "\t%s\n", rlp->featureDescription);
    00054     }
    00055 }
    00056
    00057 int rpmCheckRpmlibProvides(const char * keyName, const char * keyEVR,
    00058         int keyFlags)
    00059 {
    00060     const struct rpmlibProvides_s * rlp;
    00061     int rc = 0;
    00062
    00063     for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
    00064         if (rlp->featureEVR && rlp->featureFlags)
    00065             rc = rpmRangesOverlap(keyName, keyEVR, keyFlags,
    00066                 rlp->featureName, rlp->featureEVR, rlp->featureFlags);
    00067         if (rc)
    00068             break;
    00069     }
    00070     return rc;
    00071 }
    00072
    00073 int rpmGetRpmlibProvides(const char *** provNames, int ** provFlags,
    00074                          const char *** provVersions)
    00075 {
    00076     const char ** names, ** versions;
    00077     int * flags;
    00078     int n = 0;
    00079
    00080     while (rpmlibProvides[n].featureName != NULL)
    00081         n++;
    00082
    00083     names = xcalloc((n+1), sizeof(*names));
    00084     versions = xcalloc((n+1), sizeof(*versions));
    00085     flags = xcalloc((n+1), sizeof(*flags));
    00086
    00087     for (n = 0; rpmlibProvides[n].featureName != NULL; n++) {
    00088         names[n] = rpmlibProvides[n].featureName;
    00089         flags[n] = rpmlibProvides[n].featureFlags;
    00090         versions[n] = rpmlibProvides[n].featureEVR;
    00091     }
    00092
    00093     /*@-branchstate@*/
    00094     if (provNames)
    00095         *provNames = names;
    00096     else
    00097         names = _free(names);
    00098     /*@=branchstate@*/
    00099
    00100     /*@-branchstate@*/
    00101     if (provFlags)
    00102         *provFlags = flags;
    00103     else
    00104         flags = _free(flags);
    00105     /*@=branchstate@*/
    00106
    00107     /*@-branchstate@*/
    00108     if (provVersions)
    00109         *provVersions = versions;
    00110     else
    00111         versions = _free(versions);
    00112     /*@=branchstate@*/
    00113
    00114     /*@-compmempass@*/ /* FIX: rpmlibProvides[] reachable */
    00115     return n;
    00116     /*@=compmempass@*/
    00117 }