+
+void
+rewrite_repos(Pool *pool, Id *addedfileprovides)
+{
+ Repo *repo;
+ Repodata *data;
+ Map providedids;
+ Queue fileprovidesq;
+ Id id;
+ int i, j, n, nprovidedids;
+ struct repoinfo *cinfo;
+
+ map_init(&providedids, pool->ss.nstrings);
+ queue_init(&fileprovidesq);
+ for (nprovidedids = 0; (id = addedfileprovides[nprovidedids]) != 0; nprovidedids++)
+ MAPSET(&providedids, id);
+ FOR_REPOS(i, repo)
+ {
+ /* make sure this repo has just one main repodata */
+ if (!repo->nrepodata)
+ continue;
+ cinfo = repo->appdata;
+ data = repo->repodata + 0;
+ if (data->store.pagefd == -1)
+ continue;
+ if (repodata_lookup_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, &fileprovidesq))
+ {
+ n = 0;
+ for (j = 0; j < fileprovidesq.count; j++)
+ if (MAPTST(&providedids, fileprovidesq.elements[j]))
+ n++;
+ if (n == nprovidedids)
+ continue; /* nothing new added */
+ }
+ /* oh my! */
+ for (j = 0; addedfileprovides[j]; j++)
+ repodata_add_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, addedfileprovides[j]);
+ repodata_internalize(data);
+ writecachedrepo(repo, data, 0, cinfo ? cinfo->cookie : installedcookie);
+ }
+ queue_free(&fileprovidesq);
+ map_free(&providedids);
+}
+