]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Add pool_set_whatprovides function
authorMichael Schroeder <mls@suse.de>
Thu, 18 Jan 2018 12:22:36 +0000 (13:22 +0100)
committerMichael Schroeder <mls@suse.de>
Thu, 18 Jan 2018 12:22:36 +0000 (13:22 +0100)
Set an entry in the whatprovides table. Also make the pool methods
set_namespaceproviders and flush_namespaceproviders available in
the bindings.

bindings/solv.i
doc/gen/libsolv-bindings.3
doc/gen/libsolv-pool.3
doc/libsolv-bindings.txt
doc/libsolv-pool.txt
examples/p5solv
src/libsolv.ver
src/pool.c
src/pool.h

index 35466879056b8464031c780622c2ddd7e130b815..add97a23b2bf19150b2d3cd18f793f8e21987fc5 100644 (file)
@@ -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) {
index 9a844a4a8491b37cedf5a2a3f778d661650155a4..7ea859f1ca6a88c7b93a341f4937669a8ea952b2 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: Libsolv-Bindings
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\"      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
index d324f6892eea80293f204400565c4bb0a416f2c2..ffb8e56cd00f8353662d94459e2a9eb824c4725d 100644 (file)
@@ -1,13 +1,13 @@
 '\" t
 .\"     Title: Libsolv-Pool
 .\"    Author: [see the "Author" section]
-.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\"      Date: 09/04/2017
+.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
+.\"      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 \{\
index c204502f1e3875b3dc88ac61ab3b76e07b263577..0d336cec7af590ed89bf132540924198afc89baf 100644 (file)
@@ -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)
index cc7707ad1b7260fd144f10340d4a3eccbcc697b9..60147207b7ca7c7f826244adcec137b9bb3c2e35 100644 (file)
@@ -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
index 45debb1ba17588e43e955856696c54313682c0a7..9e90670bf1a30eb919a957f267a547e480c05119 100755 (executable)
@@ -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) {
index 04b09d505024e34d141361b1ae0d0dd432b67024..c124854fb32a8a186be87eab83542999849397a5 100644 (file)
@@ -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;
index 6ca15823129cf6b4103f7dbb74d7e92d54ae7f99..1d9eadc03cb15c83ddcba2283d83b1cde3888926 100644 (file)
@@ -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;
index f6a5493474a7c4f145f05bba7eefc1236fdec939..f6573af38fa01119ca85241abc9a74ea01985f16 100644 (file)
@@ -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