00001
00005 #include "system.h"
00006
00007 #include <rpmlib.h>
00008 #include "debug.h"
00009
00010 static struct rpmlibProvides {
00011 const char * featureName;
00012 const char * featureEVR;
00013 int featureFlags;
00014 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 names 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 compressed using bzip2.") },
00025 { "rpmlib(PayloadFilesHavePrefix)", "4.0-1",
00026 (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
00027 N_("package payload files have \"./\" prefix.") },
00028 { "rpmlib(ExplicitPackageProvide)", "4.0-1",
00029 (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
00030 N_("package name-version-release 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 { NULL, NULL, 0, NULL }
00038 };
00039
00040 void rpmShowRpmlibProvides(FILE * fp)
00041 {
00042 const struct rpmlibProvides * rlp;
00043
00044 for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
00045 fprintf(fp, " %s", rlp->featureName);
00046 if (rlp->featureEVR && rlp->featureFlags)
00047 printDepFlags(fp, rlp->featureEVR, rlp->featureFlags);
00048 fprintf(fp, "\n");
00049 if (rlp->featureDescription)
00050 fprintf(fp, "\t%s\n", rlp->featureDescription);
00051 }
00052 }
00053
00054 int rpmCheckRpmlibProvides(const char * keyName, const char * keyEVR,
00055 int keyFlags)
00056 {
00057 const struct rpmlibProvides * rlp;
00058 int rc = 0;
00059
00060 for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
00061 if (rlp->featureEVR && rlp->featureFlags)
00062 rc = rpmRangesOverlap(keyName, keyEVR, keyFlags,
00063 rlp->featureName, rlp->featureEVR, rlp->featureFlags);
00064 if (rc)
00065 break;
00066 }
00067 return rc;
00068 }
00069
00070 int rpmGetRpmlibProvides(const char *** provNames, int ** provFlags,
00071 const char *** provVersions)
00072 {
00073 const char ** names, ** versions;
00074 int * flags;
00075 int n = 0;
00076
00077 while (rpmlibProvides[n].featureName != NULL)
00078 n++;
00079
00080 names = xcalloc((n+1), sizeof(*names));
00081 versions = xcalloc((n+1), sizeof(*versions));
00082 flags = xcalloc((n+1), sizeof(*flags));
00083
00084 for (n = 0; rpmlibProvides[n].featureName != NULL; n++) {
00085 names[n] = rpmlibProvides[n].featureName;
00086 flags[n] = rpmlibProvides[n].featureFlags;
00087 versions[n] = rpmlibProvides[n].featureEVR;
00088 }
00089
00090 if (provNames)
00091 *provNames = names;
00092 else
00093 names = _free(names);
00094
00095 if (provFlags)
00096 *provFlags = flags;
00097 else
00098 flags = _free(flags);
00099
00100 if (provVersions)
00101 *provVersions = versions;
00102 else
00103 versions = _free(versions);
00104
00105 return n;
00106 }