Imported Upstream version 0.6.19
[platform/upstream/libsolv.git] / ext / repo_rpmmd.c
index 21dd913..a45d491 100644 (file)
@@ -19,7 +19,9 @@
 #include "tools_util.h"
 #include "repo_rpmmd.h"
 #include "chksum.h"
-
+#ifdef ENABLE_COMPLEX_DEPS
+#include "pool_parserpmrichdep.h"
+#endif
 
 enum state {
   STATE_START,
@@ -466,7 +468,7 @@ static char *flagtab[] = {
 static unsigned int
 adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts, int isreq)
 {
-  Id id, name, marker;
+  Id id, marker;
   const char *n, *f, *k;
   const char **a;
 
@@ -496,10 +498,18 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts
          pd->acontent = l + 256;
        }
       sprintf(pd->content, "%s:%s", k, n);
-      name = pool_str2id(pool, pd->content, 1);
+      id = pool_str2id(pool, pd->content, 1);
+    }
+#ifdef ENABLE_COMPLEX_DEPS
+  else if (!f && n[0] == '(')
+    {
+      id = pool_parserpmrichdep(pool, n);
+      if (!id)
+       return olddeps;
     }
+#endif
   else
-    name = pool_str2id(pool, (char *)n, 1);
+    id = pool_str2id(pool, (char *)n, 1);
   if (f)
     {
       Id evr = makeevr_atts(pool, pd, atts);
@@ -508,10 +518,8 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts
        if (!strcmp(f, flagtab[flags]))
          break;
       flags = flags < 6 ? flags + 1 : 0;
-      id = pool_rel2id(pool, name, evr, flags, 1);
+      id = pool_rel2id(pool, id, evr, flags, 1);
     }
-  else
-    id = name;
 #if 0
   fprintf(stderr, "new dep %s\n", pool_dep2str(pool, id));
 #endif
@@ -768,10 +776,20 @@ startElement(void *userData, const char *name, const char **atts)
       str = find_attr("href", atts);
       if (str)
        {
-         repodata_set_location(pd->data, handle, 0, 0, str);
-         str = find_attr("xml:base", atts);
-         if (str)
-           repodata_set_poolstr(pd->data, handle, SOLVABLE_MEDIABASE, str);
+         int medianr = 0;
+         const char *base = find_attr("xml:base", atts);
+         if (base  && !strncmp(base, "media:", 6))
+           {
+             /* check for the media number in the fragment */
+             int l = strlen(base);
+             while (l && base[l - 1] >= '0' && base[l - 1] <= '9')
+               l--;
+             if (l && base[l - 1] == '#' && base[l])
+               medianr = atoi(base + l);
+           }
+         repodata_set_location(pd->data, handle, medianr, 0, str);
+         if (base)
+           repodata_set_poolstr(pd->data, handle, SOLVABLE_MEDIABASE, base);
        }
       break;
     case STATE_CHECKSUM: