From: Tomas Mlcoch Date: Wed, 25 Jun 2014 11:43:12 +0000 (+0200) Subject: Package: new attrs siggpg, sigpgp and hdrid + support for these to parsehdr X-Git-Tag: upstream/0.10.0~220 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62b83dea14a55d696f29e8ec1ad94504c1dc2fa7;p=services%2Fcreaterepo_c.git Package: new attrs siggpg, sigpgp and hdrid + support for these to parsehdr --- diff --git a/src/package.c b/src/package.c index bb85537..35cd297 100644 --- a/src/package.c +++ b/src/package.c @@ -54,6 +54,12 @@ cr_changelog_entry_new(void) return entry; } +cr_BinaryData * +cr_binary_data_new(void) +{ + return (cr_BinaryData *) g_new0(cr_BinaryData, 1); +} + cr_Package * cr_package_new(void) { @@ -135,6 +141,9 @@ cr_package_free(cr_Package *package) g_slist_free (package->changelogs); } + g_free(package->siggpg); + g_free(package->sigpgp); + g_free (package); } diff --git a/src/package.h b/src/package.h index bb5502d..0396935 100644 --- a/src/package.h +++ b/src/package.h @@ -70,6 +70,13 @@ typedef struct { char *changelog; /*!< text of changelog */ } cr_ChangelogEntry; +/** Binary data. + */ +typedef struct { + void *data; + gsize size; +} cr_BinaryData; + /** Package */ typedef struct { @@ -118,6 +125,10 @@ typedef struct { GSList *changelogs; /*!< changelogs (list of cr_ChangelogEntry structs) */ + char *hdrid; + cr_BinaryData *siggpg; + cr_BinaryData *sigpgp; + GStringChunk *chunk; /*!< string chunk for store all package strings on the single place */ @@ -140,6 +151,11 @@ cr_PackageFile *cr_package_file_new(void); */ cr_ChangelogEntry *cr_changelog_entry_new(void); +/** Create new (empty) structure for binary data + * @return new mepty cr_BinaryData + */ +cr_BinaryData *cr_binary_data_new(void); + /** Create new (empty) package structure. * @return new empty cr_Package */ diff --git a/src/parsehdr.c b/src/parsehdr.c index 20e6134..7a81829 100644 --- a/src/parsehdr.c +++ b/src/parsehdr.c @@ -550,5 +550,35 @@ cr_package_from_header(Header hdr, int changelog_limit, GError **err) rpmtdFree(changelognames); rpmtdFree(changelogtexts); + + // + // Keys and hdrid (data used for caching when the --cachedir is specified) + // + + pkg->hdrid = cr_safe_string_chunk_insert(pkg->chunk, + headerGetString(hdr, RPMTAG_HDRID)); + + rpmtd gpgtd = rpmtdNew(); + rpmtd pgptd = rpmtdNew(); + + if (headerGet(hdr, RPMTAG_SIGGPG, gpgtd, flags)) { + pkg->siggpg = cr_binary_data_new(); + pkg->siggpg->size = gpgtd->count; + pkg->siggpg->data = g_string_chunk_insert_len(pkg->chunk, + gpgtd->data, + gpgtd->count); + } + + if (headerGet(hdr, RPMTAG_SIGPGP, pgptd, flags)) { + pkg->sigpgp = cr_binary_data_new(); + pkg->sigpgp->size = pgptd->count; + pkg->sigpgp->data = g_string_chunk_insert_len(pkg->chunk, + pgptd->data, + pgptd->count); + } + + rpmtdFree(gpgtd); + rpmtdFree(pgptd); + return pkg; }