make url ids extensible and fix parsers.
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 12 Sep 2008 13:12:34 +0000 (13:12 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 12 Sep 2008 13:12:34 +0000 (13:12 +0000)
parse urls in products

package/libsatsolver.changes
src/knownid.h
tools/repo_content.c
tools/repo_products.c
tools/repo_rpmmd.c

index 1db4a869eef5b17ebf47db780e55acc7d2322ab7..05ae0e72f48aed82595d17d53d7b2f0e1fddd389 100644 (file)
@@ -3,6 +3,7 @@ Fri Sep 12 14:01:11 CEST 2008 - dmacvicar@suse.de
 
 - add repo_add_poolstr_array
 - move updates="key,key.." to repomd.xml
+- make product url ids more extensible
 - 0.10.11
 
 -------------------------------------------------------------------
index b8c6902b5f9a5226e6c3b2c40312d10db3f35533..9db847d3ef81fd4a97e757851363c0fd3c694b6b 100644 (file)
@@ -156,6 +156,7 @@ KNOWNID(PRODUCT_URL_TYPE_SMOLT,             "product:url:type:smolt"),
 KNOWNID(PRODUCT_URL_TYPE_RELNOTES,     "product:url:type:relnotes"),
 KNOWNID(PRODUCT_URL_TYPE_EXTRA,                "product:url:type:extra"),
 KNOWNID(PRODUCT_URL_TYPE_OPTIONAL,     "product:url:type:optional"),
+KNOWNID(PRODUCT_URL_TYPE_UPDATE,       "product:url:type:update"),
 KNOWNID(PRODUCT_FLAGS,                 "product:flags"),
 KNOWNID(PRODUCT_FLAVOR,                        "product:flavor"),
 KNOWNID(PRODUCT_REFERENCES,            "product:references"),
index c7f48ef56598668e2329c5271a8899d7b63df9d9..297efa3f448d2f1715b77e45607b2fc2bd07f661 100644 (file)
@@ -203,6 +203,28 @@ add_multiple_strings(Repodata *data, Id handle, Id name, char *value)
     }
 }
 
+/*
+ * split value and add to pool
+ */
+
+static void
+add_multiple_urls(Repodata *data, Id handle, char *value, Id type)
+{
+  char *sp[2];
+  while (value)
+    {
+      int words = split(value, sp, 2);
+      if (!words)
+       break;
+      repodata_add_poolstr_array(data, handle, PRODUCT_URL, sp[0]);
+      repodata_add_idarray(data, handle, PRODUCT_URL_TYPE, type);
+      if (words == 1)
+       break;
+      value = sp[1];
+    }
+}
+
+
 
 /*
  * add 'content' to repo
@@ -333,11 +355,13 @@ repo_add_content(Repo *repo, FILE *fp)
          else if (istag ("DATADIR"))
            repo_set_str(repo, s - pool->solvables, SUSETAGS_DATADIR, value);
          else if (istag ("UPDATEURLS"))
-           add_multiple_strings(data, handle, PRODUCT_UPDATEURLS, value);
+           add_multiple_urls(data, handle, value, PRODUCT_URL_TYPE_UPDATE);
          else if (istag ("EXTRAURLS"))
-           add_multiple_strings(data, handle, PRODUCT_EXTRAURLS, value);
+           add_multiple_urls(data, handle, value, PRODUCT_URL_TYPE_EXTRA);
          else if (istag ("OPTIONALURLS"))
-           add_multiple_strings(data, handle, PRODUCT_OPTIONALURLS, value);
+           add_multiple_urls(data, handle, value, PRODUCT_URL_TYPE_OPTIONAL);
+         else if (istag ("RELNOTESURL"))
+           add_multiple_urls(data, handle, value, PRODUCT_URL_TYPE_RELNOTES);
          else if (istag ("SHORTLABEL"))
            repo_set_str(repo, s - pool->solvables, PRODUCT_SHORTLABEL, value);
          else if (istag ("LABEL")) /* LABEL is the products SUMMARY. */
@@ -346,8 +370,6 @@ repo_add_content(Repo *repo, FILE *fp)
            repo_set_str(repo, s - pool->solvables, pool_id2langid(pool, SOLVABLE_SUMMARY, key + 6, 1), value);
          else if (istag ("FLAGS"))
            add_multiple_strings(data, handle, PRODUCT_FLAGS, value);
-         else if (istag ("RELNOTESURL"))
-           repodata_add_poolstr_array(data, handle, PRODUCT_RELNOTESURL, value);
          else if (istag ("VENDOR"))
            s->vendor = str2id(pool, value, 1);
           else if (istag ("BASEARCHS"))
index 6b588263a3fcd4c3f6156726145dc35eddaaf149..0b9098fff735b2942b1c8dc38b2986619a677d42 100644 (file)
@@ -91,7 +91,7 @@ static struct stateswitch stateswitches[] = {
 #endif
   { STATE_PRODUCT,   "linguas",       STATE_LINGUAS,       0 },
   { STATE_PRODUCT,   "updaterepokey", STATE_UPDATEREPOKEY, 1 },
-  { STATE_URLS,      "url",           STATE_URL,           0 },
+  { STATE_URLS,      "url",           STATE_URL,           1 },
 /*  { STATE_BUILDCONFIG,"linguas",      STATE_LINGUAS,       0 }, */
   { STATE_LINGUAS,   "lang",          STATE_LANG,          0 },
   { STATE_REGISTER,  "flavor",        STATE_FLAVOR,        1 },
@@ -306,8 +306,21 @@ endElement(void *userData, const char *name)
     case STATE_URL:
       if (pd->tmpurltype)
         {
+          Id type = 0;
           repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_URL, pd->content);
-          repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_URL_TYPE, pd->content);
+
+          if ( pd->tmpurltype[0] == 's' )
+            type = PRODUCT_URL_TYPE_SMOLT;
+          else if ( pd->tmpurltype[0] == 'u' )
+            type = PRODUCT_URL_TYPE_UPDATE;
+          else if ( pd->tmpurltype[0] == 'o' )
+            type = PRODUCT_URL_TYPE_OPTIONAL;
+          else if ( pd->tmpurltype[0] == 'r' )
+            type = PRODUCT_URL_TYPE_RELNOTES;
+          else
+            type = PRODUCT_URL_TYPE_EXTRA;
+          
+          repodata_add_idarray(pd->data, pd->handle, PRODUCT_URL_TYPE, type);
         }
       break;
     case STATE_TARGET:
index 8cf4b65f9eb9ac0c20a78e07ea3f9df375110438..181bfa35e23c481fa7cd8ffa684aade95cf6a679 100644 (file)
@@ -1012,15 +1012,24 @@ endElement(void *userData, const char *name)
       break;
     case STATE_RELNOTESURL:
       if (pd->content[0])
-          repodata_set_poolstr(pd->data, handle, PRODUCT_RELNOTESURL, pd->content);
+        {
+          repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_URL, pd->content);
+          repodata_add_idarray(pd->data, pd->handle, PRODUCT_URL_TYPE, PRODUCT_URL_TYPE_RELNOTES);
+        }
       break;
     case STATE_UPDATEURL:
       if (pd->content[0])
-          repodata_set_poolstr(pd->data, handle, PRODUCT_EXTRAURLS, pd->content);
+        {
+          repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_URL, pd->content);
+          repodata_add_idarray(pd->data, pd->handle, PRODUCT_URL_TYPE, PRODUCT_URL_TYPE_UPDATE);
+        }
       break;
     case STATE_OPTIONALURL:
       if (pd->content[0])
-          repodata_set_poolstr(pd->data, handle, PRODUCT_OPTIONALURLS, pd->content);
+        {
+          repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_URL, pd->content);
+          repodata_add_idarray(pd->data, pd->handle, PRODUCT_URL_TYPE, PRODUCT_URL_TYPE_OPTIONAL);
+        }
       break;
     case STATE_FLAG:
       if (pd->content[0])