]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
support repository:repomd:size, cleanup code a bit
authorMichael Schroeder <mls@suse.de>
Tue, 23 Oct 2012 11:39:45 +0000 (13:39 +0200)
committerMichael Schroeder <mls@suse.de>
Tue, 23 Oct 2012 11:39:45 +0000 (13:39 +0200)
ext/repo_products.c
ext/repo_repomdxml.c
ext/repo_rpmmd.c
src/knownid.h

index 598b2ab64f889499aab14b490e916b57e17b2df8..1994e7ae001db52cf66c5c528b79a8179237af3a 100644 (file)
@@ -324,7 +324,7 @@ endElement(void *userData, const char *name)
       repodata_set_str(pd->data, pd->handle, PRODUCT_REGISTER_RELEASE, pd->content);
       break;
     case STATE_CPEID:
-      if (pd->content)
+      if (*pd->content)
         repodata_set_str(pd->data, pd->handle, SOLVABLE_CPEID, pd->content);
     default:
       break;
index 0697aa8335ee698e00acd778e5551d1358c87146..d8ae5e5c97d5441799eb2ae62920417e45a4b175 100644 (file)
@@ -106,6 +106,7 @@ enum state {
   STATE_CHECKSUM,
   STATE_TIMESTAMP,
   STATE_OPENCHECKSUM,
+  STATE_SIZE,
   NUMSTATES
 };
 
@@ -144,7 +145,8 @@ static struct stateswitch stateswitches[] = {
   { STATE_DATA,        "location",        STATE_LOCATION, 0 },
   { STATE_DATA,        "checksum",        STATE_CHECKSUM, 1 },
   { STATE_DATA,        "timestamp",       STATE_TIMESTAMP, 1 },
-  { STATE_DATA,        "open-checksum",    STATE_OPENCHECKSUM, 1 },
+  { STATE_DATA,        "open-checksum",   STATE_OPENCHECKSUM, 1 },
+  { STATE_DATA,        "size",            STATE_SIZE, 1 },
   { NUMSTATES }
 };
 
@@ -232,7 +234,6 @@ startElement(void *userData, const char *name, const char **atts)
 
   switch(pd->state)
     {
-    case STATE_START: break;
     case STATE_REPOMD:
       {
         const char *updstr;
@@ -256,12 +257,6 @@ startElement(void *userData, const char *name, const char **atts)
           }
           break;
         }
-    case STATE_SUSEINFO: break;
-    case STATE_EXPIRE: break;
-    case STATE_KEYWORDS: break;
-    case STATE_KEYWORD: break;
-    case STATE_CONTENT: break;
-    case STATE_REVISION: break;
     case STATE_DISTRO:
       {
         /* this is extra metadata about the product this repository
@@ -338,7 +333,6 @@ endElement(void *userData, const char *name)
   pd->statedepth--;
   switch (pd->state)
     {
-    case STATE_START: break;
     case STATE_REPOMD:
       if (pd->timestamp > 0)
         repodata_set_num(pd->data, SOLVID_META, REPOSITORY_TIMESTAMP, pd->timestamp);
@@ -348,7 +342,6 @@ endElement(void *userData, const char *name)
         repodata_add_flexarray(pd->data, SOLVID_META, REPOSITORY_REPOMD, pd->rdhandle);
       pd->rdhandle = 0;
       break;
-    case STATE_LOCATION: break;
 
     case STATE_CHECKSUM:
     case STATE_OPENCHECKSUM:
@@ -384,34 +377,35 @@ endElement(void *userData, const char *name)
       /* repomd.xml content and suseinfo.xml keywords are equivalent */
     case STATE_CONTENT:
     case STATE_KEYWORD:
-      if (pd->content)
+      if (*pd->content)
        repodata_add_poolstr_array(pd->data, SOLVID_META, REPOSITORY_KEYWORDS, pd->content);
       break;
     case STATE_REVISION:
-      if (pd->content)
+      if (*pd->content)
        repodata_add_poolstr_array(pd->data, SOLVID_META, REPOSITORY_REVISION, pd->content);
       break;
     case STATE_DISTRO:
       /* distro tag is used in repomd.xml to say the product this repo is
          made for */
-      if (pd->content)
+      if (*pd->content)
         repodata_set_str(pd->data, pd->rphandle, REPOSITORY_PRODUCT_LABEL, pd->content);
       repodata_add_flexarray(pd->data, SOLVID_META, REPOSITORY_DISTROS, pd->rphandle);
       break;
     case STATE_UPDATES:
-      /* distro tag is used in suseinfo.xml to say the repo updates a product
+      /* updates tag is used in suseinfo.xml to say the repo updates a product
          however it s not yet a tag standarized for repomd.xml */
-      if (pd->content)
+      if (*pd->content)
         repodata_set_str(pd->data, pd->ruhandle, REPOSITORY_PRODUCT_LABEL, pd->content);
       repodata_add_flexarray(pd->data, SOLVID_META, REPOSITORY_UPDATES, pd->ruhandle);
       break;
     case STATE_REPO:
-      if (pd->content)
+      if (*pd->content)
        repodata_add_poolstr_array(pd->data, SOLVID_META, REPOSITORY_REPOID, pd->content);
       break;
-    case STATE_SUSEINFO: break;
-    case STATE_KEYWORDS: break;
-    case NUMSTATES: break;
+    case STATE_SIZE:
+      if (*pd->content)
+       repodata_set_num(pd->data, pd->rdhandle, REPOSITORY_REPOMD_SIZE, strtoull(pd->content, 0, 10));
+      break;
     default:
       break;
     }
index b8bd9045e70fb33d020a539c1f80fa25ba6b36a2..b765e5bd9281f3c5cdb4df8cb433e57d8ad1cdc6 100644 (file)
@@ -753,32 +753,26 @@ startElement(void *userData, const char *name, const char **atts)
       repodata_set_void(pd->data, handle, SOLVABLE_ISVISIBLE);
       break;
     case STATE_INCLUDESENTRY:
-      {
-       const char *tmp = find_attr("pattern", atts);
-       if (tmp)
-         repodata_add_poolstr_array(pd->data, pd->handle, SOLVABLE_INCLUDES, join2(&pd->jd, "pattern", ":", tmp));
-        break;
-      }
+      str = find_attr("pattern", atts);
+      if (str)
+       repodata_add_poolstr_array(pd->data, pd->handle, SOLVABLE_INCLUDES, join2(&pd->jd, "pattern", ":", str));
+      break;
     case STATE_EXTENDSENTRY:
-      {
-       const char *tmp = find_attr("pattern", atts);
-       if (tmp)
-         repodata_add_poolstr_array(pd->data, pd->handle, SOLVABLE_EXTENDS, join2(&pd->jd, "pattern", ":", tmp));
-        break;
-      }
+      str = find_attr("pattern", atts);
+      if (str)
+       repodata_add_poolstr_array(pd->data, pd->handle, SOLVABLE_EXTENDS, join2(&pd->jd, "pattern", ":", str));
+      break;
     case STATE_LOCATION:
       str = find_attr("href", atts);
       if (str)
        repodata_set_location(pd->data, handle, 0, 0, str);
       break;
     case STATE_CHECKSUM:
-      {
-       const char *tmp = find_attr("type", atts);
-       pd->chksumtype = tmp && *tmp ? solv_chksum_str2type(tmp) : 0;
-        if (!pd->chksumtype)
-         pd->ret = pool_error(pool, -1, "line %d: unknown checksum type: %s", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), tmp ? tmp: "NULL");
-        break;
-      }
+      str = find_attr("type", atts);
+      pd->chksumtype = str && *str ? solv_chksum_str2type(str) : 0;
+      if (!pd->chksumtype)
+       pd->ret = pool_error(pool, -1, "line %d: unknown checksum type: %s", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), str ? str : "NULL");
+      break;
     case STATE_TIME:
       {
         unsigned int t;
@@ -788,20 +782,11 @@ startElement(void *userData, const char *name, const char **atts)
        break;
       }
     case STATE_SIZE:
-      {
-        unsigned long long k;
-        str = find_attr("installed", atts);
-       if (str && (k = strtoull(str, 0, 10)) != 0)
-         repodata_set_num(pd->data, handle, SOLVABLE_INSTALLSIZE, k);
-       /* XXX the "package" attribute gives the size of the rpm file,
-          i.e. the download size.  Except on packman, there it seems to be
-          something else entirely, it has a value near to the other two
-          values, as if the rpm is uncompressed.  */
-        str = find_attr("package", atts);
-       if (str && (k = strtoull(str, 0, 10)) != 0)
-         repodata_set_num(pd->data, handle, SOLVABLE_DOWNLOADSIZE, k);
-        break;
-      }
+      if ((str = find_attr("installed", atts)) != 0)
+       repodata_set_num(pd->data, handle, SOLVABLE_INSTALLSIZE, strtoull(str, 0, 10));
+      if ((str = find_attr("package", atts)) != 0)
+       repodata_set_num(pd->data, handle, SOLVABLE_DOWNLOADSIZE, strtoull(str, 0, 10));
+      break;
     case STATE_HEADERRANGE:
       {
         unsigned int end;
index 655657e5b758d107445e8c8815ba15186f3c6a61..ad8b4a46af1a76b5514001a712b8ce50952a50e5 100644 (file)
@@ -244,6 +244,8 @@ KNOWNID(SUSETAGS_SHARE_ARCH,                "susetags:share:arch"),
 
 KNOWNID(ARCH_ANY,                      "any"),
 
+KNOWNID(REPOSITORY_REPOMD_SIZE,                "repository:repomd:size"),
+
 KNOWNID(ID_NUM_INTERNAL,               0)
 
 #ifdef KNOWNID_INITIALIZE