add autoproduct support
[platform/upstream/libsolv.git] / ext / repo_susetags.c
index f6fd833..440e2d5 100644 (file)
@@ -130,12 +130,11 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id ma
 static void
 add_source(struct parsedata *pd, char *line, Solvable *s, Id handle)
 {
-  Repo *repo = s->repo;
-  Pool *pool = repo->pool;
+  Pool *pool = s->repo->pool;
   char *sp[5];
   Id name;
-  Id evr;
   Id arch;
+  const char *evr, *sevr;
 
   if (split(line, sp, 5) != 4)
     {
@@ -144,17 +143,26 @@ add_source(struct parsedata *pd, char *line, Solvable *s, Id handle)
     }
 
   name = pool_str2id(pool, sp[0], 1);
-  evr = makeevr(pool, join2(&pd->jd, sp[1], "-", sp[2]));
-  arch = pool_str2id(pool, sp[3], 1);
-  /* XXX: could record a dep here, depends on where we want to store the data */
+  arch = pool_str2id(pool, sp[3], 1);  /* do this before id2str */
+  evr = join2(&pd->jd, sp[1], "-", sp[2]);
+  sevr = pool_id2str(pool, s->evr);
+  if (sevr)
+    {
+      /* strip epoch */
+      const char *p;
+      for (p = sevr; *p >= '0' && *p <= '9'; p++)
+       ;
+      if (p != sevr && *p == ':' && p[1])
+       sevr = p;
+    }
   if (name == s->name)
     repodata_set_void(pd->data, handle, SOLVABLE_SOURCENAME);
   else
     repodata_set_id(pd->data, handle, SOLVABLE_SOURCENAME, name);
-  if (evr == s->evr)
+  if (sevr && !strcmp(sevr, evr))
     repodata_set_void(pd->data, handle, SOLVABLE_SOURCEEVR);
   else
-    repodata_set_id(pd->data, handle, SOLVABLE_SOURCEEVR, evr);
+    repodata_set_id(pd->data, handle, SOLVABLE_SOURCEEVR, pool_str2id(pool, evr, 1));
   repodata_set_constantid(pd->data, handle, SOLVABLE_SOURCEARCH, arch);
 }
 
@@ -215,67 +223,6 @@ set_checksum(struct parsedata *pd, Repodata *data, Id handle, Id keyname, char *
   repodata_set_checksum(data, handle, keyname, type, sp[1]);
 }
 
-static void
-set_delta_location(Repodata *data, Id handle, int medianr, char *dir, char *file)
-{
-  Pool *pool = data->repo->pool;
-  int l = 0; 
-  char *p, *op;
-
-  if (!dir)
-    {    
-      if ((dir = strrchr(file, '/')) != 0)
-        {
-          l = dir - file;
-          dir = file;
-          file = dir + l + 1; 
-          if (!l) 
-            l++;
-        }
-    }    
-  else 
-    l = strlen(dir);
-  if (l >= 2 && dir[0] == '.' && dir[1] == '/' && (l == 2 || dir[2] != '/'))
-    {    
-      dir += 2;
-      l -= 2;
-    }    
-  if (l == 1 && dir[0] == '.') 
-    l = 0; 
-  if (dir && l)
-    repodata_set_id(data, handle, DELTA_LOCATION_DIR, pool_strn2id(pool, dir, l, 1));
-  if ((p = strrchr(file, '.')) != 0)
-    {
-      *p = 0;
-      if ((op = strrchr(file, '.')) != 0)
-       {
-         *p = '.';
-         p = op;
-         *p = 0;
-         if (!strcmp(p + 1, "delta.rpm") && (op = strrchr(file, '.')) != 0)
-           {
-             *p = '.';
-             p = op;
-             *p = 0;
-           }
-       }
-      repodata_set_id(data, handle, DELTA_LOCATION_SUFFIX, pool_str2id(pool, p + 1, 1));
-    }
-  if ((p = strrchr(file, '-')) != 0)
-    {
-      *p = 0;
-      if ((op = strrchr(file, '-')) != 0)
-       {
-         *p = '-';
-         p = op;
-         *p = 0;
-       }
-      repodata_set_id(data, handle, DELTA_LOCATION_EVR, pool_str2id(pool, p + 1, 1));
-    }
-  repodata_set_id(data, handle, DELTA_LOCATION_NAME, pool_str2id(pool, file, 1));
-}
-
-
 
 /*
  * id3_cmp
@@ -438,9 +385,9 @@ finish_solvable(struct parsedata *pd, Solvable *s, Offset freshens)
 }
 
 static Hashtable
-joinhash_init(Repo *repo, Hashmask *hmp)
+joinhash_init(Repo *repo, Hashval *hmp)
 {
-  Hashmask hm = mkmask(repo->nsolvables);
+  Hashval hm = mkmask(repo->nsolvables);
   Hashtable ht = solv_calloc(hm + 1, sizeof(*ht));
   Hashval h, hh;
   Solvable *s;
@@ -459,7 +406,7 @@ joinhash_init(Repo *repo, Hashmask *hmp)
 }
 
 static Solvable *
-joinhash_lookup(Repo *repo, Hashtable ht, Hashmask hm, Id name, Id evr, Id arch, Id start)
+joinhash_lookup(Repo *repo, Hashtable ht, Hashval hm, Id name, Id evr, Id arch, Id start)
 {
   Hashval h, hh;
 
@@ -531,7 +478,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
   Repodata *data = 0;
   Id handle = 0;
   Hashtable joinhash = 0;
-  Hashmask joinhashm = 0;
+  Hashval joinhashm = 0;
   int createdpkgs = 0;
 
   if ((flags & (SUSETAGS_EXTEND|REPO_EXTEND_SOLVABLES)) != 0 && repo->nrepodata)
@@ -561,7 +508,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
     {
       Repodata *sdata;
       int i;
-      
+
       FOR_REPODATAS(repo, i, sdata)
        {
          int p;
@@ -591,7 +538,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
            }
        }
     }
-  
+
   /*
    * read complete file
    *
@@ -747,7 +694,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
                    pd.ret = pool_error(pool, -1, "susetags: line %d: bad location line '%s'\n", pd.lineno, line);
                    continue;
                  }
-               set_delta_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : 0, sp[1]);
+               repodata_set_deltalocation(data, handle, atoi(sp[0]), i == 3 ? sp[2] : 0, sp[1]);
                continue;
              }
            case CTAG('=', 'S', 'i', 'z'):
@@ -1144,11 +1091,13 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int
            break;
 
          default:
+#if 0
            pool_debug(pool, SOLV_WARN, "susetags: unknown line: %d: %s\n", pd.lineno, line);
+#endif
            break;
        }
 
-    } /* for(;;) */
+    }
 
   if (s)
     finish_solvable(&pd, s, freshens);