From: Michael Schroeder Date: Thu, 13 Jun 2013 16:35:39 +0000 (+0200) Subject: add an ugly workaround so that repo_write knows how to deal with filelist extensions X-Git-Tag: BASE-SuSE-Code-13_1-Branch~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8243f6d9275395544baa614e8788596fb11c5d34;p=thirdparty%2Flibsolv.git add an ugly workaround so that repo_write knows how to deal with filelist extensions See BUGS file. Without that patch, repo_write wrote both the filelist in the primary data and the full filelists, resulting in a broken solv file. Now, the filelist from the primary file will not be written. Note that this is just a bad workaround and should be fixed completely different. See BUGS file. --- diff --git a/src/repo_write.c b/src/repo_write.c index fd8ff40a..9f314cb6 100644 --- a/src/repo_write.c +++ b/src/repo_write.c @@ -1006,6 +1006,23 @@ repo_write_stdkeyfilter(Repo *repo, Repokey *key, void *kfdata) return KEY_STORAGE_INCORE; } +/* + * return true if the repodata contains the filelist (and just + * the filelist). The same code is used in the dataiterator. The way + * it is used is completely wrong, of course, as having the filelist + * key does not mean it is used for a specific solvable. Nevertheless + * it is better to have it than to write broken solv files. + */ +static inline int +is_filelist_extension(Repodata *data) +{ + int j; + for (j = 1; j < data->nkeys; j++) + if (data->keys[j].name != REPOSITORY_SOLVABLES && data->keys[j].name != SOLVABLE_FILELIST) + return 0; + return 1; +} + /* * Repo */ @@ -1025,7 +1042,7 @@ int repo_write_filtered(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Queue *keyq) { Pool *pool = repo->pool; - int i, j, n; + int i, j, n, lastfilelistn; Solvable *s; NeedId *needid; int nstrings, nrels; @@ -1127,6 +1144,7 @@ repo_write_filtered(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey * dirpool = 0; dirpooldata = 0; n = ID_NUM_INTERNAL; + lastfilelistn = 0; FOR_REPODATAS(repo, i, data) { cbdata.keymapstart[i] = n; @@ -1217,6 +1235,20 @@ repo_write_filtered(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey * idused = 1; /* dirs also use ids */ dirused = 1; } + if (key->type == REPOKEY_TYPE_DIRSTRARRAY && key->name == SOLVABLE_FILELIST) + { + /* is this a file list extension */ + if (is_filelist_extension(data)) + { + /* hmm, we have a file list extension. Kill filelist of other repodata. + * XXX: this is wrong, as the extension does not need to cover all + * solvables of the other repodata */ + if (lastfilelistn) + cbdata.keymap[lastfilelistn] = 0; + } + else + lastfilelistn = n; + } } if (idused) {