summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-06-20 14:18:52 -0400
committerKristian Høgsberg <krh@redhat.com>2008-06-20 14:18:52 -0400
commit17138ad12dda6da15358726f19ba8f94993ddfc1 (patch)
tree21a9e9c9123f5408f7f5c43fc1e3bc1447624cbd /src
parent157b904acee4209f6555550768edf1e150046146 (diff)
Record the time of dependencies (post, pre, postun, preun).
Diffstat (limited to 'src')
-rw-r--r--src/import-rpmdb.c46
-rw-r--r--src/import-yum.c66
-rw-r--r--src/main.c49
-rw-r--r--src/rpm.c28
4 files changed, 93 insertions, 96 deletions
diff --git a/src/import-rpmdb.c b/src/import-rpmdb.c
index ddfed9e..22d0855 100644
--- a/src/import-rpmdb.c
+++ b/src/import-rpmdb.c
@@ -34,29 +34,34 @@ union rpm_entry {
uint_32 integer;
};
-static enum razor_version_relation
-rpm_to_razor_flags (uint_32 flags)
+static uint32_t
+rpm_to_razor_flags(uint32_t flags)
{
- switch (flags & (RPMSENSE_LESS | RPMSENSE_EQUAL | RPMSENSE_GREATER)) {
- case RPMSENSE_LESS:
- return RAZOR_VERSION_LESS;
- case RPMSENSE_LESS|RPMSENSE_EQUAL:
- return RAZOR_VERSION_LESS_OR_EQUAL;
- case RPMSENSE_EQUAL:
- return RAZOR_VERSION_EQUAL;
- case RPMSENSE_GREATER|RPMSENSE_EQUAL:
- return RAZOR_VERSION_GREATER_OR_EQUAL;
- case RPMSENSE_GREATER:
- return RAZOR_VERSION_GREATER;
- }
-
- /* FIXME? */
- return RAZOR_VERSION_EQUAL;
+ uint32_t razor_flags;
+
+ razor_flags = 0;
+ if (flags & RPMSENSE_LESS)
+ razor_flags |= RAZOR_PROPERTY_LESS;
+ if (flags & RPMSENSE_EQUAL)
+ razor_flags |= RAZOR_PROPERTY_EQUAL;
+ if (flags & RPMSENSE_GREATER)
+ razor_flags |= RAZOR_PROPERTY_GREATER;
+
+ if (flags & RPMSENSE_SCRIPT_PRE)
+ razor_flags |= RAZOR_PROPERTY_PRE;
+ if (flags & RPMSENSE_SCRIPT_POST)
+ razor_flags |= RAZOR_PROPERTY_POST;
+ if (flags & RPMSENSE_SCRIPT_PREUN)
+ razor_flags |= RAZOR_PROPERTY_PREUN;
+ if (flags & RPMSENSE_SCRIPT_POSTUN)
+ razor_flags |= RAZOR_PROPERTY_POSTUN;
+
+ return razor_flags;
}
static void
add_properties(struct razor_importer *importer,
- enum razor_property_type property_type,
+ uint32_t type_flags,
Header h, int_32 name_tag, int_32 version_tag, int_32 flags_tag)
{
union rpm_entry names, versions, flags;
@@ -69,9 +74,8 @@ add_properties(struct razor_importer *importer,
for (i = 0; i < count; i++)
razor_importer_add_property(importer,
names.list[i],
- rpm_to_razor_flags (flags.flags[i]),
- versions.list[i],
- property_type);
+ rpm_to_razor_flags (flags.flags[i]) | type_flags,
+ versions.list[i]);
}
struct razor_set *
diff --git a/src/import-yum.c b/src/import-yum.c
index c461a15..2efd201 100644
--- a/src/import-yum.c
+++ b/src/import-yum.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <stdio.h>
+#include <stdint.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
@@ -54,36 +55,34 @@ struct yum_context {
struct import_property_context *current_property_context;
char name[256], arch[64], buffer[512], *p;
char pkgid[128];
+ uint32_t property_type;
int state;
};
-static enum razor_version_relation
-yum_to_razor_flags (const char *flags)
+static uint32_t
+yum_to_razor_relation (const char *flags)
{
- /* FIXME? */
- if (!flags)
- return RAZOR_VERSION_EQUAL;
-
if (flags[0] == 'L') {
if (flags[1] == 'T')
- return RAZOR_VERSION_LESS;
+ return RAZOR_PROPERTY_LESS;
else
- return RAZOR_VERSION_LESS_OR_EQUAL;
+ return RAZOR_PROPERTY_LESS | RAZOR_PROPERTY_EQUAL;
} else if (flags[0] == 'G') {
if (flags[1] == 'T')
- return RAZOR_VERSION_GREATER;
+ return RAZOR_PROPERTY_GREATER;
else
- return RAZOR_VERSION_GREATER_OR_EQUAL;
+ return RAZOR_PROPERTY_GREATER | RAZOR_PROPERTY_EQUAL;
} else
- return RAZOR_VERSION_EQUAL;
+ return RAZOR_PROPERTY_EQUAL;
}
static void
yum_primary_start_element(void *data, const char *name, const char **atts)
{
struct yum_context *ctx = data;
- const char *n, *epoch, *version, *release, *flags;
+ const char *n, *epoch, *version, *release;
char buffer[128];
+ uint32_t pre, relation, flags;
int i;
if (strcmp(name, "name") == 0) {
@@ -118,19 +117,24 @@ yum_primary_start_element(void *data, const char *name, const char **atts)
ctx->state = YUM_STATE_CHECKSUM;
} else if (strcmp(name, "rpm:requires") == 0) {
ctx->state = YUM_STATE_REQUIRES;
+ ctx->property_type = RAZOR_PROPERTY_REQUIRES;
} else if (strcmp(name, "rpm:provides") == 0) {
ctx->state = YUM_STATE_PROVIDES;
+ ctx->property_type = RAZOR_PROPERTY_PROVIDES;
} else if (strcmp(name, "rpm:obsoletes") == 0) {
ctx->state = YUM_STATE_OBSOLETES;
+ ctx->property_type = RAZOR_PROPERTY_OBSOLETES;
} else if (strcmp(name, "rpm:conflicts") == 0) {
ctx->state = YUM_STATE_CONFLICTS;
+ ctx->property_type = RAZOR_PROPERTY_CONFLICTS;
} else if (strcmp(name, "rpm:entry") == 0 &&
ctx->state != YUM_STATE_BEGIN) {
n = NULL;
epoch = NULL;
version = NULL;
release = NULL;
- flags = NULL;
+ relation = RAZOR_PROPERTY_EQUAL;
+ pre = 0;
for (i = 0; atts[i]; i += 2) {
if (strcmp(atts[i], "name") == 0)
n = atts[i + 1];
@@ -141,7 +145,13 @@ yum_primary_start_element(void *data, const char *name, const char **atts)
else if (strcmp(atts[i], "rel") == 0)
release = atts[i + 1];
else if (strcmp(atts[i], "flags") == 0)
- flags = atts[i + 1];
+ relation = yum_to_razor_relation(atts[i + 1]);
+ else if (strcmp(atts[i], "pre") == 0)
+ pre =
+ RAZOR_PROPERTY_PRE |
+ RAZOR_PROPERTY_POST |
+ RAZOR_PROPERTY_PREUN |
+ RAZOR_PROPERTY_POSTUN;
}
if (n == NULL) {
@@ -151,32 +161,8 @@ yum_primary_start_element(void *data, const char *name, const char **atts)
}
razor_build_evr(buffer, sizeof buffer, epoch, version, release);
- switch (ctx->state) {
- case YUM_STATE_REQUIRES:
- razor_importer_add_property(ctx->importer, n,
- yum_to_razor_flags (flags),
- buffer,
- RAZOR_PROPERTY_REQUIRES);
- break;
- case YUM_STATE_PROVIDES:
- razor_importer_add_property(ctx->importer, n,
- yum_to_razor_flags (flags),
- buffer,
- RAZOR_PROPERTY_PROVIDES);
- break;
- case YUM_STATE_OBSOLETES:
- razor_importer_add_property(ctx->importer, n,
- yum_to_razor_flags (flags),
- buffer,
- RAZOR_PROPERTY_OBSOLETES);
- break;
- case YUM_STATE_CONFLICTS:
- razor_importer_add_property(ctx->importer, n,
- yum_to_razor_flags (flags),
- buffer,
- RAZOR_PROPERTY_CONFLICTS);
- break;
- }
+ flags = ctx->property_type | relation | pre;
+ razor_importer_add_property(ctx->importer, n, flags, buffer);
}
}
diff --git a/src/main.c b/src/main.c
index 05d5b53..6a2acf7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -73,17 +73,14 @@ command_list(int argc, const char *argv[])
}
static int
-list_properties(const char *package_name,
- enum razor_property_type required_type)
+list_properties(const char *package_name, uint32_t type)
{
- static const char *relation_string[] = { "<", "<=", "=", ">=", ">" };
struct razor_set *set;
struct razor_property *property;
struct razor_package *package;
struct razor_property_iterator *pi;
const char *name, *version;
- enum razor_property_type type;
- enum razor_version_relation relation;
+ uint32_t flags;
set = razor_set_open(repo_filename);
if (package_name)
@@ -93,15 +90,28 @@ list_properties(const char *package_name,
pi = razor_property_iterator_create(set, package);
while (razor_property_iterator_next(pi, &property,
- &name, &relation, &version,
- &type)) {
- if (type != required_type)
+ &name, &flags, &version)) {
+ if ((flags & RAZOR_PROPERTY_TYPE_MASK) != type)
continue;
- if (version[0] == '\0')
- printf("%s\n", name);
- else
- printf("%s %s %s\n", name,
- relation_string[relation], version);
+ printf("%s", name);
+ if (version[0] != '\0')
+ printf(" %s %s",
+ razor_property_relation_to_string(property),
+ version);
+
+ if (flags & ~(RAZOR_PROPERTY_RELATION_MASK | RAZOR_PROPERTY_TYPE_MASK)) {
+ printf(" [");
+ if (flags & RAZOR_PROPERTY_PRE)
+ printf(" pre");
+ if (flags & RAZOR_PROPERTY_POST)
+ printf(" post");
+ if (flags & RAZOR_PROPERTY_PREUN)
+ printf(" preun");
+ if (flags & RAZOR_PROPERTY_POSTUN)
+ printf(" postun");
+ printf(" ]");
+ }
+ printf("\n");
}
razor_property_iterator_destroy(pi);
@@ -203,14 +213,13 @@ list_packages_for_property(struct razor_set *set,
static int
list_property_packages(const char *ref_name,
const char *ref_version,
- enum razor_property_type ref_type)
+ uint32_t type)
{
struct razor_set *set;
struct razor_property *property;
struct razor_property_iterator *pi;
const char *name, *version;
- enum razor_property_type type;
- enum razor_version_relation relation;
+ uint32_t flags;
if (ref_name == NULL)
return 0;
@@ -221,14 +230,14 @@ list_property_packages(const char *ref_name,
pi = razor_property_iterator_create(set, NULL);
while (razor_property_iterator_next(pi, &property,
- &name, &relation, &version,
- &type)) {
+ &name, &flags, &version)) {
if (strcmp(ref_name, name) != 0)
continue;
- if (ref_version && relation == RAZOR_VERSION_EQUAL &&
+ if (ref_version &&
+ (flags & RAZOR_PROPERTY_RELATION_MASK) == RAZOR_PROPERTY_EQUAL &&
strcmp(ref_version, version) != 0)
continue;
- if (ref_type != type)
+ if ((flags & RAZOR_PROPERTY_TYPE_MASK) != type)
continue;
list_packages_for_property(set, property);
diff --git a/src/rpm.c b/src/rpm.c
index 6a3ea80..7ad0d6d 100644
--- a/src/rpm.c
+++ b/src/rpm.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <stdint.h>
#include <dirent.h>
#include "razor.h"
@@ -257,24 +258,24 @@ add_property_packages(struct razor_set *set,
struct razor_package_query *query,
const char *ref_name,
const char *ref_version,
- enum razor_property_type ref_type)
+ uint32_t ref_type)
{
struct razor_property *property;
struct razor_property_iterator *pi;
struct razor_package_iterator *pkgi;
const char *name, *version;
- enum razor_property_type type;
- enum razor_version_relation relation;
+ uint32_t flags;
pi = razor_property_iterator_create(set, NULL);
while (razor_property_iterator_next(pi, &property, &name,
- &relation, &version, &type)) {
+ &flags, &version)) {
if (strcmp(ref_name, name) != 0)
continue;
- if (ref_version && relation == RAZOR_VERSION_EQUAL &&
+ if (ref_version &&
+ (flags & RAZOR_PROPERTY_RELATION_MASK) == RAZOR_PROPERTY_EQUAL &&
strcmp(ref_version, version) != 0)
continue;
- if (ref_type != type)
+ if ((flags & RAZOR_PROPERTY_TYPE_MASK) != ref_type)
continue;
pkgi = razor_package_iterator_create_for_property(set,
@@ -369,30 +370,27 @@ get_query_packages(struct razor_set *set, int argc, const char *argv[])
return razor_package_query_finish(query);
}
-static const char *relation_string[] = { "<", "<=", "=", ">=", ">" };
-
static void
print_package_properties(struct razor_set *set,
struct razor_package *package,
- enum razor_property_type ref_type)
+ uint32_t ref_type)
{
struct razor_property *property;
struct razor_property_iterator *pi;
const char *name, *version;
- enum razor_property_type type;
- enum razor_version_relation relation;
+ uint32_t flags;
pi = razor_property_iterator_create(set, package);
while (razor_property_iterator_next(pi, &property,
- &name, &relation, &version,
- &type)) {
- if (type != ref_type)
+ &name, &flags, &version)) {
+ if ((flags & RAZOR_PROPERTY_TYPE_MASK) != ref_type)
continue;
if (version[0] == '\0')
printf("%s\n", name);
else
printf("%s %s %s\n", name,
- relation_string[relation], version);
+ razor_property_relation_to_string(property),
+ version);
}
razor_property_iterator_destroy(pi);
}