- add repomd.xml data sections to meta data
authorMichael Schroeder <mls@suse.de>
Mon, 22 Jun 2009 14:02:56 +0000 (16:02 +0200)
committerMichael Schroeder <mls@suse.de>
Mon, 22 Jun 2009 14:02:56 +0000 (16:02 +0200)
- bump version to 14.2

VERSION.cmake
ext/repo_repomdxml.c
ext/repo_rpmmd.c
package/libsatsolver.changes
src/knownid.h

index 8f796fc..559f82d 100644 (file)
@@ -46,6 +46,6 @@
 
 SET(LIBSATSOLVER_MAJOR "0")
 SET(LIBSATSOLVER_MINOR "14")
-SET(LIBSATSOLVER_PATCH "1")
+SET(LIBSATSOLVER_PATCH "2")
 
-# last released 0.14.1
+# last released 0.14.2
index c6a1ae2..9b27804 100644 (file)
@@ -93,6 +93,7 @@ enum state {
   STATE_EXPIRE,
   STATE_KEYWORDS,
   STATE_KEYWORD,
+
   /* normal repomd.xml */
   STATE_REPOMD,
   STATE_REVISION,
@@ -159,6 +160,7 @@ struct parsedata {
   Repo *repo;
   Repodata *data;
   
+  XML_Parser *parser;
   struct stateswitch *swtab[NUMSTATES];
   enum state sbtab[NUMSTATES];
   int timestamp;
@@ -168,6 +170,10 @@ struct parsedata {
   Id ruhandle;
   /* repo products */
   Id rphandle;
+  /* repo data handle */
+  Id rdhandle;
+
+  const char *tmpattr;
 };
 
 /*
@@ -278,13 +284,26 @@ startElement(void *userData, const char *name, const char **atts)
           repodata_set_poolstr(pd->data, pd->ruhandle, REPOSITORY_PRODUCT_CPEID, cpeid);
         break;
       }
-    case STATE_DATA: break;
-    case STATE_LOCATION: break;
-    case STATE_CHECKSUM: break;
-    case STATE_TIMESTAMP: break;
-    case STATE_OPENCHECKSUM: break;
-    case NUMSTATES: break;
-    default: break;
+    case STATE_DATA:
+      {
+        const char *type= find_attr("type", atts);
+        pd->rdhandle = repodata_new_handle(pd->data);
+       if (type)
+          repodata_set_poolstr(pd->data, pd->rdhandle, REPOSITORY_REPOMD_TYPE, type);
+        break;
+      }
+    case STATE_LOCATION:
+      {
+        const char *href = find_attr("href", atts);
+       if (href)
+          repodata_set_str(pd->data, pd->rdhandle, REPOSITORY_REPOMD_LOCATION, href);
+      }
+    case STATE_CHECKSUM:
+    case STATE_OPENCHECKSUM:
+      pd->tmpattr= find_attr("type", atts);
+      break;
+    default:
+      break;
     }
   return;
 }
@@ -316,10 +335,38 @@ endElement(void *userData, const char *name)
       if (pd->timestamp > 0)
         repodata_set_num(pd->data, SOLVID_META, REPOSITORY_TIMESTAMP, pd->timestamp);
       break;
-    case STATE_DATA: break;
+    case STATE_DATA:
+      if (pd->rdhandle)
+        repodata_add_flexarray(pd->data, SOLVID_META, REPOSITORY_REPOMD, pd->rdhandle);
+      pd->rdhandle = 0;
+      break;
     case STATE_LOCATION: break;
-    case STATE_CHECKSUM: break;
-    case STATE_OPENCHECKSUM: break;
+
+    case STATE_CHECKSUM:
+    case STATE_OPENCHECKSUM:
+      {
+        int l;
+        Id type;
+        if (!strcasecmp(pd->tmpattr, "sha") || !strcasecmp(pd->tmpattr, "sha1"))
+          l = SIZEOF_SHA1 * 2, type = REPOKEY_TYPE_SHA1;
+        else if (!strcasecmp(pd->tmpattr, "sha256"))
+          l = SIZEOF_SHA256 * 2, type = REPOKEY_TYPE_SHA256;
+        else if (!strcasecmp(pd->tmpattr, "md5"))
+          l = SIZEOF_MD5 * 2, type = REPOKEY_TYPE_MD5;
+        else
+          {
+            fprintf(stderr, "Unknown checksum type: %d: %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr);
+            exit(1);
+          }
+        if (strlen(pd->content) != l)
+          {
+            fprintf(stderr, "Invalid checksum length: %d: for %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr);
+            exit(1);
+          }
+        repodata_set_checksum(pd->data, pd->rdhandle, pd->state == STATE_CHECKSUM ? REPOSITORY_REPOMD_CHECKSUM : REPOSITORY_REPOMD_OPENCHECKSUM, type, pd->content);
+        break;
+      }
+
     case STATE_TIMESTAMP:
       {
         /**
@@ -328,6 +375,8 @@ endElement(void *userData, const char *name)
          * the metadata was generated
          */
         int timestamp = atoi(pd->content);
+       if (timestamp)
+          repodata_set_num(pd->data, pd->rdhandle, REPOSITORY_REPOMD_TIMESTAMP, timestamp);
         if (timestamp > pd->timestamp)
           pd->timestamp = timestamp;
         break;
@@ -432,6 +481,7 @@ repo_add_repomdxml(Repo *repo, FILE *fp, int flags)
   pd.lcontent = 0;
   XML_Parser parser = XML_ParserCreate(NULL);
   XML_SetUserData(parser, &pd);
+  pd.parser = &parser;
   XML_SetElementHandler(parser, startElement, endElement);
   XML_SetCharacterDataHandler(parser, characterData);
   for (;;)
index 18dbf70..51ea595 100644 (file)
@@ -931,11 +931,11 @@ endElement(void *userData, const char *name)
       {
         int l;
         Id type, index;
-        if (!strcasecmp (pd->tmpattr, "sha") || !strcasecmp (pd->tmpattr, "sha1"))
+        if (!strcasecmp(pd->tmpattr, "sha") || !strcasecmp(pd->tmpattr, "sha1"))
           l = SIZEOF_SHA1 * 2, type = REPOKEY_TYPE_SHA1;
-        else if (!strcasecmp (pd->tmpattr, "sha256"))
+        else if (!strcasecmp(pd->tmpattr, "sha256"))
           l = SIZEOF_SHA256 * 2, type = REPOKEY_TYPE_SHA256;
-        else if (!strcasecmp (pd->tmpattr, "md5"))
+        else if (!strcasecmp(pd->tmpattr, "md5"))
           l = SIZEOF_MD5 * 2, type = REPOKEY_TYPE_MD5;
         else
           {
index 160e880..c1b5c5b 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Mon Jun 22 16:01:02 CEST 2009 - mls@suse.de
+
+- create libsatsolverext.a
+- 0.14.2
+
+-------------------------------------------------------------------
 Wed May  6 19:52:39 CEST 2009 - ma@suse.de
 
 - Fix to support sha256 hashes (bnc#501425)
index a2ee407..723af5d 100644 (file)
@@ -209,6 +209,13 @@ KNOWNID(DELTA_SEQ_NUM,                     "delta:seqnum"),
 
 KNOWNID(NAMESPACE_PRODUCTBUDDY,         "namespace:productbuddy"),
 
+KNOWNID(REPOSITORY_REPOMD,             "repository:repomd"),
+KNOWNID(REPOSITORY_REPOMD_TYPE,                "repository:repomd:type"),
+KNOWNID(REPOSITORY_REPOMD_LOCATION,    "repository:repomd:location"),
+KNOWNID(REPOSITORY_REPOMD_TIMESTAMP,   "repository:repomd:timestamp"),
+KNOWNID(REPOSITORY_REPOMD_CHECKSUM,    "repository:repomd:checksum"),
+KNOWNID(REPOSITORY_REPOMD_OPENCHECKSUM,        "repository:repomd:openchecksum"),
+
 KNOWNID(ID_NUM_INTERNAL,               0)
 
 #ifdef KNOWNID_INITIALIZE