Imported Upstream version 0.6.12
[platform/upstream/libsolv.git] / ext / repo_autopattern.c
index 4335382..7edfc6c 100644 (file)
@@ -132,13 +132,29 @@ repo_add_autopattern(Repo *repo, int flags)
                  continue;
                if (rd->name == pattern_id)
                  {
+                   const char *evrstr = pool_id2str(pool, rd->evr);
+                   if (evrstr[0] == '.')       /* hack to allow provides that do not create a pattern */
+                     continue;
+                   if (patq2.count && patq2.elements[patq2.count - 2] == p)
+                     {
+                       /* hmm, two provides. choose by evrstr */
+                       if (strcmp(evrstr, pool_id2str(pool, patq2.elements[patq2.count - 1])) >= 0)
+                         continue;
+                       patq2.count -= 2;
+                     }
                    queue_push2(&patq2, p, rd->evr);
-                   break;
                  }
                if (rd->name == product_id)
                  {
+                   const char *evrstr = pool_id2str(pool, rd->evr);
+                   if (prdq2.count && prdq2.elements[prdq2.count - 2] == p)
+                     {
+                       /* hmm, two provides. choose by evrstr */
+                       if (strcmp(evrstr, pool_id2str(pool, prdq2.elements[prdq2.count - 1])) >= 0)
+                         continue;
+                       prdq2.count -= 2;
+                     }
                    queue_push2(&prdq2, p, rd->evr);
-                   break;
                  }
              }
        }
@@ -359,6 +375,10 @@ repo_add_autopattern(Repo *repo, int flags)
            }
          if (!strcmp(pn, "product-label()") && evr)
            repodata_set_str(data, s2 - pool->solvables, PRODUCT_SHORTLABEL, newname);
+         else if (!strcmp(pn, "product-register-target()") && evr)
+           repodata_set_str(data, s2 - pool->solvables, PRODUCT_REGISTER_TARGET, newname);
+         else if (!strcmp(pn, "product-register-flavor()") && evr)
+           repodata_set_str(data, s2 - pool->solvables, PRODUCT_REGISTER_FLAVOR, newname);
          else if (!strcmp(pn, "product-type()") && evr)
            repodata_set_str(data, s2 - pool->solvables, PRODUCT_TYPE, newname);
          else if (!strcmp(pn, "product-cpeid()") && evr)