1.1 --- a/src/import-yum.c Mon Jun 16 15:40:30 2008 -0400
1.2 +++ b/src/import-yum.c Fri Jun 20 15:10:34 2008 -0400
1.3 @@ -21,6 +21,7 @@
1.4
1.5 #include <string.h>
1.6 #include <stdio.h>
1.7 +#include <stdint.h>
1.8 #include <sys/stat.h>
1.9 #include <sys/mman.h>
1.10 #include <unistd.h>
1.11 @@ -54,36 +55,34 @@
1.12 struct import_property_context *current_property_context;
1.13 char name[256], arch[64], buffer[512], *p;
1.14 char pkgid[128];
1.15 + uint32_t property_type;
1.16 int state;
1.17 };
1.18
1.19 -static enum razor_version_relation
1.20 -yum_to_razor_flags (const char *flags)
1.21 +static uint32_t
1.22 +yum_to_razor_relation (const char *flags)
1.23 {
1.24 - /* FIXME? */
1.25 - if (!flags)
1.26 - return RAZOR_VERSION_EQUAL;
1.27 -
1.28 if (flags[0] == 'L') {
1.29 if (flags[1] == 'T')
1.30 - return RAZOR_VERSION_LESS;
1.31 + return RAZOR_PROPERTY_LESS;
1.32 else
1.33 - return RAZOR_VERSION_LESS_OR_EQUAL;
1.34 + return RAZOR_PROPERTY_LESS | RAZOR_PROPERTY_EQUAL;
1.35 } else if (flags[0] == 'G') {
1.36 if (flags[1] == 'T')
1.37 - return RAZOR_VERSION_GREATER;
1.38 + return RAZOR_PROPERTY_GREATER;
1.39 else
1.40 - return RAZOR_VERSION_GREATER_OR_EQUAL;
1.41 + return RAZOR_PROPERTY_GREATER | RAZOR_PROPERTY_EQUAL;
1.42 } else
1.43 - return RAZOR_VERSION_EQUAL;
1.44 + return RAZOR_PROPERTY_EQUAL;
1.45 }
1.46
1.47 static void
1.48 yum_primary_start_element(void *data, const char *name, const char **atts)
1.49 {
1.50 struct yum_context *ctx = data;
1.51 - const char *n, *epoch, *version, *release, *flags;
1.52 + const char *n, *epoch, *version, *release;
1.53 char buffer[128];
1.54 + uint32_t pre, relation, flags;
1.55 int i;
1.56
1.57 if (strcmp(name, "name") == 0) {
1.58 @@ -118,19 +117,24 @@
1.59 ctx->state = YUM_STATE_CHECKSUM;
1.60 } else if (strcmp(name, "rpm:requires") == 0) {
1.61 ctx->state = YUM_STATE_REQUIRES;
1.62 + ctx->property_type = RAZOR_PROPERTY_REQUIRES;
1.63 } else if (strcmp(name, "rpm:provides") == 0) {
1.64 ctx->state = YUM_STATE_PROVIDES;
1.65 + ctx->property_type = RAZOR_PROPERTY_PROVIDES;
1.66 } else if (strcmp(name, "rpm:obsoletes") == 0) {
1.67 ctx->state = YUM_STATE_OBSOLETES;
1.68 + ctx->property_type = RAZOR_PROPERTY_OBSOLETES;
1.69 } else if (strcmp(name, "rpm:conflicts") == 0) {
1.70 ctx->state = YUM_STATE_CONFLICTS;
1.71 + ctx->property_type = RAZOR_PROPERTY_CONFLICTS;
1.72 } else if (strcmp(name, "rpm:entry") == 0 &&
1.73 ctx->state != YUM_STATE_BEGIN) {
1.74 n = NULL;
1.75 epoch = NULL;
1.76 version = NULL;
1.77 release = NULL;
1.78 - flags = NULL;
1.79 + relation = RAZOR_PROPERTY_EQUAL;
1.80 + pre = 0;
1.81 for (i = 0; atts[i]; i += 2) {
1.82 if (strcmp(atts[i], "name") == 0)
1.83 n = atts[i + 1];
1.84 @@ -141,7 +145,13 @@
1.85 else if (strcmp(atts[i], "rel") == 0)
1.86 release = atts[i + 1];
1.87 else if (strcmp(atts[i], "flags") == 0)
1.88 - flags = atts[i + 1];
1.89 + relation = yum_to_razor_relation(atts[i + 1]);
1.90 + else if (strcmp(atts[i], "pre") == 0)
1.91 + pre =
1.92 + RAZOR_PROPERTY_PRE |
1.93 + RAZOR_PROPERTY_POST |
1.94 + RAZOR_PROPERTY_PREUN |
1.95 + RAZOR_PROPERTY_POSTUN;
1.96 }
1.97
1.98 if (n == NULL) {
1.99 @@ -151,32 +161,8 @@
1.100 }
1.101
1.102 razor_build_evr(buffer, sizeof buffer, epoch, version, release);
1.103 - switch (ctx->state) {
1.104 - case YUM_STATE_REQUIRES:
1.105 - razor_importer_add_property(ctx->importer, n,
1.106 - yum_to_razor_flags (flags),
1.107 - buffer,
1.108 - RAZOR_PROPERTY_REQUIRES);
1.109 - break;
1.110 - case YUM_STATE_PROVIDES:
1.111 - razor_importer_add_property(ctx->importer, n,
1.112 - yum_to_razor_flags (flags),
1.113 - buffer,
1.114 - RAZOR_PROPERTY_PROVIDES);
1.115 - break;
1.116 - case YUM_STATE_OBSOLETES:
1.117 - razor_importer_add_property(ctx->importer, n,
1.118 - yum_to_razor_flags (flags),
1.119 - buffer,
1.120 - RAZOR_PROPERTY_OBSOLETES);
1.121 - break;
1.122 - case YUM_STATE_CONFLICTS:
1.123 - razor_importer_add_property(ctx->importer, n,
1.124 - yum_to_razor_flags (flags),
1.125 - buffer,
1.126 - RAZOR_PROPERTY_CONFLICTS);
1.127 - break;
1.128 - }
1.129 + flags = ctx->property_type | relation | pre;
1.130 + razor_importer_add_property(ctx->importer, n, flags, buffer);
1.131 }
1.132 }
1.133