Imported Upstream version 0.6.23
[platform/upstream/libsolv.git] / ext / repo_content.c
index 44acc4d..b12c4cd 100644 (file)
@@ -28,6 +28,7 @@
 #include "chksum.h"
 #include "repo_content.h"
 #define DISABLE_SPLIT
+#define DISABLE_JOIN2
 #include "tools_util.h"
 
 /* split off a word, return null terminated pointer to it.
@@ -141,7 +142,7 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id ma
 
          if (!rel || !evr)
            {
-             pool_debug(pool, SOLV_FATAL, "repo_content: bad relation '%s %s'\n", name, rel);
+             pool_debug(pool, SOLV_ERROR, "repo_content: bad relation '%s %s'\n", name, rel);
              continue;
            }
          for (flags = 0; flags < 6; flags++)
@@ -149,7 +150,7 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id ma
              break;
          if (flags == 6)
            {
-             pool_debug(pool, SOLV_FATAL, "repo_content: unknown relation '%s'\n", rel);
+             pool_debug(pool, SOLV_ERROR, "repo_content: unknown relation '%s'\n", rel);
              continue;
            }
          id = pool_rel2id(pool, id, pool_str2id(pool, evr, 1), flags + 1, 1);
@@ -212,6 +213,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
   char *defvendor = 0;
 
   int i = 0;
+  int res = 0;
 
   /* architectures
      we use the first architecture in BASEARCHS or noarch
@@ -288,6 +290,29 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
              repodata_add_poolstr_array(data, SOLVID_META, REPOSITORY_REPOID, value);
              continue;
            }
+         if (istag ("REPOKEYWORDS"))
+           {
+             add_multiple_strings(data, SOLVID_META, REPOSITORY_KEYWORDS, value);
+             continue;
+           }
+         if (istag ("DISTRO"))
+           {
+             Id dh = repodata_new_handle(data);
+             char *p;
+             /* like with createrepo --distro */
+             if ((p = strchr(value, ',')) != 0)
+               {
+                 *p++ = 0;
+                 if (*value)
+                   repodata_set_poolstr(data, dh, REPOSITORY_PRODUCT_CPEID, value);
+               }
+             else
+               p = value;
+             if (*p)
+               repodata_set_str(data, dh, REPOSITORY_PRODUCT_LABEL, p);
+             repodata_add_flexarray(data, SOLVID_META, REPOSITORY_DISTROS, dh);
+             continue;
+           }
 
          if (istag ("DESCRDIR"))
            {
@@ -338,13 +363,15 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
              type = solv_chksum_str2type(checksumtype);
              if (!type)
                {
-                 fprintf(stderr, "Unknown checksum type: %s: %s\n", value, checksumtype);
+                 pool_error(pool, -1, "%s: unknown checksum type '%s'", value, checksumtype);
+                 res = 1;
                  continue;
                }
               l = solv_chksum_len(type);
              if (strlen(checksum) != 2 * l)
                {
-                 fprintf(stderr, "Invalid checksum length: %s: for %s\n", value, checksum);
+                 pool_error(pool, -1, "%s: invalid checksum length for %s", value, checksumtype);
+                 res = 1;
                  continue;
                }
              fh = repodata_new_handle(data);
@@ -377,11 +404,10 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
                  if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
                    s->provides = repo_addid_dep(repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
                  if (code10)
-                   s->supplements = repo_fix_supplements(repo, s->provides, s->supplements, 0);
+                   repo_rewrite_suse_deps(s, 0);
                }
              /* create new solvable */
              s = pool_id2solvable(pool, repo_add_solvable(repo));
-             repodata_extend(data, s - pool->solvables);
              handle = s - pool->solvables;
              s->name = pool_str2id(pool, join(&pd, "product", ":", value), 1);
              if (datadir)
@@ -398,7 +424,6 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
          if (!s)
            {
              s = pool_id2solvable(pool, repo_add_solvable(repo));
-             repodata_extend(data, s - pool->solvables);
              handle = s - pool->solvables;
            }
 
@@ -407,7 +432,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
           else if (istag ("RELEASE"))
             pd.tmprel = solv_strdup(value);
          else if (code11 && istag ("DISTRIBUTION"))
-           repodata_set_str(data, s - pool->solvables, SOLVABLE_DISTRIBUTION, value);
+           repodata_set_poolstr(data, s - pool->solvables, SOLVABLE_DISTRIBUTION, value);
          else if (istag ("UPDATEURLS"))
            add_multiple_urls(data, handle, value, pool_str2id(pool, "update", 1));
          else if (istag ("EXTRAURLS"))
@@ -440,43 +465,39 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
                    }
                }
             }
+         if (!code10)
+           continue;
 
          /*
           * Every tag below is Code10 only
           *
           */
 
-         if (code10 && istag ("DISTPRODUCT"))
-           /* DISTPRODUCT is for registration and Yast, not for the solver. */
-           repodata_set_str(data, s - pool->solvables, PRODUCT_DISTPRODUCT, value);
-         else if (code10 && istag ("DISTVERSION"))
-           /* DISTVERSION is for registration and Yast, not for the solver. */
-           repodata_set_str(data, s - pool->solvables, PRODUCT_DISTVERSION, value);
-         else if (code10 && istag ("ARCH"))
+         if (istag ("ARCH"))
            /* Theoretically we want to have the best arch of the given
               modifiers which still is compatible with the system
               arch.  We don't know the latter here, though.  */
            s->arch = ARCH_NOARCH;
-         else if (code10 && istag ("PREREQUIRES"))
+         else if (istag ("PREREQUIRES"))
            s->requires = adddep(pool, &pd, s->requires, value, SOLVABLE_PREREQMARKER);
-         else if (code10 && istag ("REQUIRES"))
+         else if (istag ("REQUIRES"))
            s->requires = adddep(pool, &pd, s->requires, value, -SOLVABLE_PREREQMARKER);
-         else if (code10 && istag ("PROVIDES"))
+         else if (istag ("PROVIDES"))
            s->provides = adddep(pool, &pd, s->provides, value, 0);
-         else if (code10 && istag ("CONFLICTS"))
+         else if (istag ("CONFLICTS"))
            s->conflicts = adddep(pool, &pd, s->conflicts, value, 0);
-         else if (code10 && istag ("OBSOLETES"))
+         else if (istag ("OBSOLETES"))
            s->obsoletes = adddep(pool, &pd, s->obsoletes, value, 0);
-         else if (code10 && istag ("RECOMMENDS"))
+         else if (istag ("RECOMMENDS"))
            s->recommends = adddep(pool, &pd, s->recommends, value, 0);
-         else if (code10 && istag ("SUGGESTS"))
+         else if (istag ("SUGGESTS"))
            s->suggests = adddep(pool, &pd, s->suggests, value, 0);
-         else if (code10 && istag ("SUPPLEMENTS"))
+         else if (istag ("SUPPLEMENTS"))
            s->supplements = adddep(pool, &pd, s->supplements, value, 0);
-         else if (code10 && istag ("ENHANCES"))
+         else if (istag ("ENHANCES"))
            s->enhances = adddep(pool, &pd, s->enhances, value, 0);
          /* FRESHENS doesn't seem to exist.  */
-         else if (code10 && istag ("TYPE"))
+         else if (istag ("TYPE"))
            repodata_set_str(data, s - pool->solvables, PRODUCT_TYPE, value);
 
          /* XXX do something about LINGUAS and ARCH?
@@ -497,8 +518,8 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
 
   if (s && !s->name)
     {
-      pool_debug(pool, SOLV_FATAL, "repo_content: 'content' incomplete, no product solvable created!\n");
-      repo_free_solvable_block(repo, s - pool->solvables, 1, 1);
+      pool_debug(pool, SOLV_ERROR, "repo_content: 'content' incomplete, no product solvable created!\n");
+      repo_free_solvable(repo, s - pool->solvables, 1);
       s = 0;
     }
   if (s)
@@ -517,13 +538,12 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
       if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
         s->provides = repo_addid_dep(repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
       if (code10)
-       s->supplements = repo_fix_supplements(repo, s->provides, s->supplements, 0);
+       repo_rewrite_suse_deps(s, 0);
 
       /* now for every other arch, clone the product except the architecture */
       for (i = 0; i < numotherarchs; ++i)
        {
          Solvable *p = pool_id2solvable(pool, repo_add_solvable(repo));
-         repodata_extend(data, p - pool->solvables);
          p->name = s->name;
          p->evr = s->evr;
          p->vendor = s->vendor;
@@ -542,8 +562,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
     solv_free(pd.tmp);
   solv_free(line);
   solv_free(otherarchs);
-  join_freemem();
   if (!(flags & REPO_NO_INTERNALIZE))
     repodata_internalize(data);
-  return 0;
+  return res;
 }