diff options
author | Kristian Høgsberg <krh@redhat.com> | 2008-06-23 09:59:08 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2008-06-23 09:59:08 -0400 |
commit | e7a9df418a6b680878e8e3c0b0129d0b07326ff0 (patch) | |
tree | c4edf4beefaead67bd4bcf5b7a66fe80612f6f53 /src | |
parent | 389289592f745d1d506417425211c44b7637b458 (diff) | |
parent | c778afefaa189c6aa8437fc00512f140a6a68efe (diff) |
Merge commit 'jbowes/master'
Diffstat (limited to 'src')
-rw-r--r-- | src/import-rpmdb.c | 9 | ||||
-rw-r--r-- | src/import-yum.c | 31 | ||||
-rw-r--r-- | src/main.c | 56 | ||||
-rw-r--r-- | src/test-driver.c | 7 |
4 files changed, 95 insertions, 8 deletions
diff --git a/src/import-rpmdb.c b/src/import-rpmdb.c index 916ca27..3b4851c 100644 --- a/src/import-rpmdb.c +++ b/src/import-rpmdb.c @@ -86,6 +86,7 @@ razor_set_create_from_rpmdb(void) Header h; int_32 type, count, i; union rpm_entry name, epoch, version, release, arch; + union rpm_entry summary, description, url, license; union rpm_entry basenames, dirnames, dirindexes; char filename[PATH_MAX], evr[128], buf[16]; rpmdb db; @@ -106,6 +107,11 @@ razor_set_create_from_rpmdb(void) headerGetEntry(h, RPMTAG_VERSION, &type, &version.p, &count); headerGetEntry(h, RPMTAG_RELEASE, &type, &release.p, &count); headerGetEntry(h, RPMTAG_ARCH, &type, &arch.p, &count); + headerGetEntry(h, RPMTAG_SUMMARY, &type, &summary.p, &count); + headerGetEntry(h, RPMTAG_DESCRIPTION, &type, &description.p, + &count); + headerGetEntry(h, RPMTAG_URL, &type, &url.p, &count); + headerGetEntry(h, RPMTAG_LICENSE, &type, &license.p, &count); if (epoch.flags != NULL) { snprintf(buf, sizeof buf, "%u", *epoch.flags); @@ -118,6 +124,9 @@ razor_set_create_from_rpmdb(void) razor_importer_begin_package(importer, name.string, evr, arch.string); + razor_importer_add_details(importer, summary.string, + description.string, url.string, + license.string); add_properties(importer, RAZOR_PROPERTY_REQUIRES, h, RPMTAG_REQUIRENAME, diff --git a/src/import-yum.c b/src/import-yum.c index f70c71d..cb4ea7a 100644 --- a/src/import-yum.c +++ b/src/import-yum.c @@ -38,6 +38,10 @@ enum { YUM_STATE_BEGIN, YUM_STATE_PACKAGE_NAME, YUM_STATE_PACKAGE_ARCH, + YUM_STATE_SUMMARY, + YUM_STATE_DESCRIPTION, + YUM_STATE_URL, + YUM_STATE_LICENSE, YUM_STATE_CHECKSUM, YUM_STATE_REQUIRES, YUM_STATE_PROVIDES, @@ -53,7 +57,8 @@ struct yum_context { struct razor_importer *importer; struct import_property_context *current_property_context; - char name[256], arch[64], buffer[512], *p; + char name[256], arch[64], summary[512], description[4096]; + char url[256], license[64], buffer[512], *p; char pkgid[128]; uint32_t property_type; int state; @@ -112,9 +117,21 @@ yum_primary_start_element(void *data, const char *name, const char **atts) razor_build_evr(buffer, sizeof buffer, epoch, version, release); razor_importer_begin_package(ctx->importer, ctx->name, buffer, ctx->arch); + } else if (strcmp(name, "summary") == 0) { + ctx->p = ctx->summary; + ctx->state = YUM_STATE_SUMMARY; + } else if (strcmp(name, "description") == 0) { + ctx->p = ctx->description; + ctx->state = YUM_STATE_DESCRIPTION; + } else if (strcmp(name, "url") == 0) { + ctx->p = ctx->url; + ctx->state = YUM_STATE_URL; } else if (strcmp(name, "checksum") == 0) { ctx->p = ctx->pkgid; ctx->state = YUM_STATE_CHECKSUM; + } else if (strcmp(name, "rpm:license") == 0) { + ctx->p = ctx->license; + ctx->state = YUM_STATE_LICENSE; } else if (strcmp(name, "rpm:requires") == 0) { ctx->state = YUM_STATE_REQUIRES; ctx->property_type = RAZOR_PROPERTY_REQUIRES; @@ -174,6 +191,10 @@ yum_primary_end_element (void *data, const char *name) switch (ctx->state) { case YUM_STATE_PACKAGE_NAME: case YUM_STATE_PACKAGE_ARCH: + case YUM_STATE_SUMMARY: + case YUM_STATE_DESCRIPTION: + case YUM_STATE_URL: + case YUM_STATE_LICENSE: case YUM_STATE_CHECKSUM: case YUM_STATE_FILE: ctx->state = YUM_STATE_BEGIN; @@ -181,6 +202,10 @@ yum_primary_end_element (void *data, const char *name) } if (strcmp(name, "package") == 0) { + razor_importer_add_details(ctx->importer, ctx->summary, + ctx->description, ctx->url, + ctx->license); + XML_StopParser(ctx->current_parser, XML_TRUE); ctx->current_parser = ctx->filelists_parser; } @@ -194,6 +219,10 @@ yum_character_data (void *data, const XML_Char *s, int len) switch (ctx->state) { case YUM_STATE_PACKAGE_NAME: case YUM_STATE_PACKAGE_ARCH: + case YUM_STATE_SUMMARY: + case YUM_STATE_DESCRIPTION: + case YUM_STATE_URL: + case YUM_STATE_LICENSE: case YUM_STATE_CHECKSUM: case YUM_STATE_FILE: memcpy(ctx->p, s, len); @@ -150,6 +150,7 @@ command_list_files(int argc, const char *argv[]) struct razor_set *set; set = razor_set_open(repo_filename); + razor_set_open_files(set, "system-files.repo"); if (set == NULL) return 1; razor_set_list_files(set, argv[0]); @@ -167,6 +168,7 @@ command_list_file_packages(int argc, const char *argv[]) const char *name, *version, *arch; set = razor_set_open(repo_filename); + razor_set_open_files(set, "system-files.repo"); if (set == NULL) return 1; @@ -187,6 +189,7 @@ command_list_package_files(int argc, const char *argv[]) struct razor_set *set; set = razor_set_open(repo_filename); + razor_set_open_files(set, "system-files.repo"); if (set == NULL) return 1; razor_set_list_package_files(set, argv[0]); @@ -351,7 +354,9 @@ command_import_yum(int argc, const char *argv[]) set = razor_set_create_from_yum(); if (set == NULL) return 1; - razor_set_write(set, rawhide_repo_filename); + razor_set_write(set, rawhide_repo_filename, RAZOR_REPO_FILE_MAIN); + razor_set_write(set, "rawhide-details.repo", RAZOR_REPO_FILE_DETAILS); + razor_set_write(set, "rawhide-files.repo", RAZOR_REPO_FILE_FILES); razor_set_destroy(set); printf("wrote %s\n", rawhide_repo_filename); @@ -366,7 +371,9 @@ command_import_rpmdb(int argc, const char *argv[]) set = razor_set_create_from_rpmdb(); if (set == NULL) return 1; - razor_set_write(set, repo_filename); + razor_set_write(set, repo_filename, RAZOR_REPO_FILE_MAIN); + razor_set_write(set, "system-details.repo", RAZOR_REPO_FILE_DETAILS); + razor_set_write(set, "system-files.repo", RAZOR_REPO_FILE_FILES); razor_set_destroy(set); printf("wrote %s\n", repo_filename); @@ -447,7 +454,7 @@ command_update(int argc, const char *argv[]) } set = razor_transaction_finish(trans); - razor_set_write(set, updated_repo_filename); + razor_set_write(set, updated_repo_filename, RAZOR_REPO_FILE_MAIN); razor_set_destroy(set); razor_set_destroy(upstream); printf("wrote system-updated.repo\n"); @@ -480,7 +487,7 @@ command_remove(int argc, const char *argv[]) return 1; set = razor_transaction_finish(trans); - razor_set_write(set, updated_repo_filename); + razor_set_write(set, updated_repo_filename, RAZOR_REPO_FILE_MAIN); razor_set_destroy(set); razor_set_destroy(upstream); printf("wrote system-updated.repo\n"); @@ -571,7 +578,7 @@ command_import_rpms(int argc, const char *argv[]) set = razor_importer_finish(importer); - razor_set_write(set, repo_filename); + razor_set_write(set, repo_filename, RAZOR_REPO_FILE_MAIN); razor_set_destroy(set); printf("wrote %s\n", repo_filename); @@ -769,6 +776,42 @@ command_download(int argc, const char *argv[]) return 0; } +static int +command_info(int argc, const char *argv[]) +{ + struct razor_set *set; + struct razor_package_iterator *pi; + struct razor_package *package; + const char *pattern = argv[0], *name, *version, *arch; + const char *summary, *description, *url, *license; + + set = razor_set_open(repo_filename); + razor_set_open_details(set, "system-details.repo"); + pi = razor_package_iterator_create(set); + while (razor_package_iterator_next(pi, &package, + &name, &version, &arch)) { + if (pattern && fnmatch(pattern, name, 0) != 0) + continue; + + razor_package_get_details (set, package, &summary, &description, + &url, &license); + + printf ("Name: %s\n", name); + printf ("Arch: %s\n", arch); + printf ("Version: %s\n", version); + printf ("URL: %s\n", url); + printf ("License: %s\n", license); + printf ("Summary: %s\n", summary); + printf ("Description:\n"); + printf ("%s\n", description); + printf ("\n"); + } + razor_package_iterator_destroy(pi); + razor_set_destroy(set); + + return 0; +} + static struct { const char *name; const char *description; @@ -792,7 +835,8 @@ static struct { { "diff", "show diff between two package sets", command_diff }, { "install", "install rpm", command_install }, { "init", "init razor root", command_init }, - { "download", "download packages", command_download } + { "download", "download packages", command_download }, + { "info", "display package details", command_info } }; static int diff --git a/src/test-driver.c b/src/test-driver.c index 876d248..91bc62c 100644 --- a/src/test-driver.c +++ b/src/test-driver.c @@ -264,8 +264,12 @@ end_transaction(struct test_context *ctx) razor_transaction_install_package(ctx->trans, pkg); } for (i = 0; i < ctx->n_remove_pkgs; i++) { - pkg = razor_set_get_package(ctx->repo_set, + pkg = razor_set_get_package(ctx->system_set, ctx->remove_pkgs[i]); + if (!pkg) + pkg = razor_set_get_package(ctx->repo_set, + ctx->remove_pkgs[i]); + razor_transaction_remove_package(ctx->trans, pkg); } @@ -280,6 +284,7 @@ end_transaction(struct test_context *ctx) if (!errors) { struct razor_set *new; new = razor_transaction_finish(ctx->trans); + ctx->trans = NULL; ctx->system_set = new; } } |