From b46e133115833eba663c7d635b7ade1a65b9f57c Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Thu, 18 Jan 2018 13:22:36 +0100 Subject: [PATCH] Add pool_set_whatprovides function Set an entry in the whatprovides table. Also make the pool methods set_namespaceproviders and flush_namespaceproviders available in the bindings. --- bindings/solv.i | 10 +++++++ doc/gen/libsolv-bindings.3 | 34 +++++++++++++++++++++-- doc/gen/libsolv-pool.3 | 18 ++++++++++--- doc/libsolv-bindings.txt | 15 +++++++++++ doc/libsolv-pool.txt | 10 +++++++ examples/p5solv | 1 + src/libsolv.ver | 1 + src/pool.c | 55 ++++++++++++++++++++++++++++++++------ src/pool.h | 2 ++ 9 files changed, 133 insertions(+), 13 deletions(-) diff --git a/bindings/solv.i b/bindings/solv.i index 35466879..add97a23 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -1888,6 +1888,16 @@ typedef struct { return pool_queuetowhatprovides($self, &q); } + void set_namespaceproviders(DepId ns, DepId evr, bool value=1) { + Id dep = pool_rel2id($self, ns, evr, REL_NAMESPACE, 1); + pool_set_whatprovides($self, dep, value ? 2 : 1); + } + + void flush_namespaceproviders(DepId ns, DepId evr) { + pool_flush_namespaceproviders($self, ns, evr); + } + + %typemap(out) Queue whatmatchesdep Queue2Array(XSolvable *, 1, new_XSolvable(arg1, id)); %newobject whatmatchesdep; Queue whatmatchesdep(Id keyname, DepId dep, Id marker = -1) { diff --git a/doc/gen/libsolv-bindings.3 b/doc/gen/libsolv-bindings.3 index 9a844a4a..7ea859f1 100644 --- a/doc/gen/libsolv-bindings.3 +++ b/doc/gen/libsolv-bindings.3 @@ -2,12 +2,12 @@ .\" Title: Libsolv-Bindings .\" Author: [see the "Author" section] .\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 11/16/2017 +.\" Date: 01/18/2018 .\" Manual: LIBSOLV .\" Source: libsolv .\" Language: English .\" -.TH "LIBSOLV\-BINDINGS" "3" "11/16/2017" "libsolv" "LIBSOLV" +.TH "LIBSOLV\-BINDINGS" "3" "01/18/2018" "libsolv" "LIBSOLV" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -881,6 +881,36 @@ my \fI$offset\fR \fB=\fR \fI$pool\fR\fB\->towhatprovides(\e\fR\fI@ids\fR\fB)\fR; .RS 4 .\} .nf +\fBvoid set_namespaceproviders(DepId\fR \fIns\fR\fB, DepId\fR \fIevr\fR\fB, bool\fR \fIvalue\fR \fB= 1)\fR +\fI$pool\fR\fB\->set_namespaceproviders(\fR\fI$ns\fR\fB,\fR \fI$evr\fR\fB, 1)\fR; +\fIpool\fR\fB\&.set_namespaceproviders(\fR\fIns\fR\fB,\fR \fIevr\fR\fB,\fR \fITrue\fR\fB)\fR +\fIpool\fR\fB\&.set_namespaceproviders(\fR\fIns\fR\fB,\fR \fIevr\fR\fB,\fR \fItrue\fR\fB)\fR +.fi +.if n \{\ +.RE +.\} +.sp +Manually set an namespace provides entry in the whatprovides index\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fBvoid flush_namespaceproviders(DepId\fR \fIns\fR\fB, DepId\fR \fIevr\fR\fB)\fR +\fI$pool\fR\fB\->flush_namespaceproviders(\fR\fI$ns\fR\fB,\fR \fI$evr\fR\fB)\fR; +\fI$pool\fR\fB\&.flush_namespaceproviders(\fR\fIns\fR\fB,\fR \fIevr\fR\fB)\fR +\fI$pool\fR\fB\&.flush_namespaceproviders(\fR\fIns\fR\fB,\fR \fIevr\fR\fB)\fR +.fi +.if n \{\ +.RE +.\} +.sp +Flush the cache of all namespacprovudes matching the specified namespace dependency\&. You can use zero as a wildcard argument\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf \fBbool isknownarch(DepId\fR \fIid\fR\fB)\fR my \fI$bool\fR \fB=\fR \fI$pool\fR\fB\->isknownarch(\fR\fI$id\fR\fB)\fR; \fIbool\fR \fB=\fR \fIpool\fR\fB\&.isknownarch(\fR\fIid\fR\fB)\fR diff --git a/doc/gen/libsolv-pool.3 b/doc/gen/libsolv-pool.3 index d324f689..ffb8e56c 100644 --- a/doc/gen/libsolv-pool.3 +++ b/doc/gen/libsolv-pool.3 @@ -1,13 +1,13 @@ '\" t .\" Title: Libsolv-Pool .\" Author: [see the "Author" section] -.\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 09/04/2017 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 01/18/2018 .\" Manual: LIBSOLV .\" Source: libsolv .\" Language: English .\" -.TH "LIBSOLV\-POOL" "3" "09/04/2017" "libsolv" "LIBSOLV" +.TH "LIBSOLV\-POOL" "3" "01/18/2018" "libsolv" "LIBSOLV" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -956,6 +956,18 @@ Same as pool_addfileprovides, but the added Ids are returned in two Queues, \fIi .RS 4 .\} .nf +\fBvoid pool_set_whatprovides(\fR\fIpool\fR\fB, Id\fR \fIid\fR\fB, Id\fR \fIoffset\fR\fB)\fR; +.fi +.if n \{\ +.RE +.\} +.sp +Manually set an entry in the whatprovides index\&. You\(cqll never do this for package dependencies, as those entries are created by calling the pool_createwhatprovides() function\&. But this function is useful for namespace provides if you do not want to use a namespace callback to lazily set the provides\&. The offset argument is a offset in the whatprovides array, thus you can use \(lq1\(rq as a false value and \(lq2\(rq as true value\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf \fBvoid pool_flush_namespaceproviders(Pool *\fR\fIpool\fR\fB, Id\fR \fIns\fR\fB, Id\fR \fIevr\fR\fB)\fR; .fi .if n \{\ diff --git a/doc/libsolv-bindings.txt b/doc/libsolv-bindings.txt index c204502f..0d336cec 100644 --- a/doc/libsolv-bindings.txt +++ b/doc/libsolv-bindings.txt @@ -504,6 +504,21 @@ string. See the Dataiterator class for the allowed flags. create solver jobs working on a specific set of packages. See the Solver class for more information. + void set_namespaceproviders(DepId ns, DepId evr, bool value = 1) + $pool->set_namespaceproviders($ns, $evr, 1); + pool.set_namespaceproviders(ns, evr, True) + pool.set_namespaceproviders(ns, evr, true) + +Manually set an namespace provides entry in the whatprovides index. + + void flush_namespaceproviders(DepId ns, DepId evr) + $pool->flush_namespaceproviders($ns, $evr); + $pool.flush_namespaceproviders(ns, evr) + $pool.flush_namespaceproviders(ns, evr) + +Flush the cache of all namespacprovudes matching the specified namespace +dependency. You can use zero as a wildcard argument. + bool isknownarch(DepId id) my $bool = $pool->isknownarch($id); bool = pool.isknownarch(id) diff --git a/doc/libsolv-pool.txt b/doc/libsolv-pool.txt index cc7707ad..60147207 100644 --- a/doc/libsolv-pool.txt +++ b/doc/libsolv-pool.txt @@ -606,6 +606,16 @@ packages, _idqinst_ for the latter one. This information can be stored in the meta section of the repositories to speed up the next time the repository is loaded and addfileprovides is called + void pool_set_whatprovides(pool, Id id, Id offset); + +Manually set an entry in the whatprovides index. You'll never do this for +package dependencies, as those entries are created by calling the +pool_createwhatprovides() function. But this function is useful for +namespace provides if you do not want to use a namespace callback to +lazily set the provides. The offset argument is a offset in the +whatprovides array, thus you can use ``1'' as a false value and ``2'' +as true value. + void pool_flush_namespaceproviders(Pool *pool, Id ns, Id evr); Clear the cache of the providers for namespace dependencies matching diff --git a/examples/p5solv b/examples/p5solv index 45debb1b..9e90670b 100755 --- a/examples/p5solv +++ b/examples/p5solv @@ -566,6 +566,7 @@ die("unknown command '$cmd'\n") unless defined $cmdactionmap{$cmd}; $pool->addfileprovides(); $pool->createwhatprovides(); +$pool->set_namespaceproviders($solv::NAMESPACE_LANGUAGE, $pool->Dep('de'), 1); my @jobs; for my $arg (@ARGV) { diff --git a/src/libsolv.ver b/src/libsolv.ver index 04b09d50..c124854f 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -101,6 +101,7 @@ SOLV_1.0 { pool_set_installed; pool_set_languages; pool_set_rootdir; + pool_set_whatprovides; pool_setarch; pool_setarchpolicy; pool_setdebugcallback; diff --git a/src/pool.c b/src/pool.c index 6ca15823..1d9eadc0 100644 --- a/src/pool.c +++ b/src/pool.c @@ -1410,7 +1410,8 @@ pool_flush_namespaceproviders(Pool *pool, Id ns, Id evr) continue; if (evr && rd->evr != evr) continue; - pool->whatprovides_rel[d] = 0; + if (pool->whatprovides_rel[d]) + pool_set_whatprovides(pool, MAKERELDEP(d), 0); } } @@ -1862,24 +1863,66 @@ pool_lookup_deltalocation(Pool *pool, Id entry, unsigned int *medianrp) return loc; } +void +pool_set_whatprovides(Pool *pool, Id id, Id providers) +{ + int d, nrels = pool->nrels; + Reldep *rd; + Map m; + + /* set new entry */ + if (ISRELDEP(id)) + { + d = GETRELID(id); + pool->whatprovides_rel[d] = providers; + d++; + } + else + { + pool->whatprovides[id] = providers; + if (id < pool->whatprovidesauxoff) + pool->whatprovidesaux[id] = 0; /* sorry */ + d = 1; + } + if (!pool->whatprovides_rel) + return; + /* clear cache of all rels that use it */ + map_init(&m, 0); + for (rd = pool->rels + d; d < nrels; d++, rd++) + { + if (rd->name == id || rd->evr == id || + (m.size && ISRELDEP(rd->name) && MAPTST(&m, GETRELID(rd->name))) || + (m.size && ISRELDEP(rd->evr) && MAPTST(&m, GETRELID(rd->evr)))) + { + pool->whatprovides_rel[d] = 0; /* clear cache */ + if (!m.size) + map_init(&m, nrels); + MAPSET(&m, d); + } + } + map_free(&m); +} + static void add_new_provider(Pool *pool, Id id, Id p) { Queue q; Id *pp; + /* find whatprovides entry */ while (ISRELDEP(id)) { Reldep *rd = GETRELDEP(pool, id); id = rd->name; } + /* add new provider to existing list keeping it sorted */ queue_init(&q); for (pp = pool->whatprovidesdata + pool->whatprovides[id]; *pp; pp++) { if (*pp == p) { - queue_free(&q); + queue_free(&q); /* already have it */ return; } if (*pp > p) @@ -1891,9 +1934,7 @@ add_new_provider(Pool *pool, Id id, Id p) } if (p) queue_push(&q, p); - pool->whatprovides[id] = pool_queuetowhatprovides(pool, &q); - if (id < pool->whatprovidesauxoff) - pool->whatprovidesaux[id] = 0; /* sorry */ + pool_set_whatprovides(pool, id, pool_queuetowhatprovides(pool, &q)); queue_free(&q); } @@ -1920,9 +1961,7 @@ pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts) continue; s->provides = repo_addid_dep(s->repo, s->provides, id, SOLVABLE_FILEMARKER); if (pool->whatprovides) - add_new_provider(pool, fn, p); - if (pool->whatprovides_rel) - pool->whatprovides_rel[GETRELID(id)] = 0; /* clear cache */ + add_new_provider(pool, id, p); s = pool->solvables + q; if (!s->repo) continue; diff --git a/src/pool.h b/src/pool.h index f6a54934..f6573af3 100644 --- a/src/pool.h +++ b/src/pool.h @@ -344,6 +344,8 @@ static inline Id *pool_whatprovides_ptr(Pool *pool, Id d) void pool_whatmatchesdep(Pool *pool, Id keyname, Id dep, Queue *q, int marker); void pool_whatcontainsdep(Pool *pool, Id keyname, Id dep, Queue *q, int marker); +void pool_set_whatprovides(Pool *pool, Id id, Id providers); + /* search the pool. the following filters are available: * p - search just this solvable -- 2.47.2