From b8ebb69d3d0dce41ffb2c5c0861cf99868631ef7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 31 Oct 2007 22:59:42 -0400 Subject: [PATCH] Import obsoletes and conflicts; add commands to list them. --- import.c | 40 ++++++++++++++++++++++++++++++++++++++++ main.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/import.c b/import.c index 0d8d682..f291ef0 100644 --- a/import.c +++ b/import.c @@ -159,6 +159,8 @@ enum { YUM_STATE_PACKAGE_NAME, YUM_STATE_REQUIRES, YUM_STATE_PROVIDES, + YUM_STATE_OBSOLETES, + YUM_STATE_CONFLICTS, YUM_STATE_FILE }; @@ -201,6 +203,10 @@ yum_start_element(void *data, const char *name, const char **atts) ctx->state = YUM_STATE_REQUIRES; } else if (strcmp(name, "rpm:provides") == 0) { ctx->state = YUM_STATE_PROVIDES; + } else if (strcmp(name, "rpm:obsoletes") == 0) { + ctx->state = YUM_STATE_OBSOLETES; + } else if (strcmp(name, "rpm:conflicts") == 0) { + ctx->state = YUM_STATE_CONFLICTS; } else if (strcmp(name, "rpm:entry") == 0 && ctx->state != YUM_STATE_BEGIN) { n = NULL; @@ -238,6 +244,14 @@ yum_start_element(void *data, const char *name, const char **atts) razor_importer_add_property(ctx->importer, n, buffer, RAZOR_PROPERTY_PROVIDES); break; + case YUM_STATE_OBSOLETES: + razor_importer_add_property(ctx->importer, n, buffer, + RAZOR_PROPERTY_OBSOLETES); + break; + case YUM_STATE_CONFLICTS: + razor_importer_add_property(ctx->importer, n, buffer, + RAZOR_PROPERTY_CONFLICTS); + break; } } else if (strcmp(name, "file") == 0) { ctx->state = YUM_STATE_FILE; @@ -365,12 +379,38 @@ razor_set_create_from_rpmdb(void) &property_names.p, &count); headerGetEntry(h, RPMTAG_PROVIDEVERSION, &type, &property_versions.p, &count); + headerGetEntry(h, RPMTAG_PROVIDEFLAGS, &type, + &property_flags.p, &count); for (i = 0; i < count; i++) razor_importer_add_property(importer, property_names.list[i], property_versions.list[i], RAZOR_PROPERTY_PROVIDES); + headerGetEntry(h, RPMTAG_OBSOLETENAME, &type, + &property_names.p, &count); + headerGetEntry(h, RPMTAG_OBSOLETEVERSION, &type, + &property_versions.p, &count); + headerGetEntry(h, RPMTAG_OBSOLETEFLAGS, &type, + &property_flags.p, &count); + for (i = 0; i < count; i++) + razor_importer_add_property(importer, + property_names.list[i], + property_versions.list[i], + RAZOR_PROPERTY_OBSOLETES); + + headerGetEntry(h, RPMTAG_CONFLICTNAME, &type, + &property_names.p, &count); + headerGetEntry(h, RPMTAG_CONFLICTVERSION, &type, + &property_versions.p, &count); + headerGetEntry(h, RPMTAG_CONFLICTFLAGS, &type, + &property_flags.p, &count); + for (i = 0; i < count; i++) + razor_importer_add_property(importer, + property_names.list[i], + property_versions.list[i], + RAZOR_PROPERTY_CONFLICTS); + headerGetEntry(h, RPMTAG_BASENAMES, &type, &basenames.p, &count); headerGetEntry(h, RPMTAG_DIRNAMES, &type, diff --git a/main.c b/main.c index f29e302..80831d4 100644 --- a/main.c +++ b/main.c @@ -47,6 +47,30 @@ command_list_provides(int argc, const char *argv[]) } static int +command_list_obsoletes(int argc, const char *argv[]) +{ + struct razor_set *set; + + set = razor_set_open(repo_filename); + razor_set_list_properties(set, argv[0], RAZOR_PROPERTY_OBSOLETES); + razor_set_destroy(set); + + return 0; +} + +static int +command_list_conflicts(int argc, const char *argv[]) +{ + struct razor_set *set; + + set = razor_set_open(repo_filename); + razor_set_list_properties(set, argv[0], RAZOR_PROPERTY_CONFLICTS); + razor_set_destroy(set); + + return 0; +} + +static int command_list_files(int argc, const char *argv[]) { struct razor_set *set; @@ -210,8 +234,10 @@ static struct { int (*func)(int argc, const char *argv[]); } razor_commands[] = { { "list", "list all packages", command_list }, - { "list-requires", "list all requires or requires for the given package", command_list_requires }, - { "list-provides", "list all provides or provides for the give package", command_list_provides }, + { "list-requires", "list all requires for the given package", command_list_requires }, + { "list-provides", "list all provides for the give package", command_list_provides }, + { "list-obsoletes", "list all obsoletes for the give package", command_list_obsoletes }, + { "list-conflicts", "list all conflicts for the give package", command_list_conflicts }, { "list-files", "list files for package set", command_list_files }, { "list-file-packages", "list packages owning file", command_list_file_packages }, { "list-package-files", "list files in package", command_list_package_files }, -- 1.7.1