Import summary and description into the repo files.
Also add a 'info' command for displaying them.
1.1 --- a/main.c Sun Jun 08 11:56:11 2008 -0400
1.2 +++ b/main.c Sun Jun 08 17:11:41 2008 -0400
1.3 @@ -810,6 +810,35 @@
1.4 return 0;
1.5 }
1.6
1.7 +static int
1.8 +command_info(int argc, const char *argv[])
1.9 +{
1.10 + struct razor_set *set;
1.11 + struct razor_package_iterator *pi;
1.12 + struct razor_package *package;
1.13 + const char *pattern = argv[0], *name, *version, *arch;
1.14 +
1.15 + set = razor_set_open(repo_filename);
1.16 + pi = razor_package_iterator_create(set);
1.17 + while (razor_package_iterator_next(pi, &package,
1.18 + &name, &version, &arch)) {
1.19 + if (pattern && fnmatch(pattern, name, 0) != 0)
1.20 + continue;
1.21 +
1.22 + printf ("Name: %s\n", name);
1.23 + printf ("Arch: %s\n", arch);
1.24 + printf ("Version: %s\n", version);
1.25 + printf ("Summary: %s\n", razor_package_get_summary (set, package));
1.26 + printf ("Description:\n");
1.27 + printf ("%s\n", razor_package_get_description (set, package));
1.28 + printf ("\n");
1.29 + }
1.30 + razor_package_iterator_destroy(pi);
1.31 + razor_set_destroy(set);
1.32 +
1.33 + return 0;
1.34 +}
1.35 +
1.36 static struct {
1.37 const char *name;
1.38 const char *description;
1.39 @@ -834,7 +863,8 @@
1.40 { "diff", "show diff between two package sets", command_diff },
1.41 { "install", "install rpm", command_install },
1.42 { "init", "init razor root", command_init },
1.43 - { "download", "download packages", command_download }
1.44 + { "download", "download packages", command_download },
1.45 + { "info", "display package details", command_info }
1.46 };
1.47
1.48 static int
2.1 --- a/razor.c Sun Jun 08 11:56:11 2008 -0400
2.2 +++ b/razor.c Sun Jun 08 17:11:41 2008 -0400
2.3 @@ -63,6 +63,8 @@
2.4 struct razor_package {
2.5 uint name : 24;
2.6 uint flags : 8;
2.7 + uint32_t summary;
2.8 + uint32_t description;
2.9 uint32_t version;
2.10 uint32_t arch;
2.11 struct list_head properties;
2.12 @@ -328,6 +330,15 @@
2.13 }
2.14
2.15 void
2.16 +razor_importer_add_details(struct razor_importer *importer,
2.17 + const char *summary,
2.18 + const char *description)
2.19 +{
2.20 + importer->package->summary = hashtable_tokenize(&importer->table, summary);
2.21 + importer->package->description = hashtable_tokenize(&importer->table, description);
2.22 +}
2.23 +
2.24 +void
2.25 razor_importer_add_property(struct razor_importer *importer,
2.26 const char *name,
2.27 enum razor_version_relation relation,
2.28 @@ -910,6 +921,20 @@
2.29 return p;
2.30 }
2.31
2.32 +const char *
2.33 +razor_package_get_summary(struct razor_set *set, struct razor_package *package)
2.34 +{
2.35 + const char *pool = set->string_pool.data;
2.36 + return &pool[package->summary];
2.37 +}
2.38 +
2.39 +const char *
2.40 +razor_package_get_description(struct razor_set *set, struct razor_package *package)
2.41 +{
2.42 + const char *pool = set->string_pool.data;
2.43 + return &pool[package->description];
2.44 +}
2.45 +
2.46 struct razor_property_iterator {
2.47 struct razor_set *set;
2.48 struct razor_property *property, *end;
3.1 --- a/razor.h Sun Jun 08 11:56:11 2008 -0400
3.2 +++ b/razor.h Sun Jun 08 17:11:41 2008 -0400
3.3 @@ -51,6 +51,11 @@
3.4 struct razor_package *
3.5 razor_set_get_package(struct razor_set *set, const char *package);
3.6
3.7 +const char *
3.8 +razor_package_get_summary(struct razor_set *set, struct razor_package *package);
3.9 +const char *
3.10 +razor_package_get_description(struct razor_set *set, struct razor_package *package);
3.11 +
3.12 struct razor_package_iterator;
3.13 struct razor_package_iterator *
3.14 razor_package_iterator_create(struct razor_set *set);
3.15 @@ -170,6 +175,9 @@
3.16 const char *name,
3.17 const char *version,
3.18 const char *arch);
3.19 +void razor_importer_add_details(struct razor_importer *importer,
3.20 + const char *summary,
3.21 + const char *description);
3.22 void razor_importer_add_property(struct razor_importer *importer,
3.23 const char *name,
3.24 enum razor_version_relation relation,
4.1 --- a/rpm.c Sun Jun 08 11:56:11 2008 -0400
4.2 +++ b/rpm.c Sun Jun 08 17:11:41 2008 -0400
4.3 @@ -592,7 +592,7 @@
4.4 int
4.5 razor_importer_add_rpm(struct razor_importer *importer, struct razor_rpm *rpm)
4.6 {
4.7 - const char *name, *version, *release, *arch;
4.8 + const char *name, *version, *release, *arch, *summary;
4.9 const uint_32 *epoch;
4.10 char evr[128], buf[16];
4.11
4.12 @@ -601,6 +601,7 @@
4.13 version = razor_rpm_get_indirect(rpm, RPMTAG_VERSION, NULL);
4.14 release = razor_rpm_get_indirect(rpm, RPMTAG_RELEASE, NULL);
4.15 arch = razor_rpm_get_indirect(rpm, RPMTAG_ARCH, NULL);
4.16 + summary = razor_rpm_get_indirect(rpm, RPMTAG_SUMMARY, NULL);
4.17
4.18 if (epoch) {
4.19 snprintf(buf, sizeof buf, "%u", ntohl(*epoch));
4.20 @@ -672,7 +673,7 @@
4.21 rpmdbMatchIterator iter;
4.22 Header h;
4.23 int_32 type, count, i;
4.24 - union rpm_entry name, epoch, version, release, arch;
4.25 + union rpm_entry name, epoch, version, release, arch, summary, description;
4.26 union rpm_entry basenames, dirnames, dirindexes;
4.27 char filename[PATH_MAX], evr[128], buf[16];
4.28 rpmdb db;
4.29 @@ -693,6 +694,8 @@
4.30 headerGetEntry(h, RPMTAG_VERSION, &type, &version.p, &count);
4.31 headerGetEntry(h, RPMTAG_RELEASE, &type, &release.p, &count);
4.32 headerGetEntry(h, RPMTAG_ARCH, &type, &arch.p, &count);
4.33 + headerGetEntry(h, RPMTAG_SUMMARY, &type, &summary.p, &count);
4.34 + headerGetEntry(h, RPMTAG_DESCRIPTION, &type, &description.p, &count);
4.35
4.36 if (epoch.flags != NULL) {
4.37 snprintf(buf, sizeof buf, "%u", *epoch.flags);
4.38 @@ -705,6 +708,7 @@
4.39
4.40 razor_importer_begin_package(importer,
4.41 name.string, evr, arch.string);
4.42 + razor_importer_add_details(importer, summary.string, description.string);
4.43
4.44 add_properties(importer, RAZOR_PROPERTY_REQUIRES, h,
4.45 RPMTAG_REQUIRENAME,
5.1 --- a/yum.c Sun Jun 08 11:56:11 2008 -0400
5.2 +++ b/yum.c Sun Jun 08 17:11:41 2008 -0400
5.3 @@ -37,6 +37,8 @@
5.4 YUM_STATE_BEGIN,
5.5 YUM_STATE_PACKAGE_NAME,
5.6 YUM_STATE_PACKAGE_ARCH,
5.7 + YUM_STATE_SUMMARY,
5.8 + YUM_STATE_DESCRIPTION,
5.9 YUM_STATE_CHECKSUM,
5.10 YUM_STATE_REQUIRES,
5.11 YUM_STATE_PROVIDES,
5.12 @@ -52,7 +54,7 @@
5.13
5.14 struct razor_importer *importer;
5.15 struct import_property_context *current_property_context;
5.16 - char name[256], arch[64], buffer[512], *p;
5.17 + char name[256], arch[64], summary[512], description[4096], buffer[512], *p;
5.18 char pkgid[128];
5.19 int state;
5.20 };
5.21 @@ -113,6 +115,12 @@
5.22 razor_build_evr(buffer, sizeof buffer, epoch, version, release);
5.23 razor_importer_begin_package(ctx->importer,
5.24 ctx->name, buffer, ctx->arch);
5.25 + } else if (strcmp(name, "summary") == 0) {
5.26 + ctx->p = ctx->summary;
5.27 + ctx->state = YUM_STATE_SUMMARY;
5.28 + } else if (strcmp(name, "description") == 0) {
5.29 + ctx->p = ctx->description;
5.30 + ctx->state = YUM_STATE_DESCRIPTION;
5.31 } else if (strcmp(name, "checksum") == 0) {
5.32 ctx->p = ctx->pkgid;
5.33 ctx->state = YUM_STATE_CHECKSUM;
5.34 @@ -188,6 +196,8 @@
5.35 switch (ctx->state) {
5.36 case YUM_STATE_PACKAGE_NAME:
5.37 case YUM_STATE_PACKAGE_ARCH:
5.38 + case YUM_STATE_SUMMARY:
5.39 + case YUM_STATE_DESCRIPTION:
5.40 case YUM_STATE_CHECKSUM:
5.41 case YUM_STATE_FILE:
5.42 ctx->state = YUM_STATE_BEGIN;
5.43 @@ -195,6 +205,8 @@
5.44 }
5.45
5.46 if (strcmp(name, "package") == 0) {
5.47 + razor_importer_add_details(ctx->importer, ctx->summary, ctx->description);
5.48 +
5.49 XML_StopParser(ctx->current_parser, XML_TRUE);
5.50 ctx->current_parser = ctx->filelists_parser;
5.51 }
5.52 @@ -208,6 +220,8 @@
5.53 switch (ctx->state) {
5.54 case YUM_STATE_PACKAGE_NAME:
5.55 case YUM_STATE_PACKAGE_ARCH:
5.56 + case YUM_STATE_SUMMARY:
5.57 + case YUM_STATE_DESCRIPTION:
5.58 case YUM_STATE_CHECKSUM:
5.59 case YUM_STATE_FILE:
5.60 memcpy(ctx->p, s, len);