Package: new attrs siggpg, sigpgp and hdrid + support for these to parsehdr
authorTomas Mlcoch <tmlcoch@redhat.com>
Wed, 25 Jun 2014 11:43:12 +0000 (13:43 +0200)
committerTomas Mlcoch <tmlcoch@redhat.com>
Wed, 25 Jun 2014 11:43:12 +0000 (13:43 +0200)
src/package.c
src/package.h
src/parsehdr.c

index bb85537..35cd297 100644 (file)
@@ -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);
 }
 
index bb5502d..0396935 100644 (file)
@@ -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
  */
index 20e6134..7a81829 100644 (file)
@@ -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;
 }