From: Michael Schroeder Date: Mon, 10 Sep 2018 09:26:05 +0000 (+0200) Subject: Add REPOSITORY_FILTEREDFILELIST id and filelist type X-Git-Tag: 0.7.0~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3b73a25756023d533c630319be9930186f05db1;p=thirdparty%2Flibsolv.git Add REPOSITORY_FILTEREDFILELIST id and filelist type REPOSITORY_FILTEREDFILELIST is used to mark that the filelist in the repodata is filtered with some filter. The commit also adds a filelisttype element to the repodata and sets it to filtered if REPOSITORY_FILTEREDFILELIST is set. It also sets the filelisttype to extension if the repodata has a filelist and was generated by extending solvables. We'll use the filelisttype later to decide if we should use the filtered filelist when searching for files. --- diff --git a/ext/repo_rpmmd.c b/ext/repo_rpmmd.c index 6c05281d..d6398561 100644 --- a/ext/repo_rpmmd.c +++ b/ext/repo_rpmmd.c @@ -1144,6 +1144,22 @@ repo_add_rpmmd(Repo *repo, FILE *fp, const char *language, int flags) repodata_free_dircache(data); queue_free(&pd.diskusageq); + if ((flags & REPO_EXTEND_SOLVABLES) != 0) + { + /* is this a filelist extension? */ + if (repodata_has_keyname(data, SOLVABLE_FILELIST)) + repodata_set_filelisttype(data, REPODATA_FILELIST_EXTENSION); + } + else + { + /* is this a primary with a filtered filelist? */ + if (data->end > data->start) + { + repodata_set_filelisttype(data, REPODATA_FILELIST_FILTERED); + repodata_set_void(data, SOLVID_META, REPOSITORY_FILTEREDFILELIST); + } + } + if (!(flags & REPO_NO_INTERNALIZE)) repodata_internalize(data); POOL_DEBUG(SOLV_DEBUG_STATS, "repo_add_rpmmd took %d ms\n", solv_timems(now)); diff --git a/ext/repo_susetags.c b/ext/repo_susetags.c index 52d5e5e9..6d03d231 100644 --- a/ext/repo_susetags.c +++ b/ext/repo_susetags.c @@ -1062,6 +1062,23 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int solv_free(joinhash); repodata_free_dircache(data); + + if ((flags & REPO_EXTEND_SOLVABLES) != 0) + { + /* is this a filelist extension? */ + if (repodata_has_keyname(data, SOLVABLE_FILELIST)) + repodata_set_filelisttype(data, REPODATA_FILELIST_EXTENSION); + } + else + { + /* is this a primary with a filtered filelist? */ + if (data->end > data->start) + { + repodata_set_filelisttype(data, REPODATA_FILELIST_FILTERED); + repodata_set_void(data, SOLVID_META, REPOSITORY_FILTEREDFILELIST); + } + } + if (!(flags & REPO_NO_INTERNALIZE)) repodata_internalize(data); diff --git a/src/knownid.h b/src/knownid.h index 64cc6fc0..cacdaaa4 100644 --- a/src/knownid.h +++ b/src/knownid.h @@ -261,6 +261,7 @@ KNOWNID(PRODUCT_REGISTER_FLAVOR, "product:regflavor"), /* installed and availab KNOWNID(SOLVABLE_INSTALLSTATUS, "solvable:installstatus"), /* debian install status */ KNOWNID(SOLVABLE_PREREQ_IGNOREINST, "solvable:prereq_ignoreinst"), /* ignore these pre-requires for installed packages */ +KNOWNID(REPOSITORY_FILTEREDFILELIST, "repository:filteredfilelist"), /* filelist in repository is filtered */ KNOWNID(ID_NUM_INTERNAL, 0) diff --git a/src/libsolv.ver b/src/libsolv.ver index 5c7c02fd..f023c8c9 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -224,6 +224,7 @@ SOLV_1.0 { repodata_set_constant; repodata_set_constantid; repodata_set_deltalocation; + repodata_set_filelisttype; repodata_set_id; repodata_set_idarray; repodata_set_location; diff --git a/src/repo_solv.c b/src/repo_solv.c index 0cbd073a..d56b4e77 100644 --- a/src/repo_solv.c +++ b/src/repo_solv.c @@ -1327,6 +1327,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) { @@ -1334,7 +1345,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)); diff --git a/src/repodata.c b/src/repodata.c index 86639252..24e3f5a4 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -3570,6 +3570,7 @@ repodata_disable_paging(Repodata *data) } } +/* call the pool's loadcallback to load a stub repodata */ static void repodata_stub_loader(Repodata *data) { @@ -3642,6 +3643,7 @@ repodata_create_stubs(Repodata *data) Dataiterator di; Id xkeyname = 0; int i, cnt = 0; + int filelisttype = data->filelisttype; dataiterator_init(&di, pool, repo, SOLVID_META, REPOSITORY_EXTERNAL, 0, 0); while (dataiterator_step(&di)) @@ -3681,6 +3683,8 @@ repodata_create_stubs(Repodata *data) else { repodata_add_stubkey(sdata, xkeyname, di.kv.id); + if (xkeyname == SOLVABLE_FILELIST && filelisttype == REPODATA_FILELIST_FILTERED) + repodata_set_filelisttype(sdata, REPODATA_FILELIST_EXTENSION); xkeyname = 0; } } @@ -3692,6 +3696,12 @@ repodata_create_stubs(Repodata *data) return data; } +void +repodata_set_filelisttype(Repodata *data, int type) +{ + data->filelisttype = type; +} + unsigned int repodata_memused(Repodata *data) { diff --git a/src/repodata.h b/src/repodata.h index 2e02f66d..f377a31f 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -53,16 +53,23 @@ typedef struct _Repokey { struct dircache; #endif -typedef struct _Repodata { - Id repodataid; /* our id */ - struct _Repo *repo; /* back pointer to repo */ - +/* repodata states */ #define REPODATA_AVAILABLE 0 #define REPODATA_STUB 1 #define REPODATA_ERROR 2 #define REPODATA_STORE 3 #define REPODATA_LOADING 4 +/* repodata filelist types */ +/* note that FILELIST_FILTERED means that the data contains a filtered + * filelist *AND* that it is authoritative for all included solvables. */ +#define REPODATA_FILELIST_FILTERED 1 +#define REPODATA_FILELIST_EXTENSION 2 + +typedef struct _Repodata { + Id repodataid; /* our id */ + struct _Repo *repo; /* back pointer to repo */ + int state; /* available, stub or error */ void (*loadcallback)(struct _Repodata *); @@ -87,6 +94,8 @@ typedef struct _Repodata { FILE *fp; /* file pointer of solv file */ int error; /* corrupt solv file */ + int filelisttype; /* type of filelist */ + unsigned int schemadatalen; /* schema storage size */ Id *schematahash; /* unification helper */ @@ -203,9 +212,10 @@ void repodata_search(Repodata *data, Id solvid, Id keyname, int flags, int (*cal * if valid, NULL if not possible */ const char *repodata_stringify(Pool *pool, Repodata *data, Repokey *key, struct _KeyValue *kv, int flags); +/* filelist filter support */ +void repodata_set_filelisttype(Repodata *data, int filelisttype); int repodata_filelistfilter_matches(Repodata *data, const char *str); - /* lookup functions */ Id repodata_lookup_type(Repodata *data, Id solvid, Id keyname); Id repodata_lookup_id(Repodata *data, Id solvid, Id keyname);