Mailinglist Archive: zypp-commit (606 mails)

< Previous Next >
[zypp-commit] r9392 - in /trunk/sat-solver/src: pool.h solvable.c
  • From: mlschroe@xxxxxxxxxxxxxxxx
  • Date: Fri, 04 Apr 2008 20:35:12 -0000
  • Message-id: <20080404203512.A3F17342BF@xxxxxxxxxxxxxxxx>
Author: mlschroe
Date: Fri Apr 4 22:35:12 2008
New Revision: 9392

URL: http://svn.opensuse.org/viewcvs/zypp?rev=9392&view=rev
Log:
- add solvable_trivial_installable
(probably not the final interface, as we should work with a solver result)

Modified:
trunk/sat-solver/src/pool.h
trunk/sat-solver/src/solvable.c

Modified: trunk/sat-solver/src/pool.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.h?rev=9392&r1=9391&r2=9392&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.h (original)
+++ trunk/sat-solver/src/pool.h Fri Apr 4 22:35:12 2008
@@ -177,6 +177,7 @@
const unsigned char *solvable_lookup_bin_checksum(Solvable *s, Id keyname, Id
*typep);
const char *solvable_lookup_checksum(Solvable *s, Id keyname, Id *typep);

+int solvable_trivial_installable(Solvable *s, struct _Repo *installed);




Modified: trunk/sat-solver/src/solvable.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solvable.c?rev=9392&r1=9391&r2=9392&view=diff
==============================================================================
--- trunk/sat-solver/src/solvable.c (original)
+++ trunk/sat-solver/src/solvable.c Fri Apr 4 22:35:12 2008
@@ -358,3 +358,111 @@
}
return loc;
}
+
+
+static inline Id dep2name(Pool *pool, Id dep)
+{
+ while (ISRELDEP(dep))
+ {
+ Reldep *rd = rd = GETRELDEP(pool, dep);
+ dep = rd->name;
+ }
+ return dep;
+}
+
+static inline int providedbyinstalled(Pool *pool, Repo *installed, Id dep)
+{
+ Id p, *pp;
+ Solvable *s;
+ FOR_PROVIDES(p, pp, dep)
+ {
+ if (p == SYSTEMSOLVABLE)
+ return -1;
+ s = pool->solvables + p;
+ if (s->repo && s->repo == installed)
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * returns:
+ * 1: solvable is installable without any other package changes
+ * 0: solvable is not installable
+ * -1: solvable is installable, but doesn't constrain any installed packages
+ */
+int
+solvable_trivial_installable(Solvable *s, Repo *installed)
+{
+ Pool *pool = s->repo->pool;
+ Solvable *s2;
+ Id p, *pp, *dp;
+ Id *reqp, req;
+ Id *conp, con;
+ Id *obsp, obs;
+ int r, interesting = 0;
+
+ if (s->requires)
+ {
+ reqp = s->repo->idarraydata + s->requires;
+ while ((req = *reqp++) != 0)
+ {
+ if (req == SOLVABLE_PREREQMARKER)
+ continue;
+ r = providedbyinstalled(pool, installed, req);
+ if (!r)
+ return 0;
+ if (r > 0)
+ interesting = 1;
+ }
+ }
+ if (!installed)
+ return 1;
+ if (s->conflicts)
+ {
+ conp = s->repo->idarraydata + s->conflicts;
+ while ((con = *conp++) != 0)
+ {
+ if (providedbyinstalled(pool, installed, con))
+ return 0;
+ if (!interesting && ISRELDEP(con))
+ {
+ con = dep2name(pool, con);
+ if (providedbyinstalled(pool, installed, con))
+ interesting = 1;
+ }
+ }
+ }
+ if (s->obsoletes && s->repo != installed)
+ {
+ obsp = s->repo->idarraydata + s->obsoletes;
+ while ((obs = *conp++) != 0)
+ {
+ if (providedbyinstalled(pool, installed, obs))
+ return 0;
+ }
+ }
+ if (s->repo != installed)
+ {
+ FOR_PROVIDES(p, pp, s->name)
+ {
+ s2 = pool->solvables + p;
+ if (s2->repo == installed && s2->name == s->name)
+ return 0;
+ }
+ }
+ FOR_REPO_SOLVABLES(installed, p, s2)
+ {
+ if (!s2->conflicts)
+ continue;
+ conp = s->repo->idarraydata + s->conflicts;
+ while ((con = *conp++) != 0)
+ {
+ dp = pool_whatprovides(pool, con);
+ for (; *dp; dp++)
+ if (*dp == s - pool->solvables)
+ return 0;
+ }
+ }
+ return interesting ? 1 : -1;
+}

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages