Imported Upstream version 0.7.18
[platform/upstream/libsolv.git] / src / repo_solv.c
index 5858d4f..761d06e 100644 (file)
@@ -478,7 +478,7 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
   int oldnstrings = pool->ss.nstrings;
   int oldnrels = pool->nrels;
 
-  struct _Stringpool *spool;
+  struct s_Stringpool *spool;
 
   Repodata *parent = 0;
   Repodata data;
@@ -859,7 +859,7 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
        type = idmap[type];
       else if ((flags & REPO_LOCALPOOL) != 0)
         type = pool_str2id(pool, stringpool_id2str(spool, type), 1);
-      if (type < REPOKEY_TYPE_VOID || type > REPOKEY_TYPE_FLEXARRAY)
+      if (type < REPOKEY_TYPE_VOID || type > REPOKEY_TYPE_DELETED)
        {
          data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "unsupported data type '%s'", pool_id2str(pool, type));
          type = REPOKEY_TYPE_VOID;
@@ -879,6 +879,8 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
            data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "main solvable data must use incore storage %d", keys[i].storage);
          keys[i].storage = KEY_STORAGE_SOLVABLE;
        }
+      if ((type == REPOKEY_TYPE_FIXARRAY || type == REPOKEY_TYPE_FLEXARRAY) && keys[i].storage != KEY_STORAGE_INCORE)
+       data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "flex/fixarrays must use incore storage\n");
       /* cannot handle rel idarrays in incore/vertical */
       if (type == REPOKEY_TYPE_REL_IDARRAY && keys[i].storage != KEY_STORAGE_SOLVABLE)
        data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "type REL_IDARRAY is only supported for STORAGE_SOLVABLE");
@@ -1216,12 +1218,9 @@ printf("=> %s %s %p\n", pool_id2str(pool, keys[key].name), pool_id2str(pool, key
            }
          /* FALLTHROUGH */
        default:
-         if (id == RPM_RPMDBID && s && (keys[key].type == REPOKEY_TYPE_U32 || keys[key].type == REPOKEY_TYPE_NUM))
+         if (id == RPM_RPMDBID && s && keys[key].type == REPOKEY_TYPE_NUM)
            {
-             if (keys[key].type == REPOKEY_TYPE_U32)
-               dp = data_read_u32(dp, (unsigned int *)&id);
-             else
-               dp = data_read_id_max(dp, &id, 0, 0, &data);
+             dp = data_read_id(dp, &id);
              if (!repo->rpmdbid)
                repo->rpmdbid = repo_sidedata_create(repo, sizeof(Id));
              repo->rpmdbid[(s - pool->solvables) - repo->start] = id;
@@ -1270,7 +1269,7 @@ printf("=> %s %s %p\n", pool_id2str(pool, keys[key].name), pool_id2str(pool, key
       keys[i].type = REPOKEY_TYPE_IDARRAY;
 
   for (i = 1; i < numkeys; i++)
-    if (keys[i].storage == KEY_STORAGE_VERTICAL_OFFSET)
+    if (keys[i].storage == KEY_STORAGE_VERTICAL_OFFSET && keys[i].size)
       break;
   if (i < numkeys && !data.error)
     {
@@ -1310,6 +1309,7 @@ printf("=> %s %s %p\n", pool_id2str(pool, keys[key].name), pool_id2str(pool, key
       /* overwrite stub repodata */
       repodata_freedata(parent);
       data.repodataid = parent->repodataid;
+      data.loadcallback = parent->loadcallback;
       *parent = data;
     }
   else
@@ -1326,6 +1326,17 @@ printf("=> %s %s %p\n", pool_id2str(pool, keys[key].name), pool_id2str(pool, key
       repo->repodata[repo->nrepodata++] = data;
     }
 
+  if ((flags & REPO_EXTEND_SOLVABLES) != 0)
+    {
+      if (repodata_has_keyname(&data, SOLVABLE_FILELIST))
+       repodata_set_filelisttype(repo->repodata + data.repodataid, REPODATA_FILELIST_EXTENSION);
+    }
+  else
+    {
+      if (repodata_lookup_type(&data, SOLVID_META, REPOSITORY_FILTEREDFILELIST))
+        repodata_set_filelisttype(repo->repodata + data.repodataid, REPODATA_FILELIST_FILTERED);
+    }
+
   /* create stub repodata entries for all external */
   if (!(flags & SOLV_ADD_NO_STUBS) && !parent)
     {
@@ -1333,7 +1344,7 @@ printf("=> %s %s %p\n", pool_id2str(pool, keys[key].name), pool_id2str(pool, key
        if (data.keys[key].name == REPOSITORY_EXTERNAL && data.keys[key].type == REPOKEY_TYPE_FLEXARRAY)
          break;
       if (key < data.nkeys)
-       repodata_create_stubs(repo->repodata + (repo->nrepodata - 1));
+       repodata_create_stubs(repo->repodata + data.repodataid);
     }
 
   POOL_DEBUG(SOLV_DEBUG_STATS, "repo_add_solv took %d ms\n", solv_timems(now));