Zypp Commits
Threads by month
- ----- 2024 -----
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
May 2009
- 4 participants
- 79 discussions
[zypp-commit] <libzypp> SuSE-Code-11-Branch : Fix lost housekeeping data in modifyRepo (bnc #503207)
by Michael Andres 20 May '09
by Michael Andres 20 May '09
20 May '09
ref: refs/heads/SuSE-Code-11-Branch
commit 696e32924d086bc2993befc64117493fb6f4f985
Author: Michael Andres <ma(a)suse.de>
Date: Wed May 20 14:11:48 2009 +0200
Fix lost housekeeping data in modifyRepo (bnc #503207)
---
zypp/RepoManager.cc | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc
index f926001..55c624b 100644
--- a/zypp/RepoManager.cc
+++ b/zypp/RepoManager.cc
@@ -1511,19 +1511,16 @@ namespace zypp
////////////////////////////////////////////////////////////////////////////
void RepoManager::modifyRepository( const std::string &alias,
- const RepoInfo & newinfo,
+ const RepoInfo & newinfo_r,
const ProgressData::ReceiverFnc & progressrcv )
{
RepoInfo toedit = getRepositoryInfo(alias);
+ RepoInfo newinfo( newinfo_r ); // need writable copy to upadte housekeeping data
// check if the new alias already exists when renaming the repo
- if (alias != newinfo.alias())
+ if ( alias != newinfo.alias() && hasRepo( newinfo.alias() ) )
{
- for_( it, repoBegin(), repoEnd() )
- {
- if ( newinfo.alias() == (*it).alias() )
- ZYPP_THROW(RepoAlreadyExistsException(newinfo));
- }
+ ZYPP_THROW(RepoAlreadyExistsException(newinfo));
}
if (toedit.filepath().empty())
@@ -1561,6 +1558,7 @@ namespace zypp
newinfo.dumpAsIniOn(file);
}
+ newinfo.setFilepath(toedit.filepath());
_pimpl->repos.erase(toedit);
_pimpl->repos.insert(newinfo);
HistoryLog(_pimpl->options.rootDir).modifyRepository(toedit, newinfo);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> SuSE-Code-11-Branch : - add changes, bump version
by Michael Schroeder 20 May '09
by Michael Schroeder 20 May '09
20 May '09
ref: refs/heads/SuSE-Code-11-Branch
commit 85cf17004f8d22fd8307276219436b71b0d99ec7
Author: Michael Schroeder <mls(a)suse.de>
Date: Wed May 20 12:34:16 2009 +0200
- add changes, bump version
---
VERSION.cmake | 4 ++--
package/libsatsolver.changes | 8 ++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/VERSION.cmake b/VERSION.cmake
index b08bdc3..ac6d668 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -46,6 +46,6 @@
SET(LIBSATSOLVER_MAJOR "0")
SET(LIBSATSOLVER_MINOR "13")
-SET(LIBSATSOLVER_PATCH "6")
+SET(LIBSATSOLVER_PATCH "7")
-# last released 0.13.6
+# last released 0.13.7
diff --git a/package/libsatsolver.changes b/package/libsatsolver.changes
index eef07d8..b84cfce 100644
--- a/package/libsatsolver.changes
+++ b/package/libsatsolver.changes
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Wed May 20 12:32:16 CEST 2009 - mls(a)suse.de
+
+- add workaround for multiversion supplements (bnc#501088)
+- fix systemlevel == 1 conflict handling
+- fix name/evr access (bnc#490033)
+- 0.13.7
+
+-------------------------------------------------------------------
Thu Mar 5 14:31:14 CET 2009 - mls(a)suse.de
- fix repodata_merge_attrs() function
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> SuSE-Code-11-Branch : - add workaround for multversion supplements (bnc#5018088)
by Michael Schroeder 20 May '09
by Michael Schroeder 20 May '09
20 May '09
ref: refs/heads/SuSE-Code-11-Branch
commit 1e67cac4a49c1fc0385a57bf43bd162b61f565fb
Author: Michael Schroeder <mls(a)suse.de>
Date: Wed May 20 12:31:29 2009 +0200
- add workaround for multversion supplements (bnc#5018088)
---
src/solver.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/solver.c b/src/solver.c
index 65da12c..97d1879 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -2980,6 +2980,29 @@ run_solver(Solver *solv, int disablerules, int doweak)
}
}
+ /* multiversion doesn't mix well with supplements.
+ * filter supplemented packages where we already decided
+ * to install a different version (see bnc#501088) */
+ if (dqs.count && solv->noobsoletes.size)
+ {
+ for (i = j = 0; i < dqs.count; i++)
+ {
+ p = dqs.elements[i];
+ if (MAPTST(&solv->noobsoletes, p))
+ {
+ Id p2, pp2;
+ s = pool->solvables + p;
+ FOR_PROVIDES(p2, pp2, s->name)
+ if (solv->decisionmap[p2] > 0 && pool->solvables[p2].name == s->name)
+ break;
+ if (p2)
+ continue; /* ignore this package */
+ }
+ dqs.elements[j++] = p;
+ }
+ dqs.count = j;
+ }
+
/* make dq contain both recommended and supplemented pkgs */
if (dqs.count)
{
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> master : - oops, should use 'commit -a'...
by Michael Schroeder 15 May '09
by Michael Schroeder 15 May '09
15 May '09
ref: refs/heads/master
commit 9abdbc3c6ee67a0852425c3d8c593a8bebf1b399
Author: Michael Schroeder <mls(a)suse.de>
Date: Fri May 15 18:44:13 2009 +0200
- oops, should use 'commit -a'...
---
applayer/CMakeLists.txt | 4 +-
applayer/decision.c | 2 +-
applayer/decision.h | 2 +-
applayer/job.c | 2 +-
applayer/job.h | 2 +-
applayer/problem.c | 14 ++++---
applayer/problem.h | 10 ++--
applayer/request.c | 44 ++++++++++----------
applayer/request.h | 34 +++++++-------
applayer/solution.c | 2 +-
applayer/solution.h | 2 +-
bindings/job.i | 4 +-
bindings/perl/tests/solver.pl | 4 +-
bindings/pool.i | 12 +++---
bindings/problem.i | 10 ++--
bindings/python/tests/pool.py | 2 +-
bindings/python/tests/solvable.py | 6 +-
bindings/request.i | 78 +++++++++++++++++-----------------
bindings/ruby/tests/CMakeLists.txt | 2 +-
bindings/ruby/tests/decisions.rb | 8 ++--
bindings/ruby/tests/installable.rb | 6 +-
bindings/ruby/tests/patch_updates.rb | 6 +-
bindings/ruby/tests/pool.rb | 2 +-
bindings/ruby/tests/problems.rb | 72 ++++++++++++++++----------------
bindings/ruby/tests/reasons.rb | 42 +++++++++---------
bindings/ruby/tests/request.rb | 28 ++++++------
bindings/ruby/tests/solutions.rb | 10 ++--
bindings/ruby/tests/solvable.rb | 6 +-
bindings/ruby/tests/solver.rb | 8 ++--
bindings/ruby/tests/updates.rb | 6 +-
bindings/rule.i | 2 +-
bindings/satsolver.i | 4 +-
bindings/solver.i | 40 +++++++++---------
33 files changed, 239 insertions(+), 237 deletions(-)
diff --git a/applayer/CMakeLists.txt b/applayer/CMakeLists.txt
index 3e2f6cb..ac6bfcb 100644
--- a/applayer/CMakeLists.txt
+++ b/applayer/CMakeLists.txt
@@ -5,12 +5,12 @@
ADD_SUBDIRECTORY(tests)
SET(libappsatsolver_SRCS job.c applayer.c covenant.c decision.c dependency.c
- kinds.c problem.c relation.c solution.c transaction.c xrepokey.c xsolvable.c)
+ kinds.c problem.c relation.c solution.c request.c xrepokey.c xsolvable.c)
ADD_LIBRARY(appsatsolver STATIC ${libappsatsolver_SRCS})
SET(libappsatsolver_HEADERS job.h applayer.h covenant.h decision.h dependency.h
- kinds.h problem.h relation.h solution.h transaction.h xrepokey.h xsolvable.h)
+ kinds.h problem.h relation.h solution.h request.h xrepokey.h xsolvable.h)
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Werror" )
diff --git a/applayer/decision.c b/applayer/decision.c
index 8b6511f..413ae78 100644
--- a/applayer/decision.c
+++ b/applayer/decision.c
@@ -10,7 +10,7 @@
*
* A successful solver result.
*
- * Set of 'job items' needed to solve the Transaction.
+ * Set of 'job items' needed to solve the Request.
*
*/
diff --git a/applayer/decision.h b/applayer/decision.h
index 76fa550..6754863 100644
--- a/applayer/decision.h
+++ b/applayer/decision.h
@@ -13,7 +13,7 @@
*
* A successful solver result.
*
- * Set of 'job items' needed to solve the Transaction.
+ * Set of 'job items' needed to solve the Request.
*
*/
diff --git a/applayer/job.c b/applayer/job.c
index c52d08f..2590bd0 100644
--- a/applayer/job.c
+++ b/applayer/job.c
@@ -8,7 +8,7 @@
/*
* Job
*
- * A single 'job' item of a Transaction
+ * A single 'job' item of a Request
*
*/
diff --git a/applayer/job.h b/applayer/job.h
index 9d0fc03..bc7e5e7 100644
--- a/applayer/job.h
+++ b/applayer/job.h
@@ -8,7 +8,7 @@
/*
* Job
*
- * A single 'job' item of a Transaction
+ * A single 'job' item of a Request
*
*/
diff --git a/applayer/problem.c b/applayer/problem.c
index 16aa39a..9ab2434 100644
--- a/applayer/problem.c
+++ b/applayer/problem.c
@@ -10,7 +10,7 @@
*
* An unsuccessful solver result
*
- * If a transaction is not solvable, one or more
+ * If a request is not solvable, one or more
* Problems will be reported by the Solver.
*
*/
@@ -23,13 +23,13 @@
Problem *
-problem_new( Solver *s, Transaction *t, Id id )
+problem_new( Solver *s, Request *t, Id id )
{
Id prule;
Problem *p = (Problem *)malloc( sizeof( Problem ));
p->solver = s;
- p->transaction = t;
+ p->request = t;
p->id = id;
prule = solver_findproblemrule( s, id );
p->reason = solver_problemruleinfo( s, &(t->queue), prule, &(p->relation), &(p->source), &(p->target) );
@@ -44,7 +44,7 @@ problem_free( Problem *p )
void
-solver_problems_iterate( Solver *solver, Transaction *t, int (*callback)(const Problem *p, void *user_data), void *user_data )
+solver_problems_iterate( Solver *solver, Request *t, int (*callback)(const Problem *p, void *user_data), void *user_data )
{
Id problem = 0;
if (!callback)
@@ -84,9 +84,9 @@ problem_solutions_iterate( Problem *problem, int (*callback)( const Solution *s,
{
/* job, rp is index into job queue */
- what = problem->transaction->queue.elements[rp];
+ what = solver->job.elements[rp];
- switch (problem->transaction->queue.elements[rp - 1])
+ switch (solver->job.elements[rp - 1])
{
case SOLVER_INSTALL_SOLVABLE:
s1 = what;
@@ -141,6 +141,8 @@ problem_solutions_iterate( Problem *problem, int (*callback)( const Solution *s,
{
s1 = p;
s2 = rp;
+ if (p < 0)
+ p = rp;
/* policy, replace p with rp */
Solvable *sp = pool->solvables + p;
Solvable *sr = rp ? pool->solvables + rp : 0;
diff --git a/applayer/problem.h b/applayer/problem.h
index 42d0d78..bf1a94f 100644
--- a/applayer/problem.h
+++ b/applayer/problem.h
@@ -13,19 +13,19 @@
*
* An unsuccessful solver result
*
- * If a transaction is not solvable, one or more
+ * If a request is not solvable, one or more
* Problems will be reported by the Solver.
*
*/
#include "solver.h"
-#include "transaction.h"
+#include "request.h"
#include "solution.h"
typedef struct _Problem {
Solver *solver;
- Transaction *transaction;
+ Request *request;
Id id; /* [PRIVATE] problem id */
SolverProbleminfo reason;
Id source; /* solvable id */
@@ -33,10 +33,10 @@ typedef struct _Problem {
Id target; /* solvable id */
} Problem;
-Problem *problem_new( Solver *s, Transaction *t, Id id );
+Problem *problem_new( Solver *s, Request *t, Id id );
void problem_free( Problem *p );
-void solver_problems_iterate( Solver *solver, Transaction *t, int (*callback)( const Problem *p, void *user_data ), void *user_data );
+void solver_problems_iterate( Solver *solver, Request *t, int (*callback)( const Problem *p, void *user_data ), void *user_data );
void problem_solutions_iterate( Problem *p, int (*callback)( const Solution *s, void *user_data ), void *user_data );
#endif /* SATSOLVER_PROBLEM_H */
diff --git a/applayer/request.c b/applayer/request.c
index a2bf6b0..b82206f 100644
--- a/applayer/request.c
+++ b/applayer/request.c
@@ -6,7 +6,7 @@
*/
/************************************************
- * Transaction
+ * Request
*
* A set of Actions to be solved by the Solver
*
@@ -14,20 +14,20 @@
#include <stdlib.h>
-#include "transaction.h"
+#include "request.h"
-Transaction *
-transaction_new( Pool *pool )
+Request *
+request_new( Pool *pool )
{
- Transaction *t = (Transaction *)malloc( sizeof( Transaction ));
+ Request *t = (Request *)malloc( sizeof( Request ));
t->pool = pool;
queue_init( &(t->queue) );
return t;
}
void
-transaction_free( Transaction *t )
+request_free( Request *t )
{
queue_free( &(t->queue) );
free( t );
@@ -35,71 +35,71 @@ transaction_free( Transaction *t )
/*
- * number of actions in transaction
+ * number of actions in request
* every two queue elements make one action
*/
int
-transaction_size( Transaction *t )
+request_size( Request *t )
{
return t->queue.count >> 1;
}
void
-transaction_install_xsolvable( Transaction *t, XSolvable *xs )
+request_install_xsolvable( Request *t, XSolvable *xs )
{
- queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE );
+ queue_push( &(t->queue), SOLVER_INSTALL|SOLVER_SOLVABLE );
/* FIXME: check: s->repo->pool == $self->pool */
queue_push( &(t->queue), xs->id );
}
void
-transaction_remove_xsolvable( Transaction *t, XSolvable *xs )
+request_remove_xsolvable( Request *t, XSolvable *xs )
{
- queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE );
+ queue_push( &(t->queue), SOLVER_ERASE|SOLVER_SOLVABLE );
/* FIXME: check: s->repo->pool == $self->pool */
queue_push( &(t->queue), xs->id );
}
void
-transaction_install_name( Transaction *t, const char *name )
+request_install_name( Request *t, const char *name )
{
- queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_NAME );
+ queue_push( &(t->queue), SOLVER_INSTALL|SOLVER_SOLVABLE_NAME );
queue_push( &(t->queue), str2id( t->pool, name, 1 ));
}
void
-transaction_remove_name( Transaction *t, const char *name )
+request_remove_name( Request *t, const char *name )
{
- queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_NAME );
+ queue_push( &(t->queue), SOLVER_ERASE|SOLVER_SOLVABLE_NAME );
queue_push( &(t->queue), str2id( t->pool, name, 1 ));
}
void
-transaction_install_relation( Transaction *t, const Relation *rel )
+request_install_relation( Request *t, const Relation *rel )
{
- queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_PROVIDES );
+ queue_push( &(t->queue), SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES );
/* FIXME: check: rel->pool == $self->pool */
queue_push( &(t->queue), rel->id );
}
void
-transaction_remove_relation( Transaction *t, const Relation *rel )
+request_remove_relation( Request *t, const Relation *rel )
{
- queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_PROVIDES );
+ queue_push( &(t->queue), SOLVER_ERASE|SOLVER_SOLVABLE_PROVIDES );
/* FIXME: check: rel->pool == $self->pool */
queue_push( &(t->queue), rel->id );
}
Job *
-transaction_job_get( Transaction *t, int i )
+request_job_get( Request *t, int i )
{
int size, cmd;
Id id;
@@ -114,7 +114,7 @@ transaction_job_get( Transaction *t, int i )
void
-transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j))
+request_jobs_iterate( Request *t, int (*callback)( const Job *j))
{
int i;
for (i = 0; i < t->queue.count-1; )
diff --git a/applayer/request.h b/applayer/request.h
index 0a30642..777221e 100644
--- a/applayer/request.h
+++ b/applayer/request.h
@@ -6,36 +6,36 @@
*/
/************************************************
- * Transaction
+ * Request
*
* A set of Actions to be solved by the Solver
*
*/
-#ifndef SATSOLVER_TRANSACTION_H
-#define SATSOLVER_TRANSACTION_H
+#ifndef SATSOLVER_REQUEST_H
+#define SATSOLVER_REQUEST_H
#include "job.h"
-typedef struct _Transaction {
+typedef struct _Request {
Pool *pool;
Queue queue;
-} Transaction;
+} Request;
-Transaction *transaction_new( Pool *pool );
-void transaction_free( Transaction *t );
+Request *request_new( Pool *pool );
+void request_free( Request *t );
-void transaction_install_xsolvable( Transaction *t, XSolvable *xs );
-void transaction_remove_xsolvable( Transaction *t, XSolvable *xs );
-void transaction_install_name( Transaction *t, const char *name );
-void transaction_remove_name( Transaction *t, const char *name );
-void transaction_install_relation( Transaction *t, const Relation *rel );
-void transaction_remove_relation( Transaction *t, const Relation *rel );
-int transaction_size( Transaction *t );
-Job *transaction_job_get( Transaction *t, int i );
+void request_install_xsolvable( Request *t, XSolvable *xs );
+void request_remove_xsolvable( Request *t, XSolvable *xs );
+void request_install_name( Request *t, const char *name );
+void request_remove_name( Request *t, const char *name );
+void request_install_relation( Request *t, const Relation *rel );
+void request_remove_relation( Request *t, const Relation *rel );
+int request_size( Request *t );
+Job *request_job_get( Request *t, int i );
-void transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j));
+void request_jobs_iterate( Request *t, int (*callback)( const Job *j));
-#endif /* SATSOLVER_TRANSACTION_H */
+#endif /* SATSOLVER_REQUEST_H */
diff --git a/applayer/solution.c b/applayer/solution.c
index 2547637..7ab9cda 100644
--- a/applayer/solution.c
+++ b/applayer/solution.c
@@ -11,7 +11,7 @@
* A possible solution to a Problem.
*
* For each reported Problem, the Solver might generate
- * one or more Solutions to make the Transaction solvable.
+ * one or more Solutions to make the Request solvable.
*
*/
diff --git a/applayer/solution.h b/applayer/solution.h
index c0e7979..0a6d978 100644
--- a/applayer/solution.h
+++ b/applayer/solution.h
@@ -14,7 +14,7 @@
* A possible solution to a Problem.
*
* For each reported Problem, the Solver might generate
- * one or more Solutions to make the Transaction solvable.
+ * one or more Solutions to make the Request solvable.
*
*/
diff --git a/bindings/job.i b/bindings/job.i
index 7e1907a..79868f3 100644
--- a/bindings/job.i
+++ b/bindings/job.i
@@ -1,10 +1,10 @@
/*
* Document-class: Job
- * A job is a single 'work item' of a transaction
+ * A job is a single 'work item' of a request
*
* === Constructor
* There is no constructor defined for Job. Jobs are created by accessing
- * a Transaction
+ * a Request
*
*/
diff --git a/bindings/perl/tests/solver.pl b/bindings/perl/tests/solver.pl
index b16786f..6ccfd80 100755
--- a/bindings/perl/tests/solver.pl
+++ b/bindings/perl/tests/solver.pl
@@ -22,8 +22,8 @@ my $solver = $pool->create_solver();
# Create dependencies to provides table
$pool->prepare();
-# Create Transactions
-my $job = $pool->create_transaction();
+# Create Request
+my $job = $pool->create_request();
# Push jobs on Queue
my $pat = $pool->find("pattern:default") || die;
diff --git a/bindings/pool.i b/bindings/pool.i
index 07c52e5..dbf1121 100644
--- a/bindings/pool.i
+++ b/bindings/pool.i
@@ -752,18 +752,18 @@ typedef struct _Pool {} Pool;
#endif
/**************************
- * Transaction management
+ * Request management
*/
- %newobject create_transaction;
+ %newobject create_request;
/*
- * Create an empty Transaction.
+ * Create an empty Request
*
- * Equivalent to: Transaction.new
+ * Equivalent to: Request.new
*
*/
- Transaction *create_transaction()
- { return transaction_new( $self ); }
+ Request *create_request()
+ { return request_new( $self ); }
/**************************
* Solver management
diff --git a/bindings/problem.i b/bindings/problem.i
index f13a6ff..46b7a55 100644
--- a/bindings/problem.i
+++ b/bindings/problem.i
@@ -1,7 +1,7 @@
/*
* Document-class: Problem
*
- * If solving a Transaction is unsucccessful (+Solver+.+solve+ returning +false+), the Solver provides
+ * If solving a Request is unsucccessful (+Solver+.+solve+ returning +false+), the Solver provides
* information on possible reason and how to fix them.
*
* The Problem class represents such a reason and provides solutions.
@@ -38,7 +38,7 @@ typedef struct _Problem {} Problem;
%extend Problem {
/* The problem is caused by an update rule (i.e. 'better' Solvable available) */
%constant int SOLVER_PROBLEM_UPDATE_RULE = SOLVER_PROBLEM_UPDATE_RULE;
- /* The problem is caused by a Job inside the Transaction */
+ /* The problem is caused by a Job inside the Request */
%constant int SOLVER_PROBLEM_JOB_RULE = SOLVER_PROBLEM_JOB_RULE;
/* A Job based on a Relation could not be fulfilled because there is no Solvable in the Pool providing it. */
%constant int SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP = SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP;
@@ -69,10 +69,10 @@ typedef struct _Problem {} Problem;
{ return $self->solver; }
/*
- * The Transaction causing the Problem
+ * The Request causing the Problem
*/
- Transaction *transaction()
- { return $self->transaction; }
+ Request *request()
+ { return $self->request; }
/*
* The reason for the problem. One of +Satsolver::SOLVER_PROBLEM_*+
diff --git a/bindings/python/tests/pool.py b/bindings/python/tests/pool.py
index 0a38d7f..f105e45 100644
--- a/bindings/python/tests/pool.py
+++ b/bindings/python/tests/pool.py
@@ -4,7 +4,7 @@
# It contains all solvables, grouped by Repo(sitorie)s
# and is needed to create instances of other classes.
#
-# For Solvable, Repo, Transaction, Solver and Relation,
+# For Solvable, Repo, Request, Solver and Relation,
# Pool provides create_... methods as counterparts to
# the instance contructors, all requiring a Pool argument.
#
diff --git a/bindings/python/tests/solvable.py b/bindings/python/tests/solvable.py
index 4988d41..f972975 100644
--- a/bindings/python/tests/solvable.py
+++ b/bindings/python/tests/solvable.py
@@ -86,8 +86,8 @@ class TestSequenceFunctions(unittest.TestCase):
solv1.requires().add(rel)
assert solv1.requires().size() == 1
- transaction = self.pool.create_transaction()
- transaction.install( solv1 )
+ request = self.pool.create_request()
+ request.install( solv1 )
system = self.pool.create_repo( '@system' )
@@ -99,7 +99,7 @@ class TestSequenceFunctions(unittest.TestCase):
solver = self.pool.create_solver()
solver.set_allow_uninstall(True)
- res = solver.solve( transaction )
+ res = solver.solve( request )
assert res.__class__.__name__ == 'bool', res.__class__.__name__
assert res == True, res
for s in solver.installs():
diff --git a/bindings/request.i b/bindings/request.i
index 1ef2d9a..901db55 100644
--- a/bindings/request.i
+++ b/bindings/request.i
@@ -1,17 +1,17 @@
/*
- * Document-class: Transaction
- * Transaction represents a Set of Jobs as input for the Solver.
+ * Document-class: Request
+ * Request represents a Set of Jobs as input for the Solver.
*
*/
%{
/*
- * iterating over jobs of a transaction ('yield' in Ruby)
+ * iterating over jobs of a request ('yield' in Ruby)
*/
static int
-transaction_jobs_iterate_callback( const Job *j )
+request_jobs_iterate_callback( const Job *j )
{
#if defined(SWIGRUBY)
/* FIXME: how to pass 'break' back to the caller ? */
@@ -23,25 +23,25 @@ transaction_jobs_iterate_callback( const Job *j )
%}
-%nodefault _Transaction;
-%rename(Transaction) _Transaction;
-typedef struct _Transaction {} Transaction;
+%nodefault _Request;
+%rename(Request) _Request;
+typedef struct _Request {} Request;
#if defined(SWIGRUBY)
-%mixin Transaction "Enumerable";
+%mixin Request "Enumerable";
#endif
-%extend Transaction {
+%extend Request {
/*
- * Create transaction based on Pool
+ * Create request based on Pool
*
- * See also: Pool.create_transaction
+ * See also: Pool.create_request
*/
- Transaction( Pool *pool )
- { return transaction_new( pool ); }
+ Request( Pool *pool )
+ { return request_new( pool ); }
- ~Transaction()
- { transaction_free( $self ); }
+ ~Request()
+ { request_free( $self ); }
/*
* Install request
@@ -55,13 +55,13 @@ typedef struct _Transaction {} Transaction;
* solvable matching the request (by name, by relation)
*
* call-seq:
- * transaction.install(solvable) -> void
- * transaction.install("kernel") -> void
- * transaction.install(relation) -> void
+ * request.install(solvable) -> void
+ * request.install("kernel") -> void
+ * request.install(relation) -> void
*
*/
void install( XSolvable *xs )
- { transaction_install_xsolvable( $self, xs ); }
+ { request_install_xsolvable( $self, xs ); }
/*
* Remove request
@@ -75,40 +75,40 @@ typedef struct _Transaction {} Transaction;
* solvable matching the request (by name, by relation)
*
* call-seq:
- * transaction.remove(solvable) -> void
- * transaction.remove("kernel") -> void
- * transaction.remove(relation) -> void
+ * request.remove(solvable) -> void
+ * request.remove("kernel") -> void
+ * request.remove(relation) -> void
*
*/
void remove( XSolvable *xs )
- { transaction_remove_xsolvable( $self, xs ); }
+ { request_remove_xsolvable( $self, xs ); }
/*
* Install solvable by name
*/
void install( const char *name )
- { transaction_install_name( $self, name ); }
+ { request_install_name( $self, name ); }
/*
* Remove solvable by name
*
*/
void remove( const char *name )
- { transaction_remove_name( $self, name ); }
+ { request_remove_name( $self, name ); }
/*
* Install solvable by relation
*
*/
void install( const Relation *rel )
- { transaction_install_relation( $self, rel ); }
+ { request_install_relation( $self, rel ); }
/*
* Remove solvable by relation
*
*/
void remove( const Relation *rel )
- { return transaction_remove_relation( $self, rel ); }
+ { return request_remove_relation( $self, rel ); }
#if defined(SWIGRUBY)
%rename("empty?") empty();
@@ -116,30 +116,30 @@ typedef struct _Transaction {} Transaction;
"$result = $1 ? Qtrue : Qfalse;";
#endif
/*
- * Check if the transaction has any jobs attached.
+ * Check if the request has any jobs attached.
*
* call-seq:
- * transaction.empty? -> bool
+ * request.empty? -> bool
*
*/
int empty()
{ return ( $self->queue.count == 0 ); }
/*
- * Return number of jobs of this transaction
+ * Return number of jobs of this request
*
*/
int size()
- { return transaction_size( $self ); }
+ { return request_size( $self ); }
#if defined(SWIGRUBY)
%rename("clear!") clear();
#endif
/*
- * Remove all jobs of this transaction
+ * Remove all jobs of this request
*
* call-seq:
- * transaction.clear! -> void
+ * request.clear! -> void
*
*/
void clear()
@@ -154,23 +154,23 @@ typedef struct _Transaction {} Transaction;
* The index is just a convenience access method and
* does NOT imply any preference/ordering of the Jobs.
*
- * A Transaction is always considered a set of Jobs.
+ * A Request is always considered a set of Jobs.
*
* call-seq:
- * transaction.get(42) -> Job
+ * request.get(42) -> Job
*
*/
Job *get( unsigned int i )
- { return transaction_job_get( $self, i ); }
+ { return request_job_get( $self, i ); }
/*
- * Iterate over each Job of the Transaction.
+ * Iterate over each Job of the Request.
*
* call-seq:
- * transaction.each { |job| ... }
+ * request.each { |job| ... }
*
*/
void each()
- { transaction_jobs_iterate( $self, transaction_jobs_iterate_callback ); }
+ { request_jobs_iterate( $self, request_jobs_iterate_callback ); }
}
diff --git a/bindings/ruby/tests/CMakeLists.txt b/bindings/ruby/tests/CMakeLists.txt
index b4846ec..49e6561 100644
--- a/bindings/ruby/tests/CMakeLists.txt
+++ b/bindings/ruby/tests/CMakeLists.txt
@@ -15,7 +15,7 @@ ADD_TEST(bindings_ruby_repodata ruby -C ${CMAKE_CURRENT_SOURCE_DIR} repodata.
ADD_TEST(bindings_ruby_providers ruby -C ${CMAKE_CURRENT_SOURCE_DIR} providers.rb)
-ADD_TEST(bindings_ruby_transaction ruby -C ${CMAKE_CURRENT_SOURCE_DIR} transaction.rb)
+ADD_TEST(bindings_ruby_request ruby -C ${CMAKE_CURRENT_SOURCE_DIR} request.rb)
ADD_TEST(bindings_ruby_covenants ruby -C ${CMAKE_CURRENT_SOURCE_DIR} covenants.rb)
ADD_TEST(bindings_ruby_solver ruby -C ${CMAKE_CURRENT_SOURCE_DIR} solver.rb)
diff --git a/bindings/ruby/tests/decisions.rb b/bindings/ruby/tests/decisions.rb
index 793b648..4aec778 100644
--- a/bindings/ruby/tests/decisions.rb
+++ b/bindings/ruby/tests/decisions.rb
@@ -55,15 +55,15 @@ class DecisionTest < Test::Unit::TestCase
solv3.requires << Satsolver::Relation.new( pool, "A", Satsolver::REL_GT, "0.0-0" )
repo.create_solvable( 'DD', '4.4-0' )
- transaction = pool.create_transaction
- transaction.install( solv3 )
- transaction.remove( "D" )
+ request = pool.create_request
+ request.install( solv3 )
+ request.remove( "D" )
pool.installed = installed
solver = pool.create_solver( )
solver.allow_uninstall = true;
# @pool.debug = 255
- solver.solve( transaction )
+ solver.solve( request )
puts "** Problems found" if solver.problems?
assert solver.decision_count > 0
i = 0
diff --git a/bindings/ruby/tests/installable.rb b/bindings/ruby/tests/installable.rb
index 8dba24c..9413c16 100644
--- a/bindings/ruby/tests/installable.rb
+++ b/bindings/ruby/tests/installable.rb
@@ -35,10 +35,10 @@ end
pool.prepare
repo.each do |s|
- transaction = Satsolver::Transaction.new( pool )
- transaction.install( s )
+ request = Satsolver::Request.new( pool )
+ request.install( s )
solver = Satsolver::Solver.new( pool )
- res = solver.solve( transaction )
+ res = solver.solve( request )
$stderr.puts "Package #{s} is not installable" unless res
end
diff --git a/bindings/ruby/tests/patch_updates.rb b/bindings/ruby/tests/patch_updates.rb
index 3d16508..90bcb3d 100644
--- a/bindings/ruby/tests/patch_updates.rb
+++ b/bindings/ruby/tests/patch_updates.rb
@@ -18,7 +18,7 @@ solver.allow_uninstall = true
solver.fix_system = true
pool.prepare
-solver.solve( pool.create_transaction )
+solver.solve( pool.create_request )
removals = []
solver.each_to_remove { |s|
@@ -43,7 +43,7 @@ solver.allow_uninstall = true
solver.fix_system = true
pool.prepare
-solver.solve( pool.create_transaction )
+solver.solve( pool.create_request )
# these shouldn't print anything
@@ -68,7 +68,7 @@ solver.update_system = true
solver.fix_system = true
pool.prepare
-solver.solve( pool.create_transaction )
+solver.solve( pool.create_request )
#
# Now match updates to patches
diff --git a/bindings/ruby/tests/pool.rb b/bindings/ruby/tests/pool.rb
index fde6b05..3ca6160 100644
--- a/bindings/ruby/tests/pool.rb
+++ b/bindings/ruby/tests/pool.rb
@@ -4,7 +4,7 @@
# It contains all solvables, grouped by Repo(sitorie)s
# and is needed to create instances of other classes.
#
-# For Solvable, Repo, Transaction, Solver and Relation,
+# For Solvable, Repo, Request, Solver and Relation,
# Pool provides create_... methods as counterparts to
# the instance contructors, all requiring a Pool argument.
#
diff --git a/bindings/ruby/tests/problems.rb b/bindings/ruby/tests/problems.rb
index 8c0b50c..d2af244 100644
--- a/bindings/ruby/tests/problems.rb
+++ b/bindings/ruby/tests/problems.rb
@@ -47,12 +47,12 @@ require 'pathname'
require 'test/unit'
require 'satsolver'
-def solve_and_check solver, transaction, reason
+def solve_and_check solver, request, reason
# assert solver.problems?
i = 0
found = false
- solver.each_problem( transaction ) { |p|
+ solver.each_problem( request ) { |p|
found = true if p.reason == reason
i += 1
case p.reason
@@ -104,87 +104,87 @@ class ProblemTest < Test::Unit::TestCase
end
def test_update_rule
- transaction = @pool.create_transaction
+ request = @pool.create_request
@pool.installed = @installed
solver = @pool.create_solver( )
- solver.solve( transaction )
- assert solve_and_check( solver, transaction, Satsolver::SOLVER_PROBLEM_UPDATE_RULE )
+ solver.solve( request )
+ assert solve_and_check( solver, request, Satsolver::SOLVER_PROBLEM_UPDATE_RULE )
end
def test_job_rule
- transaction = @pool.create_transaction
+ request = @pool.create_request
@pool.installed = @installed
solver = @pool.create_solver( )
- solver.solve( transaction )
- assert solve_and_check( solver, transaction, Satsolver::SOLVER_PROBLEM_JOB_RULE )
+ solver.solve( request )
+ assert solve_and_check( solver, request, Satsolver::SOLVER_PROBLEM_JOB_RULE )
end
def test_job_nothing_provides
- transaction = @pool.create_transaction
+ request = @pool.create_request
@pool.installed = @installed
solver = @pool.create_solver( )
- solver.solve( transaction )
- assert solve_and_check( solver, transaction, Satsolver::SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP )
+ solver.solve( request )
+ assert solve_and_check( solver, request, Satsolver::SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP )
end
def test_not_installable
- transaction = @pool.create_transaction
+ request = @pool.create_request
solv = @pool.find( "A", @repo )
solv.requires << @pool.create_relation( "ZZ" )
- transaction.install( solv )
+ request.install( solv )
@pool.installed = @installed
solver = @pool.create_solver( )
- solver.solve( transaction )
- assert solve_and_check( solver, transaction, Satsolver::SOLVER_PROBLEM_NOT_INSTALLABLE )
+ solver.solve( request )
+ assert solve_and_check( solver, request, Satsolver::SOLVER_PROBLEM_NOT_INSTALLABLE )
end
def test_nothing_provides
- transaction = @pool.create_transaction
+ request = @pool.create_request
solvA = @pool.find( "A", @repo )
solvA.requires << @pool.create_relation( "B", Satsolver::REL_GE, "2.0-0" )
solvB = @pool.find( "B", @repo )
solvB.requires << @pool.create_relation( "ZZ" )
- transaction.install( solvA )
+ request.install( solvA )
@pool.installed = @installed
solver = @pool.create_solver( )
- solver.solve( transaction )
- assert solve_and_check( solver, transaction, Satsolver::SOLVER_PROBLEM_NOTHING_PROVIDES_DEP )
+ solver.solve( request )
+ assert solve_and_check( solver, request, Satsolver::SOLVER_PROBLEM_NOTHING_PROVIDES_DEP )
end
def test_same_name
- transaction = @pool.create_transaction
+ request = @pool.create_request
solvA = @pool.find( "A", @repo )
- transaction.install( solvA )
+ request.install( solvA )
solvA = @repo.create_solvable( "A", "2.0-0" )
- transaction.install( solvA )
+ request.install( solvA )
@pool.installed = @installed
solver = @pool.create_solver( )
- solver.solve( transaction )
- assert solve_and_check( solver, transaction, Satsolver::SOLVER_PROBLEM_SAME_NAME )
+ solver.solve( request )
+ assert solve_and_check( solver, request, Satsolver::SOLVER_PROBLEM_SAME_NAME )
end
def test_package_conflict
- transaction = @pool.create_transaction
+ request = @pool.create_request
solvA = @pool.find( "A", @repo )
solvB = @pool.find( "B", @repo )
solvA.conflicts << @pool.create_relation( solvB.name, Satsolver::REL_EQ, solvB.evr )
solvB.conflicts << @pool.create_relation( solvA.name, Satsolver::REL_EQ, solvA.evr )
- transaction.install( solvA )
- transaction.install( solvB )
+ request.install( solvA )
+ request.install( solvB )
@pool.installed = @installed
solver = @pool.create_solver( )
- solver.solve( transaction )
- assert solve_and_check( solver, transaction, Satsolver::SOLVER_PROBLEM_PACKAGE_CONFLICT )
+ solver.solve( request )
+ assert solve_and_check( solver, request, Satsolver::SOLVER_PROBLEM_PACKAGE_CONFLICT )
end
def test_package_obsoletes
- transaction = @pool.create_transaction
+ request = @pool.create_request
solvCC = @pool.find( "CC", @repo )
solvCC.obsoletes << @pool.create_relation( "A" )
- transaction.install( solvCC )
+ request.install( solvCC )
@pool.installed = @installed
solver = @pool.create_solver( )
- solver.solve( transaction )
- assert solve_and_check( solver, transaction, Satsolver::SOLVER_PROBLEM_PACKAGE_OBSOLETES )
+ solver.solve( request )
+ assert solve_and_check( solver, request, Satsolver::SOLVER_PROBLEM_PACKAGE_OBSOLETES )
end
def test_providers_not_installable
- transaction = @pool.create_transaction
+ request = @pool.create_request
@pool.installed = @installed
solver = @pool.create_solver( )
- solver.solve( transaction )
- assert solve_and_check( solver, transaction, Satsolver::SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE )
+ solver.solve( request )
+ assert solve_and_check( solver, request, Satsolver::SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE )
end
end
diff --git a/bindings/ruby/tests/reasons.rb b/bindings/ruby/tests/reasons.rb
index 6a1866f..3158deb 100644
--- a/bindings/ruby/tests/reasons.rb
+++ b/bindings/ruby/tests/reasons.rb
@@ -155,12 +155,12 @@ class ReasonsTest < Test::Unit::TestCase
puts "\n---\nB-1.0-0 requires A = 1.0-0"
- transaction = @pool.create_transaction
- transaction.install( solv2 )
+ request = @pool.create_request
+ request.install( solv2 )
@pool.prepare
solver = @pool.create_solver( )
- solver.solve( transaction )
+ solver.solve( request )
explain solver
end
@@ -175,12 +175,12 @@ class ReasonsTest < Test::Unit::TestCase
puts "\n---\nB-1.0-0 requires a = 42, provided by A-1.0-0"
- transaction = @pool.create_transaction
- transaction.install( solv2 )
+ request = @pool.create_request
+ request.install( solv2 )
@pool.prepare
solver = @pool.create_solver( )
- solver.solve( transaction )
+ solver.solve( request )
explain solver
end
@@ -197,12 +197,12 @@ class ReasonsTest < Test::Unit::TestCase
puts "\n---\nB-1.0-0 requires a = 42, provided by A-1.0-0 and C-1.0-0"
- transaction = @pool.create_transaction
- transaction.install( solv2 )
+ request = @pool.create_request
+ request.install( solv2 )
@pool.prepare
solver = @pool.create_solver( )
- solver.solve( transaction )
+ solver.solve( request )
explain solver
end
@@ -213,13 +213,13 @@ class ReasonsTest < Test::Unit::TestCase
repo.name = "beta5"
puts "\n---\nInstalling bash"
- transaction = @pool.create_transaction
- transaction.install( "bash" )
+ request = @pool.create_request
+ request.install( "bash" )
@pool.prepare
solver = @pool.create_solver( )
# solver.dont_install_recommended = true
- solver.solve( transaction )
+ solver.solve( request )
explain solver
end
@@ -238,12 +238,12 @@ class ReasonsTest < Test::Unit::TestCase
puts "\n---\nB-1.0-0 conflicts a = 42, provided by installed A-1.0-0"
- transaction = @pool.create_transaction
- transaction.install( solv2 )
+ request = @pool.create_request
+ request.install( solv2 )
@pool.prepare
solver = @pool.create_solver( )
- solver.solve( transaction )
+ solver.solve( request )
explain solver
end
@@ -260,12 +260,12 @@ class ReasonsTest < Test::Unit::TestCase
puts "\n---\n#{solv2} obsoletes #{rel}, provided by installed #{solv1}"
- transaction = @pool.create_transaction
- transaction.install( solv2 )
+ request = @pool.create_request
+ request.install( solv2 )
@pool.prepare
solver = @pool.create_solver( )
- solver.solve( transaction )
+ solver.solve( request )
explain solver
end
@@ -283,13 +283,13 @@ class ReasonsTest < Test::Unit::TestCase
@pool.installed = @repo
- transaction = @pool.create_transaction
- transaction.remove( solv1 )
+ request = @pool.create_request
+ request.remove( solv1 )
@pool.prepare
solver = @pool.create_solver( )
solver.allow_uninstall = true
- solver.solve( transaction )
+ solver.solve( request )
explain solver
end
diff --git a/bindings/ruby/tests/request.rb b/bindings/ruby/tests/request.rb
index 454572f..dc8eb01 100644
--- a/bindings/ruby/tests/request.rb
+++ b/bindings/ruby/tests/request.rb
@@ -6,8 +6,8 @@ require 'pathname'
require 'test/unit'
require 'satsolver'
-class TransactionTest < Test::Unit::TestCase
- def test_transaction
+class RequestTest < Test::Unit::TestCase
+ def test_request
pool = Satsolver::Pool.new
assert pool
pool.arch = "i686"
@@ -15,16 +15,16 @@ class TransactionTest < Test::Unit::TestCase
repo = pool.add_solv( solvpath )
repo.name = "test1"
- transaction = Satsolver::Transaction.new( pool )
- assert transaction
- transaction.install( "foo" )
- transaction.install( repo.find "ruby" )
- transaction.install( Satsolver::Relation.new( pool, "foo", Satsolver::REL_EQ, "42-7" ) )
- transaction.remove( "bar" )
- transaction.remove( repo.find "glibc" )
- transaction.remove( Satsolver::Relation.new( pool, "bar", Satsolver::REL_EQ, "42-7" ) )
- assert transaction.size == 6
- transaction.each { |a|
+ request = Satsolver::Request.new( pool )
+ assert request
+ request.install( "foo" )
+ request.install( repo.find "ruby" )
+ request.install( Satsolver::Relation.new( pool, "foo", Satsolver::REL_EQ, "42-7" ) )
+ request.remove( "bar" )
+ request.remove( repo.find "glibc" )
+ request.remove( Satsolver::Relation.new( pool, "bar", Satsolver::REL_EQ, "42-7" ) )
+ assert request.size == 6
+ request.each { |a|
cmd = case a.cmd
when Satsolver::INSTALL_SOLVABLE: "install #{a.solvable}"
when Satsolver::REMOVE_SOLVABLE: "remove #{a.solvable}"
@@ -36,7 +36,7 @@ class TransactionTest < Test::Unit::TestCase
end
puts cmd
}
- transaction.clear!
- assert transaction.empty?
+ request.clear!
+ assert request.empty?
end
end
diff --git a/bindings/ruby/tests/solutions.rb b/bindings/ruby/tests/solutions.rb
index 0feef22..72a693a 100644
--- a/bindings/ruby/tests/solutions.rb
+++ b/bindings/ruby/tests/solutions.rb
@@ -41,19 +41,19 @@ class SolutionTest < Test::Unit::TestCase
repo.create_solvable( 'DD', '4.4-0' )
- transaction = pool.create_transaction
- transaction.install( solv1 )
- transaction.remove( "Z" )
+ request = pool.create_request
+ request.install( solv1 )
+ request.remove( "Z" )
pool.installed = installed
solver = pool.create_solver( )
# solver.allow_uninstall = true;
# @pool.debug = 255
- solver.solve( transaction )
+ solver.solve( request )
assert solver.problems?
puts "Problems found"
i = 0
- solver.each_problem( transaction ) { |p|
+ solver.each_problem( request ) { |p|
i += 1
case p.reason
when Satsolver::SOLVER_PROBLEM_UPDATE_RULE
diff --git a/bindings/ruby/tests/solvable.rb b/bindings/ruby/tests/solvable.rb
index a82d0d7..7fa91ac 100644
--- a/bindings/ruby/tests/solvable.rb
+++ b/bindings/ruby/tests/solvable.rb
@@ -82,12 +82,12 @@ class SolvableTest < Test::Unit::TestCase
solv1.requires << rel
assert solv1.requires.size == 1
- transaction = @pool.create_transaction
- transaction.install( solv1 )
+ request = @pool.create_request
+ request.install( solv1 )
solver = @pool.create_solver( )
# @pool.debug = 255
- solver.solve( transaction )
+ solver.solve( request )
solver.each_to_install { |s|
puts "Install #{s}"
}
diff --git a/bindings/ruby/tests/solver.rb b/bindings/ruby/tests/solver.rb
index 104c573..fa96409 100644
--- a/bindings/ruby/tests/solver.rb
+++ b/bindings/ruby/tests/solver.rb
@@ -15,16 +15,16 @@ class SolverTest < Test::Unit::TestCase
repo = pool.add_solv( "../../../testsuite/data.libzypp/basic-exercises/exercise-1-packages.solv" )
repo.name = "test"
- transaction = Satsolver::Transaction.new( pool )
- transaction.install( "A" )
- transaction.remove( "xorg-x11" )
+ request = Satsolver::Request.new( pool )
+ request.install( "A" )
+ request.remove( "xorg-x11" )
pool.installed = system
solver = Satsolver::Solver.new( pool )
solver.allow_uninstall = true
assert solver.allow_uninstall
pool.prepare
- solver.solve( transaction )
+ solver.solve( request )
assert solver.sizechange
puts "Size change #{solver.sizechange}"
solver.each_to_install { |s|
diff --git a/bindings/ruby/tests/updates.rb b/bindings/ruby/tests/updates.rb
index 6a62211..af44dcb 100644
--- a/bindings/ruby/tests/updates.rb
+++ b/bindings/ruby/tests/updates.rb
@@ -17,7 +17,7 @@ solver.allow_uninstall = true
solver.fix_system = true
pool.prepare
-solver.solve( pool.create_transaction )
+solver.solve( pool.create_request )
removals = []
solver.each_to_remove { |s|
@@ -42,7 +42,7 @@ solver.allow_uninstall = true
solver.fix_system = true
pool.prepare
-solver.solve( pool.create_transaction )
+solver.solve( pool.create_request )
# these shouldn't print anything
@@ -67,7 +67,7 @@ solver.update_system = true
solver.fix_system = true
pool.prepare
-solver.solve( pool.create_transaction )
+solver.solve( pool.create_request )
count = 0
solver.each_to_install { |s|
diff --git a/bindings/rule.i b/bindings/rule.i
index 858cc16..f63e7c3 100644
--- a/bindings/rule.i
+++ b/bindings/rule.i
@@ -2,7 +2,7 @@
* Document-class: Rule
*
* A rule is the internal representation of the _working_ _queue_ of the
- * solver. Each transaction item and each dependency is converted to a
+ * solver. Each job item and each dependency is converted to a
* rule the solver operates on.
*
* Rules are useful to traceback a decision or a problem.
diff --git a/bindings/satsolver.i b/bindings/satsolver.i
index 1afb04e..92178a0 100644
--- a/bindings/satsolver.i
+++ b/bindings/satsolver.i
@@ -152,7 +152,7 @@ SWIGINTERNINLINE SV *SWIG_FromCharPtr(const char *cptr);
#include "relation.h"
#include "dependency.h"
#include "job.h"
-#include "transaction.h"
+#include "request.h"
#include "decision.h"
#include "problem.h"
#include "solution.h"
@@ -403,7 +403,7 @@ typedef unsigned int Offset;
%include "dependency.i"
%include "solvable.i"
%include "job.i"
-%include "transaction.i"
+%include "request.i"
%include "decision.i"
%include "problem.i"
%include "solution.i"
diff --git a/bindings/solver.i b/bindings/solver.i
index 33f9e70..2a9fd5b 100644
--- a/bindings/solver.i
+++ b/bindings/solver.i
@@ -8,7 +8,7 @@
* solver can operate on. The pool also has designated repository for
* 'installed' solvables.
*
- * Solving is done by creating Transactions and feeding them to the
+ * Solving is done by creating a Request and feeding it to the
* solver as input. On success (solver.solve() returning 'true'), one can
* retrieve the Decisions made by the solver (i.e. install this, remove
* that, update those). On failure, the solver creates a list of
@@ -24,17 +24,17 @@
* pool.installed = system
* repo = pool.add_solv( "myrepo.solv" )
*
- * transaction = pool.create_transaction
- * transaction.install( "packageA" )
- * transaction.install( "packageB" )
- * transaction.remove( "old_package" )
+ * request = pool.create_request
+ * request.install( "packageA" )
+ * request.install( "packageB" )
+ * request.remove( "old_package" )
*
* solver = pool.create_solver
* solver.allow_uninstall = true
* pool.prepare
- * result = solver.solve( transaction )
+ * result = solver.solve( request )
* if !result
- * raise "Couldn't solve transaction"
+ * raise "Couldn't solve request"
* end
*
* solver.each_to_install do |s|
@@ -157,7 +157,7 @@ typedef struct solver {} Solver;
* The normal solver operation tries to install (to update to) the 'best' package,
* usually the one with the highest version.
* If allow_downgrade is set, packages may be downgraded in order to
- * fulfill a transaction or a dependency
+ * fulfill a request or a dependency
* call-seq:
* solver.allow_downgrade -> bool
*
@@ -250,9 +250,9 @@ typedef struct solver {} Solver;
/*
* On package removal, also remove dependant packages.
*
- * If removal of a package breaks dependencies, the transaction is
+ * If removal of a package breaks dependencies, the request is
* usually considered not solvable. The dependencies of installed
- * packages take precedence over transaction actions.
+ * packages take precedence over request actions.
*
*
* call-seq:
@@ -791,15 +791,15 @@ typedef struct solver {} Solver;
}
#endif
/*
- * Solve the given Transaction
+ * Solve the given Request
*
* Returns +true+ if a solution was found, else +false+.
*
* call-seq:
- * solver.solve(transaction) -> bool
+ * solver.solve(request) -> bool
*
*/
- int solve( Transaction *t )
+ int solve( Request *t )
{
if ($self->covenantq.count) {
/* FIXME: Honor covenants */
@@ -811,11 +811,11 @@ typedef struct solver {} Solver;
/*
* Return the number of decisions after solving.
*
- * If its >0, a solution of the Transaction was found.
+ * If its >0, a solution of the Request was found.
*
- * If its ==0, and 'Solver.problems?' returns +true+, the Transaction couldn't be solved.
+ * If its ==0, and 'Solver.problems?' returns +true+, the Request couldn't be solved.
*
- * If its ==0, and 'Solver.problems?' returns +false+, the Transaction is trivially solved.
+ * If its ==0, and 'Solver.problems?' returns +false+, the Request is trivially solved.
*
* call-seq:
* solver.decision_count -> int
@@ -865,10 +865,10 @@ typedef struct solver {} Solver;
* *OBSOLETE*: Use Decision.explain instead
*
* call-seq:
- * solver.explain(transaction, decision) -> [<SOLVER_PROBLEM_xxx>, Relation, Solvable, Solvable]
+ * solver.explain(request, decision) -> [<SOLVER_PROBLEM_xxx>, Relation, Solvable, Solvable]
*
*/
- __type explain(Transaction *unused, Decision *decision)
+ __type explain(Request *unused, Decision *decision)
{
Swig_Type result = Swig_Null;
Id rule = decision->rule - $self->rules;
@@ -911,10 +911,10 @@ typedef struct solver {} Solver;
* Iterate over problems.
*
* call-seq:
- * solver.each_problem(transaction) { |problem| ... }
+ * solver.each_problem(request) { |problem| ... }
*
*/
- void each_problem( Transaction *t )
+ void each_problem( Request *t )
{ return solver_problems_iterate( $self, t, solver_problems_iterate_callback, NULL ); }
/*
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> master : - rename applayer's transaction to request to make it compile
by Michael Schroeder 15 May '09
by Michael Schroeder 15 May '09
15 May '09
ref: refs/heads/master
commit ff13681f6b91cb3d7af39be703ebe681f6cfa323
Author: Michael Schroeder <mls(a)suse.de>
Date: Fri May 15 17:04:18 2009 +0200
- rename applayer's transaction to request to make it compile
(I would prefer job, but job is already taken.
Let Klaus decide.)
---
applayer/request.c | 127 ++++++++++++++++++++++++++
applayer/request.h | 41 +++++++++
applayer/transaction.c | 127 --------------------------
applayer/transaction.h | 41 ---------
bindings/request.i | 176 ++++++++++++++++++++++++++++++++++++
bindings/ruby/tests/request.rb | 42 +++++++++
bindings/ruby/tests/transaction.rb | 42 ---------
bindings/transaction.i | 176 ------------------------------------
8 files changed, 386 insertions(+), 386 deletions(-)
diff --git a/applayer/request.c b/applayer/request.c
new file mode 100644
index 0000000..a2bf6b0
--- /dev/null
+++ b/applayer/request.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+/************************************************
+ * Transaction
+ *
+ * A set of Actions to be solved by the Solver
+ *
+ */
+
+#include <stdlib.h>
+
+#include "transaction.h"
+
+
+Transaction *
+transaction_new( Pool *pool )
+{
+ Transaction *t = (Transaction *)malloc( sizeof( Transaction ));
+ t->pool = pool;
+ queue_init( &(t->queue) );
+ return t;
+}
+
+void
+transaction_free( Transaction *t )
+{
+ queue_free( &(t->queue) );
+ free( t );
+}
+
+
+/*
+ * number of actions in transaction
+ * every two queue elements make one action
+ */
+
+int
+transaction_size( Transaction *t )
+{
+ return t->queue.count >> 1;
+}
+
+
+void
+transaction_install_xsolvable( Transaction *t, XSolvable *xs )
+{
+ queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE );
+ /* FIXME: check: s->repo->pool == $self->pool */
+ queue_push( &(t->queue), xs->id );
+}
+
+
+void
+transaction_remove_xsolvable( Transaction *t, XSolvable *xs )
+{
+ queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE );
+ /* FIXME: check: s->repo->pool == $self->pool */
+ queue_push( &(t->queue), xs->id );
+}
+
+
+void
+transaction_install_name( Transaction *t, const char *name )
+{
+ queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_NAME );
+ queue_push( &(t->queue), str2id( t->pool, name, 1 ));
+}
+
+
+void
+transaction_remove_name( Transaction *t, const char *name )
+{
+ queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_NAME );
+ queue_push( &(t->queue), str2id( t->pool, name, 1 ));
+}
+
+
+void
+transaction_install_relation( Transaction *t, const Relation *rel )
+{
+ queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_PROVIDES );
+ /* FIXME: check: rel->pool == $self->pool */
+ queue_push( &(t->queue), rel->id );
+}
+
+
+void
+transaction_remove_relation( Transaction *t, const Relation *rel )
+{
+ queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_PROVIDES );
+ /* FIXME: check: rel->pool == $self->pool */
+ queue_push( &(t->queue), rel->id );
+}
+
+
+Job *
+transaction_job_get( Transaction *t, int i )
+{
+ int size, cmd;
+ Id id;
+ i <<= 1;
+ size = t->queue.count;
+ if (i-1 >= size)
+ return NULL;
+ cmd = t->queue.elements[i];
+ id = t->queue.elements[i+1];
+ return job_new( t->pool, cmd, id );
+}
+
+
+void
+transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j))
+{
+ int i;
+ for (i = 0; i < t->queue.count-1; )
+ {
+ int cmd = t->queue.elements[i++];
+ Id id = t->queue.elements[i++];
+ if (callback( job_new( t->pool, cmd, id ) ) )
+ break;
+ }
+}
diff --git a/applayer/request.h b/applayer/request.h
new file mode 100644
index 0000000..0a30642
--- /dev/null
+++ b/applayer/request.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+/************************************************
+ * Transaction
+ *
+ * A set of Actions to be solved by the Solver
+ *
+ */
+
+#ifndef SATSOLVER_TRANSACTION_H
+#define SATSOLVER_TRANSACTION_H
+
+#include "job.h"
+
+
+typedef struct _Transaction {
+ Pool *pool;
+ Queue queue;
+} Transaction;
+
+
+Transaction *transaction_new( Pool *pool );
+void transaction_free( Transaction *t );
+
+void transaction_install_xsolvable( Transaction *t, XSolvable *xs );
+void transaction_remove_xsolvable( Transaction *t, XSolvable *xs );
+void transaction_install_name( Transaction *t, const char *name );
+void transaction_remove_name( Transaction *t, const char *name );
+void transaction_install_relation( Transaction *t, const Relation *rel );
+void transaction_remove_relation( Transaction *t, const Relation *rel );
+int transaction_size( Transaction *t );
+Job *transaction_job_get( Transaction *t, int i );
+
+void transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j));
+
+#endif /* SATSOLVER_TRANSACTION_H */
diff --git a/applayer/transaction.c b/applayer/transaction.c
deleted file mode 100644
index a2bf6b0..0000000
--- a/applayer/transaction.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2007, Novell Inc.
- *
- * This program is licensed under the BSD license, read LICENSE.BSD
- * for further information
- */
-
-/************************************************
- * Transaction
- *
- * A set of Actions to be solved by the Solver
- *
- */
-
-#include <stdlib.h>
-
-#include "transaction.h"
-
-
-Transaction *
-transaction_new( Pool *pool )
-{
- Transaction *t = (Transaction *)malloc( sizeof( Transaction ));
- t->pool = pool;
- queue_init( &(t->queue) );
- return t;
-}
-
-void
-transaction_free( Transaction *t )
-{
- queue_free( &(t->queue) );
- free( t );
-}
-
-
-/*
- * number of actions in transaction
- * every two queue elements make one action
- */
-
-int
-transaction_size( Transaction *t )
-{
- return t->queue.count >> 1;
-}
-
-
-void
-transaction_install_xsolvable( Transaction *t, XSolvable *xs )
-{
- queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE );
- /* FIXME: check: s->repo->pool == $self->pool */
- queue_push( &(t->queue), xs->id );
-}
-
-
-void
-transaction_remove_xsolvable( Transaction *t, XSolvable *xs )
-{
- queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE );
- /* FIXME: check: s->repo->pool == $self->pool */
- queue_push( &(t->queue), xs->id );
-}
-
-
-void
-transaction_install_name( Transaction *t, const char *name )
-{
- queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_NAME );
- queue_push( &(t->queue), str2id( t->pool, name, 1 ));
-}
-
-
-void
-transaction_remove_name( Transaction *t, const char *name )
-{
- queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_NAME );
- queue_push( &(t->queue), str2id( t->pool, name, 1 ));
-}
-
-
-void
-transaction_install_relation( Transaction *t, const Relation *rel )
-{
- queue_push( &(t->queue), SOLVER_INSTALL_SOLVABLE_PROVIDES );
- /* FIXME: check: rel->pool == $self->pool */
- queue_push( &(t->queue), rel->id );
-}
-
-
-void
-transaction_remove_relation( Transaction *t, const Relation *rel )
-{
- queue_push( &(t->queue), SOLVER_ERASE_SOLVABLE_PROVIDES );
- /* FIXME: check: rel->pool == $self->pool */
- queue_push( &(t->queue), rel->id );
-}
-
-
-Job *
-transaction_job_get( Transaction *t, int i )
-{
- int size, cmd;
- Id id;
- i <<= 1;
- size = t->queue.count;
- if (i-1 >= size)
- return NULL;
- cmd = t->queue.elements[i];
- id = t->queue.elements[i+1];
- return job_new( t->pool, cmd, id );
-}
-
-
-void
-transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j))
-{
- int i;
- for (i = 0; i < t->queue.count-1; )
- {
- int cmd = t->queue.elements[i++];
- Id id = t->queue.elements[i++];
- if (callback( job_new( t->pool, cmd, id ) ) )
- break;
- }
-}
diff --git a/applayer/transaction.h b/applayer/transaction.h
deleted file mode 100644
index 0a30642..0000000
--- a/applayer/transaction.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2007, Novell Inc.
- *
- * This program is licensed under the BSD license, read LICENSE.BSD
- * for further information
- */
-
-/************************************************
- * Transaction
- *
- * A set of Actions to be solved by the Solver
- *
- */
-
-#ifndef SATSOLVER_TRANSACTION_H
-#define SATSOLVER_TRANSACTION_H
-
-#include "job.h"
-
-
-typedef struct _Transaction {
- Pool *pool;
- Queue queue;
-} Transaction;
-
-
-Transaction *transaction_new( Pool *pool );
-void transaction_free( Transaction *t );
-
-void transaction_install_xsolvable( Transaction *t, XSolvable *xs );
-void transaction_remove_xsolvable( Transaction *t, XSolvable *xs );
-void transaction_install_name( Transaction *t, const char *name );
-void transaction_remove_name( Transaction *t, const char *name );
-void transaction_install_relation( Transaction *t, const Relation *rel );
-void transaction_remove_relation( Transaction *t, const Relation *rel );
-int transaction_size( Transaction *t );
-Job *transaction_job_get( Transaction *t, int i );
-
-void transaction_jobs_iterate( Transaction *t, int (*callback)( const Job *j));
-
-#endif /* SATSOLVER_TRANSACTION_H */
diff --git a/bindings/request.i b/bindings/request.i
new file mode 100644
index 0000000..1ef2d9a
--- /dev/null
+++ b/bindings/request.i
@@ -0,0 +1,176 @@
+/*
+ * Document-class: Transaction
+ * Transaction represents a Set of Jobs as input for the Solver.
+ *
+ */
+
+%{
+
+/*
+ * iterating over jobs of a transaction ('yield' in Ruby)
+ */
+
+static int
+transaction_jobs_iterate_callback( const Job *j )
+{
+#if defined(SWIGRUBY)
+ /* FIXME: how to pass 'break' back to the caller ? */
+ rb_yield(SWIG_NewPointerObj((void*) j, SWIGTYPE_p__Job, 0));
+#endif
+ return 0;
+}
+
+%}
+
+
+%nodefault _Transaction;
+%rename(Transaction) _Transaction;
+typedef struct _Transaction {} Transaction;
+
+#if defined(SWIGRUBY)
+%mixin Transaction "Enumerable";
+#endif
+
+%extend Transaction {
+ /*
+ * Create transaction based on Pool
+ *
+ * See also: Pool.create_transaction
+ */
+ Transaction( Pool *pool )
+ { return transaction_new( pool ); }
+
+ ~Transaction()
+ { transaction_free( $self ); }
+
+ /*
+ * Install request
+ *
+ * Ensure installation of a solvable by either
+ * * specifying it directly
+ * * specify it by name
+ * * specify a required relation
+ *
+ * Except when specified directly, the solver is free to choose any
+ * solvable matching the request (by name, by relation)
+ *
+ * call-seq:
+ * transaction.install(solvable) -> void
+ * transaction.install("kernel") -> void
+ * transaction.install(relation) -> void
+ *
+ */
+ void install( XSolvable *xs )
+ { transaction_install_xsolvable( $self, xs ); }
+
+ /*
+ * Remove request
+ *
+ * Ensure removal of a solvable by either
+ * * specifying it directly
+ * * specify it by name
+ * * specify a required relation
+ *
+ * Except when specified directly, the solver is free to choose any
+ * solvable matching the request (by name, by relation)
+ *
+ * call-seq:
+ * transaction.remove(solvable) -> void
+ * transaction.remove("kernel") -> void
+ * transaction.remove(relation) -> void
+ *
+ */
+ void remove( XSolvable *xs )
+ { transaction_remove_xsolvable( $self, xs ); }
+
+ /*
+ * Install solvable by name
+ */
+ void install( const char *name )
+ { transaction_install_name( $self, name ); }
+
+ /*
+ * Remove solvable by name
+ *
+ */
+ void remove( const char *name )
+ { transaction_remove_name( $self, name ); }
+
+ /*
+ * Install solvable by relation
+ *
+ */
+ void install( const Relation *rel )
+ { transaction_install_relation( $self, rel ); }
+
+ /*
+ * Remove solvable by relation
+ *
+ */
+ void remove( const Relation *rel )
+ { return transaction_remove_relation( $self, rel ); }
+
+#if defined(SWIGRUBY)
+ %rename("empty?") empty();
+ %typemap(out) int empty
+ "$result = $1 ? Qtrue : Qfalse;";
+#endif
+ /*
+ * Check if the transaction has any jobs attached.
+ *
+ * call-seq:
+ * transaction.empty? -> bool
+ *
+ */
+ int empty()
+ { return ( $self->queue.count == 0 ); }
+
+ /*
+ * Return number of jobs of this transaction
+ *
+ */
+ int size()
+ { return transaction_size( $self ); }
+
+#if defined(SWIGRUBY)
+ %rename("clear!") clear();
+#endif
+ /*
+ * Remove all jobs of this transaction
+ *
+ * call-seq:
+ * transaction.clear! -> void
+ *
+ */
+ void clear()
+ { queue_empty( &($self->queue) ); }
+
+#if defined(SWIGRUBY)
+ %alias get "[]";
+#endif
+ /*
+ * Get job by index
+ *
+ * The index is just a convenience access method and
+ * does NOT imply any preference/ordering of the Jobs.
+ *
+ * A Transaction is always considered a set of Jobs.
+ *
+ * call-seq:
+ * transaction.get(42) -> Job
+ *
+ */
+ Job *get( unsigned int i )
+ { return transaction_job_get( $self, i ); }
+
+ /*
+ * Iterate over each Job of the Transaction.
+ *
+ * call-seq:
+ * transaction.each { |job| ... }
+ *
+ */
+ void each()
+ { transaction_jobs_iterate( $self, transaction_jobs_iterate_callback ); }
+}
+
diff --git a/bindings/ruby/tests/request.rb b/bindings/ruby/tests/request.rb
new file mode 100644
index 0000000..454572f
--- /dev/null
+++ b/bindings/ruby/tests/request.rb
@@ -0,0 +1,42 @@
+$:.unshift "../../../build/bindings/ruby"
+require 'pathname'
+
+# test Transction
+
+require 'test/unit'
+require 'satsolver'
+
+class TransactionTest < Test::Unit::TestCase
+ def test_transaction
+ pool = Satsolver::Pool.new
+ assert pool
+ pool.arch = "i686"
+ solvpath = Pathname( File.dirname( __FILE__ ) ) + Pathname( "../../testdata" ) + "os11-biarch.solv"
+ repo = pool.add_solv( solvpath )
+ repo.name = "test1"
+
+ transaction = Satsolver::Transaction.new( pool )
+ assert transaction
+ transaction.install( "foo" )
+ transaction.install( repo.find "ruby" )
+ transaction.install( Satsolver::Relation.new( pool, "foo", Satsolver::REL_EQ, "42-7" ) )
+ transaction.remove( "bar" )
+ transaction.remove( repo.find "glibc" )
+ transaction.remove( Satsolver::Relation.new( pool, "bar", Satsolver::REL_EQ, "42-7" ) )
+ assert transaction.size == 6
+ transaction.each { |a|
+ cmd = case a.cmd
+ when Satsolver::INSTALL_SOLVABLE: "install #{a.solvable}"
+ when Satsolver::REMOVE_SOLVABLE: "remove #{a.solvable}"
+ when Satsolver::INSTALL_SOLVABLE_NAME: "install by name #{a.name}"
+ when Satsolver::REMOVE_SOLVABLE_NAME: "remove by name #{a.name}"
+ when Satsolver::INSTALL_SOLVABLE_PROVIDES: "install by relation #{a.relation}"
+ when Satsolver::REMOVE_SOLVABLE_PROVIDES: "remove by relation #{a.relation}"
+ else "<NONE>"
+ end
+ puts cmd
+ }
+ transaction.clear!
+ assert transaction.empty?
+ end
+end
diff --git a/bindings/ruby/tests/transaction.rb b/bindings/ruby/tests/transaction.rb
deleted file mode 100644
index 454572f..0000000
--- a/bindings/ruby/tests/transaction.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-$:.unshift "../../../build/bindings/ruby"
-require 'pathname'
-
-# test Transction
-
-require 'test/unit'
-require 'satsolver'
-
-class TransactionTest < Test::Unit::TestCase
- def test_transaction
- pool = Satsolver::Pool.new
- assert pool
- pool.arch = "i686"
- solvpath = Pathname( File.dirname( __FILE__ ) ) + Pathname( "../../testdata" ) + "os11-biarch.solv"
- repo = pool.add_solv( solvpath )
- repo.name = "test1"
-
- transaction = Satsolver::Transaction.new( pool )
- assert transaction
- transaction.install( "foo" )
- transaction.install( repo.find "ruby" )
- transaction.install( Satsolver::Relation.new( pool, "foo", Satsolver::REL_EQ, "42-7" ) )
- transaction.remove( "bar" )
- transaction.remove( repo.find "glibc" )
- transaction.remove( Satsolver::Relation.new( pool, "bar", Satsolver::REL_EQ, "42-7" ) )
- assert transaction.size == 6
- transaction.each { |a|
- cmd = case a.cmd
- when Satsolver::INSTALL_SOLVABLE: "install #{a.solvable}"
- when Satsolver::REMOVE_SOLVABLE: "remove #{a.solvable}"
- when Satsolver::INSTALL_SOLVABLE_NAME: "install by name #{a.name}"
- when Satsolver::REMOVE_SOLVABLE_NAME: "remove by name #{a.name}"
- when Satsolver::INSTALL_SOLVABLE_PROVIDES: "install by relation #{a.relation}"
- when Satsolver::REMOVE_SOLVABLE_PROVIDES: "remove by relation #{a.relation}"
- else "<NONE>"
- end
- puts cmd
- }
- transaction.clear!
- assert transaction.empty?
- end
-end
diff --git a/bindings/transaction.i b/bindings/transaction.i
deleted file mode 100644
index 1ef2d9a..0000000
--- a/bindings/transaction.i
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Document-class: Transaction
- * Transaction represents a Set of Jobs as input for the Solver.
- *
- */
-
-%{
-
-/*
- * iterating over jobs of a transaction ('yield' in Ruby)
- */
-
-static int
-transaction_jobs_iterate_callback( const Job *j )
-{
-#if defined(SWIGRUBY)
- /* FIXME: how to pass 'break' back to the caller ? */
- rb_yield(SWIG_NewPointerObj((void*) j, SWIGTYPE_p__Job, 0));
-#endif
- return 0;
-}
-
-%}
-
-
-%nodefault _Transaction;
-%rename(Transaction) _Transaction;
-typedef struct _Transaction {} Transaction;
-
-#if defined(SWIGRUBY)
-%mixin Transaction "Enumerable";
-#endif
-
-%extend Transaction {
- /*
- * Create transaction based on Pool
- *
- * See also: Pool.create_transaction
- */
- Transaction( Pool *pool )
- { return transaction_new( pool ); }
-
- ~Transaction()
- { transaction_free( $self ); }
-
- /*
- * Install request
- *
- * Ensure installation of a solvable by either
- * * specifying it directly
- * * specify it by name
- * * specify a required relation
- *
- * Except when specified directly, the solver is free to choose any
- * solvable matching the request (by name, by relation)
- *
- * call-seq:
- * transaction.install(solvable) -> void
- * transaction.install("kernel") -> void
- * transaction.install(relation) -> void
- *
- */
- void install( XSolvable *xs )
- { transaction_install_xsolvable( $self, xs ); }
-
- /*
- * Remove request
- *
- * Ensure removal of a solvable by either
- * * specifying it directly
- * * specify it by name
- * * specify a required relation
- *
- * Except when specified directly, the solver is free to choose any
- * solvable matching the request (by name, by relation)
- *
- * call-seq:
- * transaction.remove(solvable) -> void
- * transaction.remove("kernel") -> void
- * transaction.remove(relation) -> void
- *
- */
- void remove( XSolvable *xs )
- { transaction_remove_xsolvable( $self, xs ); }
-
- /*
- * Install solvable by name
- */
- void install( const char *name )
- { transaction_install_name( $self, name ); }
-
- /*
- * Remove solvable by name
- *
- */
- void remove( const char *name )
- { transaction_remove_name( $self, name ); }
-
- /*
- * Install solvable by relation
- *
- */
- void install( const Relation *rel )
- { transaction_install_relation( $self, rel ); }
-
- /*
- * Remove solvable by relation
- *
- */
- void remove( const Relation *rel )
- { return transaction_remove_relation( $self, rel ); }
-
-#if defined(SWIGRUBY)
- %rename("empty?") empty();
- %typemap(out) int empty
- "$result = $1 ? Qtrue : Qfalse;";
-#endif
- /*
- * Check if the transaction has any jobs attached.
- *
- * call-seq:
- * transaction.empty? -> bool
- *
- */
- int empty()
- { return ( $self->queue.count == 0 ); }
-
- /*
- * Return number of jobs of this transaction
- *
- */
- int size()
- { return transaction_size( $self ); }
-
-#if defined(SWIGRUBY)
- %rename("clear!") clear();
-#endif
- /*
- * Remove all jobs of this transaction
- *
- * call-seq:
- * transaction.clear! -> void
- *
- */
- void clear()
- { queue_empty( &($self->queue) ); }
-
-#if defined(SWIGRUBY)
- %alias get "[]";
-#endif
- /*
- * Get job by index
- *
- * The index is just a convenience access method and
- * does NOT imply any preference/ordering of the Jobs.
- *
- * A Transaction is always considered a set of Jobs.
- *
- * call-seq:
- * transaction.get(42) -> Job
- *
- */
- Job *get( unsigned int i )
- { return transaction_job_get( $self, i ); }
-
- /*
- * Iterate over each Job of the Transaction.
- *
- * call-seq:
- * transaction.each { |job| ... }
- *
- */
- void each()
- { transaction_jobs_iterate( $self, transaction_jobs_iterate_callback ); }
-}
-
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
ref: refs/heads/master
commit aca235b4fda8843747be30a4657e608adea8ab43
Author: Michael Schroeder <mls(a)suse.de>
Date: Thu May 14 18:27:39 2009 +0200
- add some docu
---
src/solver.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/solver.c b/src/solver.c
index 5c8f997..460432d 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -3862,6 +3862,31 @@ solver_solutionelement_count(Solver *solv, Id problem, Id solution)
return solv->solutions.elements[solidx];
}
+
+/*
+ * return the next item of the proposed solution
+ * here are the possibilities for p / rp and what
+ * the solver expects the application to do:
+ * p rp
+ * -------------------------------------------------------
+ * SOLVER_SOLUTION_INFARCH pkgid
+ * -> add (SOLVER_INSTALL|SOLVER_SOLVABLE, rp) to the job
+ * SOLVER_SOLUTION_DISTUPGRADE pkgid
+ * -> add (SOLVER_INSTALL|SOLVER_SOLVABLE, rp) to the job
+ * SOLVER_SOLUTION_JOB jobidx
+ * -> remove job (jobidx - 1, jobidx) from job queue
+ * pkgid (> 0) 0
+ * -> add (SOLVER_ERASE|SOLVER_SOLVABLE, p) to the job
+ * pkgid (> 0) pkgid (> 0)
+ * -> add (SOLVER_INSTALL|SOLVER_SOLVABLE, rp) to the job
+ * (this will replace package p)
+ *
+ * Thus, the solver will either ask the application to remove
+ * a specific job from the job queue, or ask to add an install/erase
+ * job to it.
+ *
+ */
+
Id
solver_next_solutionelement(Solver *solv, Id problem, Id solution, Id element, Id *p, Id *rp)
{
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
13 May '09
ref: refs/heads/master
commit dc9a92111f3b8652b6654975809447510391b3aa
Author: Michael Schroeder <mls(a)suse.de>
Date: Wed May 13 16:31:28 2009 +0200
- start transaction ordering
---
src/CMakeLists.txt | 5 +-
src/solver.c | 417 ++++++-------------------
src/solver.h | 28 +--
src/solverdebug.c | 56 ++---
src/transaction.c | 690 ++++++++++++++++++++++++++++++++++++++++++
src/transaction.h | 55 ++++
tests/solver/deptestomatic.c | 33 ++-
tools/CMakeLists.txt | 4 +
tools/patchcheck.c | 487 +++++++++++++++++++++++++++++
tools/repo_rpmmd.c | 4 +-
10 files changed, 1385 insertions(+), 394 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0a56baa..a74bf8c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,7 +2,8 @@
SET(libsatsolver_SRCS
bitmap.c poolarch.c poolvendor.c poolid.c strpool.c dirpool.c
solver.c solverdebug.c repo_solv.c repo_helix.c evr.c pool.c
- queue.c repo.c repodata.c repopage.c util.c policy.c solvable.c)
+ queue.c repo.c repodata.c repopage.c util.c policy.c solvable.c
+ transaction.c)
ADD_LIBRARY(satsolver STATIC ${libsatsolver_SRCS})
@@ -10,7 +11,7 @@ SET(libsatsolver_HEADERS
bitmap.h evr.h hash.h policy.h poolarch.h poolvendor.h pool.h
poolid.h pooltypes.h queue.h solvable.h solver.h solverdebug.h
repo.h repodata.h repopage.h repo_solv.h repo_helix.h util.h
- strpool.h dirpool.h knownid.h)
+ strpool.h dirpool.h knownid.h transaction.h)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
diff --git a/src/solver.c b/src/solver.c
index 2329f19..5c8f997 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -140,8 +140,6 @@ dep_possible(Solver *solv, Id dep, Map *m)
* - unify rules, remove duplicates
*/
-static Pool *unifyrules_sortcmp_data;
-
/*-------------------------------------------------------------------
*
* compare rules for unification sort
@@ -149,9 +147,9 @@ static Pool *unifyrules_sortcmp_data;
*/
static int
-unifyrules_sortcmp(const void *ap, const void *bp)
+unifyrules_sortcmp(const void *ap, const void *bp, void *dp)
{
- Pool *pool = unifyrules_sortcmp_data;
+ Pool *pool = dp;
Rule *a = (Rule *)ap;
Rule *b = (Rule *)bp;
Id *ad, *bd;
@@ -206,8 +204,7 @@ unifyrules(Solver *solv)
POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- unifyrules -----\n");
/* sort rules first */
- unifyrules_sortcmp_data = solv->pool;
- qsort(solv->rules + 1, solv->nrules - 1, sizeof(Rule), unifyrules_sortcmp);
+ sat_sort(solv->rules + 1, solv->nrules - 1, sizeof(Rule), unifyrules_sortcmp, solv->pool);
/* prune rules
* i = unpruned
@@ -216,7 +213,7 @@ unifyrules(Solver *solv)
jr = 0;
for (i = j = 1, ir = solv->rules + i; i < solv->nrules; i++, ir++)
{
- if (jr && !unifyrules_sortcmp(ir, jr))
+ if (jr && !unifyrules_sortcmp(ir, jr, pool))
continue; /* prune! */
jr = solv->rules + j++; /* keep! */
if (ir != jr)
@@ -1409,7 +1406,7 @@ addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m)
{
POOL_DEBUG(SAT_DEBUG_RULE_CREATION," %s requires %s\n", solvable2str(pool, s), dep2str(pool, req));
for (i = 0; dp[i]; i++)
- POOL_DEBUG(SAT_DEBUG_RULE_CREATION, " provided by %s\n", solvable2str(pool, pool->solvables + dp[i]));
+ POOL_DEBUG(SAT_DEBUG_RULE_CREATION, " provided by %s\n", solvid2str(pool, dp[i]));
}
/* add 'requires' dependency */
@@ -1974,9 +1971,9 @@ propagate(Solver *solv, int level)
IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
{
if (p > 0)
- POOL_DEBUG(SAT_DEBUG_PROPAGATE, " -> move w%d to %s\n", (pkg == r->w1 ? 1 : 2), solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_PROPAGATE, " -> move w%d to %s\n", (pkg == r->w1 ? 1 : 2), solvid2str(pool, p));
else
- POOL_DEBUG(SAT_DEBUG_PROPAGATE," -> move w%d to !%s\n", (pkg == r->w1 ? 1 : 2), solvable2str(pool, pool->solvables - p));
+ POOL_DEBUG(SAT_DEBUG_PROPAGATE," -> move w%d to !%s\n", (pkg == r->w1 ? 1 : 2), solvid2str(pool, -p));
}
*rp = *next_rp;
@@ -2022,11 +2019,10 @@ propagate(Solver *solv, int level)
IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
{
- Solvable *s = pool->solvables + (other_watch > 0 ? other_watch : -other_watch);
if (other_watch > 0)
- POOL_DEBUG(SAT_DEBUG_PROPAGATE, " -> decided to install %s\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_PROPAGATE, " -> decided to install %s\n", solvid2str(pool, other_watch));
else
- POOL_DEBUG(SAT_DEBUG_PROPAGATE, " -> decided to conflict %s\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_PROPAGATE, " -> decided to conflict %s\n", solvid2str(pool, -other_watch));
}
} /* foreach rule involving 'pkg' */
@@ -2572,7 +2568,7 @@ selectandinstall(Solver *solv, int level, Queue *dq, int disablerules, Id ruleid
}
p = dq->elements[0];
- POOL_DEBUG(SAT_DEBUG_POLICY, "installing %s\n", solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_POLICY, "installing %s\n", solvid2str(pool, p));
return setpropagatelearn(solv, level, p, disablerules, ruleid);
}
@@ -2675,6 +2671,7 @@ solver_free(Solver *solv)
sat_free(solv->obsoletes);
sat_free(solv->obsoletes_data);
sat_free(solv->multiversionupdaters);
+ sat_free(solv->transaction_installed);
sat_free(solv);
}
@@ -2899,7 +2896,7 @@ run_solver(Solver *solv, int disablerules, int doweak)
if (solv->decisionmap[i] == 0)
{
olevel = level;
- POOL_DEBUG(SAT_DEBUG_POLICY, "keeping %s\n", solvable2str(pool, pool->solvables + i));
+ POOL_DEBUG(SAT_DEBUG_POLICY, "keeping %s\n", solvid2str(pool, i));
level = setpropagatelearn(solv, level, i, disablerules, r - solv->rules);
if (level == 0)
{
@@ -3004,7 +3001,7 @@ run_solver(Solver *solv, int disablerules, int doweak)
queue_free(&dqs);
return;
}
- if (level < systemlevel)
+ if (level < systemlevel || level == 1)
break;
n = 0;
} /* for(), decide */
@@ -3153,9 +3150,9 @@ run_solver(Solver *solv, int disablerules, int doweak)
/* simple case, just one package. no need to choose */
p = dq.elements[0];
if (dqs.count)
- POOL_DEBUG(SAT_DEBUG_POLICY, "installing supplemented %s\n", solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_POLICY, "installing supplemented %s\n", solvid2str(pool, p));
else
- POOL_DEBUG(SAT_DEBUG_POLICY, "installing recommended %s\n", solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_POLICY, "installing recommended %s\n", solvid2str(pool, p));
queue_push(&solv->recommendations, p);
level = setpropagatelearn(solv, level, p, 0, 0);
continue;
@@ -3173,7 +3170,7 @@ run_solver(Solver *solv, int disablerules, int doweak)
p = dqs.elements[i];
if (solv->decisionmap[p] || !MAPTST(&dqmap, p))
continue;
- POOL_DEBUG(SAT_DEBUG_POLICY, "installing supplemented %s\n", solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_POLICY, "installing supplemented %s\n", solvid2str(pool, p));
queue_push(&solv->recommendations, p);
olevel = level;
level = setpropagatelearn(solv, level, p, 0, 0);
@@ -3224,7 +3221,7 @@ run_solver(Solver *solv, int disablerules, int doweak)
queue_push(&solv->branches, -level);
}
p = dq.elements[0];
- POOL_DEBUG(SAT_DEBUG_POLICY, "installing recommended %s\n", solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_POLICY, "installing recommended %s\n", solvid2str(pool, p));
queue_push(&solv->recommendations, p);
olevel = level;
level = setpropagatelearn(solv, level, p, 0, 0);
@@ -3251,7 +3248,7 @@ run_solver(Solver *solv, int disablerules, int doweak)
p = dq.elements[i];
break;
}
- POOL_DEBUG(SAT_DEBUG_POLICY, "installing recommended %s\n", solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_POLICY, "installing recommended %s\n", solvid2str(pool, p));
queue_push(&solv->recommendations, p);
level = setpropagatelearn(solv, level, p, 0, 0);
continue;
@@ -3273,12 +3270,12 @@ run_solver(Solver *solv, int disablerules, int doweak)
olevel = level;
if (solv->distupgrade_removeunsupported)
{
- POOL_DEBUG(SAT_DEBUG_STATS, "removing unsupported %s\n", solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_STATS, "removing unsupported %s\n", solvid2str(pool, p));
level = setpropagatelearn(solv, level, -p, 0, 0);
}
else
{
- POOL_DEBUG(SAT_DEBUG_STATS, "keeping unsupported %s\n", solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_STATS, "keeping unsupported %s\n", solvid2str(pool, p));
level = setpropagatelearn(solv, level, p, 0, 0);
installedone = 1;
}
@@ -3302,7 +3299,7 @@ run_solver(Solver *solv, int disablerules, int doweak)
if (solv->branches.elements[i - 1] < 0)
break;
p = solv->branches.elements[i];
- POOL_DEBUG(SAT_DEBUG_STATS, "branching with %s\n", solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_STATS, "branching with %s\n", solvid2str(pool, p));
queue_empty(&dq);
for (j = i + 1; j < solv->branches.count; j++)
queue_push(&dq, solv->branches.elements[j]);
@@ -3351,7 +3348,7 @@ run_solver(Solver *solv, int disablerules, int doweak)
/* kill old solvable so that we do not loop */
p = solv->branches.elements[lasti];
solv->branches.elements[lasti] = 0;
- POOL_DEBUG(SAT_DEBUG_STATS, "minimizing %d -> %d with %s\n", solv->decisionmap[p], lastl, solvable2str(pool, pool->solvables + p));
+ POOL_DEBUG(SAT_DEBUG_STATS, "minimizing %d -> %d with %s\n", solv->decisionmap[p], lastl, solvid2str(pool, p));
minimizationsteps++;
level = lastl;
@@ -3562,11 +3559,10 @@ refine_suggestion(Solver *solv, Queue *job, Id *problem, Id sug, Queue *refined,
* make essential job rules last
*/
-Queue *problems_sort_data;
-
static int
-problems_sortcmp(const void *ap, const void *bp)
+problems_sortcmp(const void *ap, const void *bp, void *dp)
{
+ Queue *job = dp;
Id a = *(Id *)ap, b = *(Id *)bp;
if (a < 0 && b > 0)
return 1;
@@ -3574,7 +3570,6 @@ problems_sortcmp(const void *ap, const void *bp)
return -1;
if (a < 0 && b < 0)
{
- Queue *job = problems_sort_data;
int af = job->elements[-a - 1] & SOLVER_ESSENTIAL;
int bf = job->elements[-b - 1] & SOLVER_ESSENTIAL;
int x = af - bf;
@@ -3694,6 +3689,36 @@ convertsolution(Solver *solv, Id why, Queue *solutionq)
}
/*
+ * convert problem data into a form usable for refining.
+ * Returns the number of problems.
+ */
+int
+prepare_solutions(Solver *solv)
+{
+ int i, j = 1, idx = 1;
+
+ if (!solv->problems.count)
+ return 0;
+ queue_push(&solv->solutions, 0);
+ queue_push(&solv->solutions, -1); /* unrefined */
+ for (i = 1; i < solv->problems.count; i++)
+ {
+ Id p = solv->problems.elements[i];
+ queue_push(&solv->solutions, p);
+ if (p)
+ continue;
+ solv->problems.elements[j++] = idx;
+ if (i + 1 >= solv->problems.count)
+ break;
+ solv->problems.elements[j++] = solv->problems.elements[++i]; /* copy proofidx */
+ idx = solv->solutions.count;
+ queue_push(&solv->solutions, -1);
+ }
+ solv->problems.count = j;
+ return j / 2;
+}
+
+/*
* refine the simple solution rule list provided by
* the solver into multiple lists of job modifiers.
*/
@@ -3733,9 +3758,8 @@ create_solutions(Solver *solv, int probnr, int solidx)
break;
queue_push(&problem, v);
}
- problems_sort_data = &solv->job;
if (problem.count > 1)
- qsort(problem.elements, problem.count, sizeof(Id), problems_sortcmp);
+ sat_sort(problem.elements, problem.count, sizeof(Id), problems_sortcmp, &solv->job);
queue_push(&problem, 0); /* mark end for refine_suggestion */
problem.count--;
#if 0
@@ -3926,14 +3950,13 @@ findproblemrule_internal(Solver *solv, Id idx, Id *reqrp, Id *conrp, Id *sysrp,
*sysrp = lsysr;
}
-
-/*-------------------------------------------------------------------
- *
+/*
* find problem rule
*
* search for a rule that describes the problem to the
- * user. A pretty hopeless task, actually. We currently
- * prefer simple requires.
+ * user. Actually a pretty hopeless task that may leave the user
+ * puzzled. To get all of the needed information use
+ * solver_findallproblemrules() instead.
*/
Id
@@ -3944,16 +3967,18 @@ solver_findproblemrule(Solver *solv, Id problem)
reqr = conr = sysr = jobr = 0;
findproblemrule_internal(solv, idx, &reqr, &conr, &sysr, &jobr);
if (reqr)
- return reqr;
+ return reqr; /* some requires */
if (conr)
- return conr;
+ return conr; /* some conflict */
if (sysr)
- return sysr;
+ return sysr; /* an update rule */
if (jobr)
- return jobr;
+ return jobr; /* a user request */
assert(0);
}
+/*-------------------------------------------------------------------*/
+
static void
findallproblemrules_internal(Solver *solv, Id idx, Queue *rules)
{
@@ -3969,6 +3994,14 @@ findallproblemrules_internal(Solver *solv, Id idx, Queue *rules)
}
}
+/*
+ * find all problem rule
+ *
+ * return all rules that lead to the problem. This gives the user
+ * all of the information to understand the problem, but the result
+ * can be a large number of rules.
+ */
+
void
solver_findallproblemrules(Solver *solv, Id problem, Queue *rules)
{
@@ -3981,9 +4014,10 @@ solver_findallproblemrules(Solver *solv, Id problem, Queue *rules)
*
* create reverse obsoletes map for installed solvables
*
- * for each installed solvable find which packages with *different* names
+ * For each installed solvable find which packages with *different* names
* obsolete the solvable.
- * this index is used in policy_findupdatepackages if noupdateprovide is set.
+ * This index is used in policy_findupdatepackages if noupdateprovide is
+ * set.
*/
static void
@@ -3993,11 +4027,12 @@ create_obsolete_index(Solver *solv)
Solvable *s;
Repo *installed = solv->installed;
Id p, pp, obs, *obsp, *obsoletes, *obsoletes_data;
- int i, n;
+ int i, n, cnt;
- if (!installed || !installed->nsolvables)
+ if (!installed || installed->start == installed->end)
return;
- solv->obsoletes = obsoletes = sat_calloc(installed->end - installed->start, sizeof(Id));
+ cnt = installed->end - installed->start;
+ solv->obsoletes = obsoletes = sat_calloc(cnt, sizeof(Id));
for (i = 1; i < pool->nsolvables; i++)
{
s = pool->solvables + i;
@@ -4021,7 +4056,7 @@ create_obsolete_index(Solver *solv)
}
}
n = 0;
- for (i = 0; i < installed->nsolvables; i++)
+ for (i = 0; i < cnt; i++)
if (obsoletes[i])
{
n += obsoletes[i] + 1;
@@ -4090,7 +4125,7 @@ removedisabledconflicts(Solver *solv, Queue *removed)
if (r->d < 0 && decisionmap[-p])
{
/* rule is now disabled, remove from decisionmap */
- POOL_DEBUG(SAT_DEBUG_SCHUBI, "removing conflict for package %s[%d]\n", solvable2str(pool, pool->solvables - p), -p);
+ POOL_DEBUG(SAT_DEBUG_SCHUBI, "removing conflict for package %s[%d]\n", solvid2str(pool, -p), -p);
queue_push(removed, -p);
queue_push(removed, decisionmap[-p]);
decisionmap[-p] = 0;
@@ -4153,7 +4188,7 @@ removedisabledconflicts(Solver *solv, Queue *removed)
}
if (new)
{
- POOL_DEBUG(SAT_DEBUG_SCHUBI, "re-conflicting package %s[%d]\n", solvable2str(pool, pool->solvables - new), -new);
+ POOL_DEBUG(SAT_DEBUG_SCHUBI, "re-conflicting package %s[%d]\n", solvid2str(pool, -new), -new);
decisionmap[-new] = -1;
new = 0;
n = 0; /* redo all rules */
@@ -4594,240 +4629,6 @@ findrecommendedsuggested(Solver *solv)
}
-Solver *obsq_sortcmp_data;
-
-static int
-obsq_sortcmp(const void *ap, const void *bp)
-{
- Id a, b, oa, ob;
- Solver *solv = obsq_sortcmp_data;
- Pool *pool = solv->pool;
- Solvable *s, *oas, *obs;
- int r;
-
- a = ((Id *)ap)[0];
- oa = ((Id *)ap)[1];
- b = ((Id *)bp)[0];
- ob = ((Id *)bp)[1];
- if (a != b)
- return a - b;
- if (oa == ob)
- return 0;
- s = pool->solvables + a;
- oas = pool->solvables + oa;
- obs = pool->solvables + ob;
- if (oas->name != obs->name)
- {
- if (oas->name == s->name)
- return -1;
- if (obs->name == s->name)
- return 1;
- return strcmp(id2str(pool, oas->name), id2str(pool, obs->name));
- }
- r = evrcmp(pool, oas->evr, obs->evr, EVRCMP_COMPARE);
- if (r)
- return -r; /* highest version first */
- return oa - ob;
-}
-
-void
-solver_transaction_info(Solver *solv, Id p, Queue *out)
-{
- Pool *pool = solv->pool;
- Solvable *s = pool->solvables + p;
- Queue *ti = &solv->transaction_info;
- int i;
-
- queue_empty(out);
- if (p <= 0 || !s->repo)
- return;
- if (s->repo == solv->installed)
- {
- /* find which packages obsolete us */
- for (i = 0; i < ti->count; i += 2)
- if (ti->elements[i + 1] == p)
- {
- queue_push(out, p);
- queue_push(out, ti->elements[i]);
- }
- if (out->count > 2)
- {
- /* sort obsoleters */
- obsq_sortcmp_data = solv;
- qsort(out->elements, out->count / 2, 2 * sizeof(Id), obsq_sortcmp);
- }
- for (i = 0; i < out->count; i += 2)
- out->elements[i] = out->elements[i / 2 + 1];
- out->count /= 2;
- }
- else
- {
- /* find the packages we obsolete */
- for (i = 0; i < ti->count; i += 2)
- {
- if (ti->elements[i] == p)
- queue_push(out, ti->elements[i + 1]);
- else if (out->count)
- break;
- }
- }
-}
-
-Id
-solver_transaction_pkg(Solver *solv, Id p)
-{
- Queue ti;
- Id tibuf[5];
-
- queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
- solver_transaction_info(solv, p, &ti);
- p = ti.count ? ti.elements[0] : 0;
- queue_free(&ti);
- return p;
-}
-
-static void
-create_transaction(Solver *solv)
-{
- Pool *pool = solv->pool;
- Repo *installed = solv->installed;
- Queue *ti = &solv->transaction_info;
- int i, j, r, noobs;
- Id p, p2, pp2;
- Solvable *s, *s2;
-
- queue_empty(&solv->transaction);
- queue_empty(ti);
-
- /* first create obsoletes index */
- if (installed)
- {
- for (i = 0; i < solv->decisionq.count; i++)
- {
- p = solv->decisionq.elements[i];
- if (p <= 0 || p == SYSTEMSOLVABLE)
- continue;
- s = pool->solvables + p;
- if (s->repo == installed)
- continue;
- noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p);
- FOR_PROVIDES(p2, pp2, s->name)
- {
- if (solv->decisionmap[p2] > 0)
- continue;
- s2 = pool->solvables + p2;
- if (s2->repo != installed)
- continue;
- if (noobs && (s->name != s2->name || s->evr != s2->evr || s->arch != s2->arch))
- continue;
- if (!solv->implicitobsoleteusesprovides && s->name != s2->name)
- continue;
- queue_push(ti, p);
- queue_push(ti, p2);
- }
- if (s->obsoletes && !noobs)
- {
- Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
- while ((obs = *obsp++) != 0)
- {
- FOR_PROVIDES(p2, pp2, obs)
- {
- s2 = pool->solvables + p2;
- if (s2->repo != installed)
- continue;
- if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p2, obs))
- continue;
- queue_push(ti, p);
- queue_push(ti, p2);
- }
- }
- }
- }
- obsq_sortcmp_data = solv;
- qsort(ti->elements, ti->count / 2, 2 * sizeof(Id), obsq_sortcmp);
- /* now unify */
- for (i = j = 0; i < ti->count; i += 2)
- {
- if (j && ti->elements[i] == ti->elements[j - 2] && ti->elements[i + 1] == ti->elements[j - 1])
- continue;
- ti->elements[j++] = ti->elements[i];
- ti->elements[j++] = ti->elements[i + 1];
- }
- ti->count = j;
- }
-
- if (installed)
- {
- FOR_REPO_SOLVABLES(installed, p, s)
- {
- if (solv->decisionmap[p] > 0)
- continue;
- p2 = solver_transaction_pkg(solv, p);
- if (!p2)
- queue_push(&solv->transaction, SOLVER_TRANSACTION_ERASE);
- else
- {
- s2 = pool->solvables + p2;
- if (s->name == s2->name)
- {
- if (s->evr == s2->evr && solvable_identical(s, s2))
- queue_push(&solv->transaction, SOLVER_TRANSACTION_REINSTALLED);
- else
- {
- r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
- if (r < 0)
- queue_push(&solv->transaction, SOLVER_TRANSACTION_UPGRADED);
- else if (r > 0)
- queue_push(&solv->transaction, SOLVER_TRANSACTION_DOWNGRADED);
- else
- queue_push(&solv->transaction, SOLVER_TRANSACTION_CHANGED);
- }
- }
- else
- queue_push(&solv->transaction, SOLVER_TRANSACTION_OBSOLETED);
- }
- queue_push(&solv->transaction, p);
- }
- }
- for (i = 0; i < solv->decisionq.count; i++)
- {
- p = solv->decisionq.elements[i];
- if (p < 0 || p == SYSTEMSOLVABLE)
- continue;
- s = pool->solvables + p;
- if (solv->installed && s->repo == solv->installed)
- continue;
- noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p);
- p2 = solver_transaction_pkg(solv, p);
- if (noobs)
- queue_push(&solv->transaction, p2 ? SOLVER_TRANSACTION_MULTIREINSTALL : SOLVER_TRANSACTION_MULTIINSTALL);
- else if (!p2)
- queue_push(&solv->transaction, SOLVER_TRANSACTION_INSTALL);
- else
- {
- s2 = pool->solvables + p2;
- if (s->name == s2->name)
- {
- if (s->evr == s2->evr && solvable_identical(s, s2))
- queue_push(&solv->transaction, SOLVER_TRANSACTION_REINSTALL);
- else
- {
- r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
- if (r > 0)
- queue_push(&solv->transaction, SOLVER_TRANSACTION_UPGRADE);
- else if (r < 0)
- queue_push(&solv->transaction, SOLVER_TRANSACTION_DOWNGRADE);
- else
- queue_push(&solv->transaction, SOLVER_TRANSACTION_CHANGE);
- }
- }
- else
- queue_push(&solv->transaction, SOLVER_TRANSACTION_RENAME);
- }
- queue_push(&solv->transaction, p);
- }
-}
-
/*
*
* solve job queue
@@ -5072,8 +4873,7 @@ solver_solve(Solver *solv, Queue *job)
assert(solv->distupgrade && !sr->p);
continue;
}
- unifyrules_sortcmp_data = pool;
- if (!unifyrules_sortcmp(r, sr))
+ if (!unifyrules_sortcmp(r, sr, pool))
{
/* identical rule, kill unneeded one */
if (solv->allowuninstall)
@@ -5259,10 +5059,10 @@ solver_solve(Solver *solv, Queue *job)
solv->duprules = solv->duprules_end = solv->nrules;
- /* all rules created
- * --------------------------------------------------------------
- * prepare for solving
- */
+ /* all rules created
+ * --------------------------------------------------------------
+ * prepare for solving
+ */
/* free unneeded memory */
map_free(&addedmap);
@@ -5315,33 +5115,14 @@ solver_solve(Solver *solv, Queue *job)
findrecommendedsuggested(solv);
/*
- * if unsolvable, prepare solution queue
+ * prepare solution queue if there were problems
*/
- if (solv->problems.count)
- {
- int j = 1, idx = 1;
- queue_push(&solv->solutions, 0);
- queue_push(&solv->solutions, -1); /* unrefined */
- for (i = 1; i < solv->problems.count; i++)
- {
- Id p = solv->problems.elements[i];
- queue_push(&solv->solutions, p);
- if (p)
- continue;
- solv->problems.elements[j++] = idx;
- if (i + 1 >= solv->problems.count)
- break;
- solv->problems.elements[j++] = solv->problems.elements[++i]; /* copy proofidx */
- idx = solv->solutions.count;
- queue_push(&solv->solutions, -1);
- }
- solv->problems.count = j;
- }
+ prepare_solutions(solv);
/*
* finally prepare transaction info
*/
- create_transaction(solv);
+ solver_create_transaction(solv);
POOL_DEBUG(SAT_DEBUG_STATS, "final solver statistics: %d problems, %d learned rules, %d unsolvable\n", solv->problems.count / 2, solv->stats_learned, solv->stats_unsolvable);
POOL_DEBUG(SAT_DEBUG_STATS, "solver_solve took %d ms\n", sat_timems(solve_start));
@@ -5465,7 +5246,7 @@ solver_find_involved(Solver *solv, Queue *installedq, Solvable *ts, Queue *q)
if (MAPTST(&im, p))
{
#if FIND_INVOLVED_DEBUG
- printf("%s requires %s\n", solvable2str(pool, pool->solvables + ip), solvable2str(pool, pool->solvables + p));
+ printf("%s requires %s\n", solvid2str(pool, ip), solvid2str(pool, p));
#endif
queue_push(&iq, p);
}
@@ -5488,7 +5269,7 @@ solver_find_involved(Solver *solv, Queue *installedq, Solvable *ts, Queue *q)
if (MAPTST(&im, p))
{
#if FIND_INVOLVED_DEBUG
- printf("%s recommends %s\n", solvable2str(pool, pool->solvables + ip), solvable2str(pool, pool->solvables + p));
+ printf("%s recommends %s\n", solvid2str(pool, ip), solvid2str(pool, p));
#endif
queue_push(&iq, p);
}
@@ -5514,7 +5295,7 @@ solver_find_involved(Solver *solv, Queue *installedq, Solvable *ts, Queue *q)
if (sup)
{
#if FIND_INVOLVED_DEBUG
- printf("%s supplemented\n", solvable2str(pool, pool->solvables + ip));
+ printf("%s supplemented\n", solvid2str(pool, ip));
#endif
queue_push(&iq, ip);
}
@@ -5550,7 +5331,7 @@ solver_find_involved(Solver *solv, Queue *installedq, Solvable *ts, Queue *q)
if (p == tp)
continue;
#if FIND_INVOLVED_DEBUG
- printf("%s requires %s\n", solvable2str(pool, pool->solvables + ip), solvable2str(pool, pool->solvables + p));
+ printf("%s requires %s\n", solvid2str(pool, ip), solvid2str(pool, p));
#endif
MAPSET(&im, p);
queue_push(&iq, p);
@@ -5570,7 +5351,7 @@ solver_find_involved(Solver *solv, Queue *installedq, Solvable *ts, Queue *q)
if (p == tp)
continue;
#if FIND_INVOLVED_DEBUG
- printf("%s recommends %s\n", solvable2str(pool, pool->solvables + ip), solvable2str(pool, pool->solvables + p));
+ printf("%s recommends %s\n", solvid2str(pool, ip), solvid2str(pool, p));
#endif
MAPSET(&im, p);
queue_push(&iq, p);
@@ -5598,7 +5379,7 @@ solver_find_involved(Solver *solv, Queue *installedq, Solvable *ts, Queue *q)
if (sup)
{
#if FIND_INVOLVED_DEBUG
- printf("%s supplemented\n", solvable2str(pool, pool->solvables + ip));
+ printf("%s supplemented\n", solvid2str(pool, ip));
#endif
MAPSET(&im, ip);
queue_push(&iq, ip);
@@ -5707,7 +5488,7 @@ addrpmruleinfo(Solver *solv, Id p, Id d, int type, Id dep)
}
static int
-solver_allruleinfos_cmp(const void *ap, const void *bp)
+solver_allruleinfos_cmp(const void *ap, const void *bp, void *dp)
{
const Id *a = ap, *b = bp;
int r;
@@ -5758,7 +5539,7 @@ solver_allruleinfos(Solver *solv, Id rid, Queue *rq)
/* now sort & unify em */
if (!rq->count)
return 0;
- qsort(rq->elements, rq->count / 4, 4 * sizeof(Id), solver_allruleinfos_cmp);
+ sat_sort(rq->elements, rq->count / 4, 4 * sizeof(Id), solver_allruleinfos_cmp, 0);
/* throw out identical entries */
for (i = j = 0; i < rq->count; i += 4)
{
diff --git a/src/solver.h b/src/solver.h
index c271591..5330d3a 100644
--- a/src/solver.h
+++ b/src/solver.h
@@ -22,6 +22,7 @@ extern "C" {
#include "repo.h"
#include "queue.h"
#include "bitmap.h"
+#include "transaction.h"
/*
* Callback definitions in order to "overwrite" the policies by an external application.
*/
@@ -57,14 +58,15 @@ typedef struct rule {
Id n1, n2; /* next rules in linked list, corresponding to w1,w2 */
} Rule;
-struct solver;
+struct _Solver;
-typedef struct solver {
+typedef struct _Solver {
Pool *pool;
Queue job; /* copy of the job we're solving */
Queue transaction; /* solver result */
Queue transaction_info; /* transaction obsoletes info */
+ Id *transaction_installed; /* data for installed packages */
Repo *installed; /* copy of pool->installed */
@@ -130,7 +132,7 @@ typedef struct solver {
Queue learnt_pool;
Queue branches;
- int (*solution_callback)(struct solver *solv, void *data);
+ int (*solution_callback)(struct _Solver *solv, void *data);
void *solution_callback_data;
int propagate_index; /* index into decisionq for non-propagated decisions */
@@ -328,29 +330,9 @@ typedef enum {
#define SOLVER_SOLUTION_DISTUPGRADE (-1)
#define SOLVER_SOLUTION_INFARCH (-2)
-#define SOLVER_TRANSACTION_ERASE 0x10
-#define SOLVER_TRANSACTION_REINSTALLED 0x11
-#define SOLVER_TRANSACTION_DOWNGRADED 0x12
-#define SOLVER_TRANSACTION_CHANGED 0x13
-#define SOLVER_TRANSACTION_UPGRADED 0x14
-#define SOLVER_TRANSACTION_OBSOLETED 0x15
-
-#define SOLVER_TRANSACTION_INSTALL 0x20
-#define SOLVER_TRANSACTION_REINSTALL 0x21
-#define SOLVER_TRANSACTION_DOWNGRADE 0x22
-#define SOLVER_TRANSACTION_CHANGE 0x23
-#define SOLVER_TRANSACTION_UPGRADE 0x24
-#define SOLVER_TRANSACTION_RENAME 0x25
-
-#define SOLVER_TRANSACTION_MULTIINSTALL 0x30
-#define SOLVER_TRANSACTION_MULTIREINSTALL 0x31
-
-
extern Solver *solver_create(Pool *pool);
extern void solver_free(Solver *solv);
extern void solver_solve(Solver *solv, Queue *job);
-extern void solver_transaction_info(Solver *solv, Id p, Queue *info);
-extern Id solver_transaction_pkg(Solver *solv, Id p);
extern int solver_dep_installed(Solver *solv, Id dep);
extern int solver_splitprovides(Solver *solv, Id dep);
diff --git a/src/solverdebug.c b/src/solverdebug.c
index 1b74e1e..6bfc2a3 100644
--- a/src/solverdebug.c
+++ b/src/solverdebug.c
@@ -297,7 +297,7 @@ solver_printdecisions(Solver *solv)
POOL_DEBUG(SAT_DEBUG_RESULT, " change %s", solvable2str(pool, s));
break;
case SOLVER_TRANSACTION_UPGRADE:
- case SOLVER_TRANSACTION_RENAME:
+ case SOLVER_TRANSACTION_REPLACE:
POOL_DEBUG(SAT_DEBUG_RESULT, " upgrade %s", solvable2str(pool, s));
break;
case SOLVER_TRANSACTION_ERASE:
@@ -316,13 +316,13 @@ solver_printdecisions(Solver *solv)
case SOLVER_TRANSACTION_DOWNGRADE:
case SOLVER_TRANSACTION_CHANGE:
case SOLVER_TRANSACTION_UPGRADE:
- case SOLVER_TRANSACTION_RENAME:
- solver_transaction_info(solv, solv->transaction.elements[i + 1], &iq);
+ case SOLVER_TRANSACTION_REPLACE:
+ solver_transaction_all_pkgs(solv, solv->transaction.elements[i + 1], &iq);
if (iq.count)
{
POOL_DEBUG(SAT_DEBUG_RESULT, " (obsoletes");
for (j = 0; j < iq.count; j++)
- POOL_DEBUG(SAT_DEBUG_RESULT, " %s", solvable2str(pool, pool->solvables + iq.elements[j]));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " %s", solvid2str(pool, iq.elements[j]));
POOL_DEBUG(SAT_DEBUG_RESULT, ")");
}
POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
@@ -393,22 +393,18 @@ solver_printprobleminfo(Solver *solv, Queue *job, Id problem)
Pool *pool = solv->pool;
Id probr;
Id dep, source, target;
- Solvable *s, *s2;
probr = solver_findproblemrule(solv, problem);
switch (solver_problemruleinfo(solv, job, probr, &dep, &source, &target))
{
case SOLVER_RULE_DISTUPGRADE:
- s = pool_id2solvable(pool, source);
- POOL_DEBUG(SAT_DEBUG_RESULT, "%s does not belong to a distupgrade repository\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "%s does not belong to a distupgrade repository\n", solvid2str(pool, source));
return;
case SOLVER_RULE_INFARCH:
- s = pool_id2solvable(pool, source);
- POOL_DEBUG(SAT_DEBUG_RESULT, "%s has inferior architecture\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "%s has inferior architecture\n", solvid2str(pool, source));
return;
case SOLVER_RULE_UPDATE:
- s = pool_id2solvable(pool, source);
- POOL_DEBUG(SAT_DEBUG_RESULT, "problem with installed package %s\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "problem with installed package %s\n", solvid2str(pool, source));
return;
case SOLVER_RULE_JOB:
POOL_DEBUG(SAT_DEBUG_RESULT, "conflicting requests\n");
@@ -420,40 +416,28 @@ solver_printprobleminfo(Solver *solv, Queue *job, Id problem)
POOL_DEBUG(SAT_DEBUG_RESULT, "some dependency problem\n");
return;
case SOLVER_RULE_RPM_NOT_INSTALLABLE:
- s = pool_id2solvable(pool, source);
- POOL_DEBUG(SAT_DEBUG_RESULT, "package %s is not installable\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "package %s is not installable\n", solvid2str(pool, source));
return;
case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
- s = pool_id2solvable(pool, source);
- POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides %s needed by %s\n", dep2str(pool, dep), solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides %s needed by %s\n", dep2str(pool, dep), solvid2str(pool, source));
return;
case SOLVER_RULE_RPM_SAME_NAME:
- s = pool_id2solvable(pool, source);
- s2 = pool_id2solvable(pool, target);
- POOL_DEBUG(SAT_DEBUG_RESULT, "cannot install both %s and %s\n", solvable2str(pool, s), solvable2str(pool, s2));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "cannot install both %s and %s\n", solvid2str(pool, source), solvid2str(pool, target));
return;
case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
- s = pool_id2solvable(pool, source);
- s2 = pool_id2solvable(pool, target);
- POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by %s\n", solvid2str(pool, source), dep2str(pool, dep), solvid2str(pool, target));
return;
case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
- s = pool_id2solvable(pool, source);
- s2 = pool_id2solvable(pool, target);
- POOL_DEBUG(SAT_DEBUG_RESULT, "package %s obsoletes %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "package %s obsoletes %s provided by %s\n", solvid2str(pool, source), dep2str(pool, dep), solvid2str(pool, target));
return;
case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
- s = pool_id2solvable(pool, source);
- s2 = pool_id2solvable(pool, target);
- POOL_DEBUG(SAT_DEBUG_RESULT, "package %s implicitely obsoletes %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "package %s implicitely obsoletes %s provided by %s\n", solvid2str(pool, source), dep2str(pool, dep), solvid2str(pool, target));
return;
case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
- s = pool_id2solvable(pool, source);
- POOL_DEBUG(SAT_DEBUG_RESULT, "package %s requires %s, but none of the providers can be installed\n", solvable2str(pool, s), dep2str(pool, dep));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "package %s requires %s, but none of the providers can be installed\n", solvid2str(pool, source), dep2str(pool, dep));
return;
case SOLVER_RULE_RPM_SELF_CONFLICT:
- s = pool_id2solvable(pool, source);
- POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by itself\n", solvable2str(pool, s), dep2str(pool, dep));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by itself\n", solvid2str(pool, source), dep2str(pool, dep));
return;
case SOLVER_RULE_UNKNOWN:
case SOLVER_RULE_FEATURE:
@@ -497,7 +481,7 @@ solver_printsolutions(Solver *solv, Queue *job)
{
case SOLVER_INSTALL:
if (select == SOLVER_SOLVABLE && solv->installed && pool->solvables[what].repo == solv->installed)
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not keep %s installed\n", solvable2str(pool, pool->solvables + what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "- do not keep %s installed\n", solvid2str(pool, what));
else if (select == SOLVER_SOLVABLE_PROVIDES)
POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install a solvable %s\n", solver_select2str(solv, select, what));
else
@@ -505,7 +489,7 @@ solver_printsolutions(Solver *solv, Queue *job)
break;
case SOLVER_ERASE:
if (select == SOLVER_SOLVABLE && !(solv->installed && pool->solvables[what].repo == solv->installed))
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not forbid installation of %s\n", solvable2str(pool, pool->solvables + what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, "- do not forbid installation of %s\n", solvid2str(pool, what));
else if (select == SOLVER_SOLVABLE_PROVIDES)
POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall all solvables %s\n", solver_select2str(solv, select, what));
else
@@ -610,7 +594,7 @@ solver_printtrivial(Solver *solv)
solver_trivial_installable(solv, &in, &out);
POOL_DEBUG(SAT_DEBUG_RESULT, "trivial installable status:\n");
for (i = 0; i < in.count; i++)
- POOL_DEBUG(SAT_DEBUG_RESULT, " %s: %d\n", solvable2str(pool, pool->solvables + in.elements[i]), out.elements[i]);
+ POOL_DEBUG(SAT_DEBUG_RESULT, " %s: %d\n", solvid2str(pool, in.elements[i]), out.elements[i]);
POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
queue_free(&in);
queue_free(&out);
@@ -623,7 +607,7 @@ solver_select2str(Solver *solv, Id select, Id what)
const char *s;
char *b;
if (select == SOLVER_SOLVABLE)
- return solvable2str(pool, pool->solvables + what);
+ return solvid2str(pool, what);
if (select == SOLVER_SOLVABLE_NAME)
return dep2str(pool, what);
if (select == SOLVER_SOLVABLE_PROVIDES)
@@ -640,7 +624,7 @@ solver_select2str(Solver *solv, Id select, Id what)
b = "";
while ((p = pool->whatprovidesdata[what++]) != 0)
{
- s = solvable2str(pool, pool->solvables + p);
+ s = solvid2str(pool, p);
b2 = pool_alloctmpspace(pool, strlen(b) + strlen(s) + 3);
sprintf(b2, "%s, %s", b, s);
b = b2;
diff --git a/src/transaction.c b/src/transaction.c
new file mode 100644
index 0000000..cf682f3
--- /dev/null
+++ b/src/transaction.c
@@ -0,0 +1,690 @@
+/*
+ * Copyright (c) 2007-2009, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+/*
+ * transaction.c
+ *
+ * Transaction handling
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <assert.h>
+
+#include "transaction.h"
+#include "solver.h"
+#include "bitmap.h"
+#include "pool.h"
+#include "evr.h"
+#include "util.h"
+
+static int
+obsq_sortcmp(const void *ap, const void *bp, void *dp)
+{
+ Id a, b, oa, ob;
+ Pool *pool = dp;
+ Solvable *s, *oas, *obs;
+ int r;
+
+ a = ((Id *)ap)[0];
+ oa = ((Id *)ap)[1];
+ b = ((Id *)bp)[0];
+ ob = ((Id *)bp)[1];
+ if (a != b)
+ return a - b;
+ if (oa == ob)
+ return 0;
+ s = pool->solvables + a;
+ oas = pool->solvables + oa;
+ obs = pool->solvables + ob;
+ if (oas->name != obs->name)
+ {
+ if (oas->name == s->name)
+ return -1;
+ if (obs->name == s->name)
+ return 1;
+ return strcmp(id2str(pool, oas->name), id2str(pool, obs->name));
+ }
+ r = evrcmp(pool, oas->evr, obs->evr, EVRCMP_COMPARE);
+ if (r)
+ return -r; /* highest version first */
+ return oa - ob;
+}
+
+void
+solver_transaction_all_pkgs(Solver *solv, Id p, Queue *pkgs)
+{
+ Pool *pool = solv->pool;
+ Solvable *s = pool->solvables + p;
+ Queue *ti = &solv->transaction_info;
+ Id q;
+ int i;
+
+ queue_empty(pkgs);
+ if (p <= 0 || !s->repo)
+ return;
+ if (s->repo == solv->installed)
+ {
+ q = solv->transaction_installed[p - solv->installed->start];
+ if (!q)
+ return;
+ if (q > 0)
+ {
+ queue_push(pkgs, q);
+ return;
+ }
+ /* find which packages obsolete us */
+ for (i = 0; i < ti->count; i += 2)
+ if (ti->elements[i + 1] == p)
+ {
+ queue_push(pkgs, p);
+ queue_push(pkgs, ti->elements[i]);
+ }
+ /* sort obsoleters */
+ if (pkgs->count > 2)
+ sat_sort(pkgs->elements, pkgs->count / 2, 2 * sizeof(Id), obsq_sortcmp, pool);
+ for (i = 0; i < pkgs->count; i += 2)
+ pkgs->elements[i / 2] = pkgs->elements[i + 1];
+ pkgs->count /= 2;
+ }
+ else
+ {
+ /* find the packages we obsolete */
+ for (i = 0; i < ti->count; i += 2)
+ {
+ if (ti->elements[i] == p)
+ queue_push(pkgs, ti->elements[i + 1]);
+ else if (pkgs->count)
+ break;
+ }
+ }
+}
+
+Id
+solver_transaction_pkg(Solver *solv, Id p)
+{
+ Pool *pool = solv->pool;
+ Solvable *s = pool->solvables + p;
+ Queue ti;
+ Id tibuf[5];
+
+ if (p <= 0 || !s->repo)
+ return 0;
+ if (s->repo == solv->installed)
+ {
+ p = solv->transaction_installed[p - solv->installed->start];
+ return p < 0 ? -p : p;
+ }
+ queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
+ solver_transaction_all_pkgs(solv, p, &ti);
+ p = ti.count ? ti.elements[0] : 0;
+ queue_free(&ti);
+ return p;
+}
+
+/* type filtering, needed if either not all packages are shown
+ * or replaces are not shown, as otherwise parts of the
+ * transaction might not be shown to the user */
+
+Id
+solver_transaction_filter(Solver *solv, Id type, Id p, int flags)
+{
+ Pool *pool = solv->pool;
+ Solvable *s = pool->solvables + p;
+ Queue oq, rq;
+ Id q;
+ int i, j, ref = 0;
+
+ if (type == SOLVER_TRANSACTION_ERASE || type == SOLVER_TRANSACTION_INSTALL || type == SOLVER_TRANSACTION_MULTIINSTALL)
+ return type;
+
+ if (s->repo == pool->installed && (flags & SOLVER_TRANSACTION_SHOW_ACTIVE) == 0)
+ {
+ /* erase element */
+ if ((flags & SOLVER_TRANSACTION_SHOW_REPLACES) == 0 && type == SOLVER_TRANSACTION_REPLACED)
+ type = SOLVER_TRANSACTION_ERASE;
+ return type;
+ }
+ if (s->repo != pool->installed && (flags & SOLVER_TRANSACTION_SHOW_ACTIVE) != 0)
+ {
+ if ((flags & SOLVER_TRANSACTION_SHOW_REPLACES) == 0 && type == SOLVER_TRANSACTION_REPLACE)
+ type = SOLVER_TRANSACTION_INSTALL;
+ return type;
+ }
+
+ /* most of the time there's only one reference, so check it first */
+ q = solver_transaction_pkg(solv, p);
+ if ((flags & SOLVER_TRANSACTION_SHOW_REPLACES) == 0)
+ {
+ Solvable *sq = pool->solvables + q;
+ if (sq->name != s->name)
+ {
+ if (s->repo == pool->installed)
+ return SOLVER_TRANSACTION_ERASE;
+ else if (type == SOLVER_TRANSACTION_MULTIREINSTALL)
+ return SOLVER_TRANSACTION_MULTIINSTALL;
+ else
+ return SOLVER_TRANSACTION_INSTALL;
+ }
+ }
+ if (solver_transaction_pkg(solv, q) == p)
+ return type;
+
+ /* too bad, a miss. check em all */
+ queue_init(&oq);
+ queue_init(&rq);
+ solver_transaction_all_pkgs(solv, p, &oq);
+ for (i = 0; i < oq.count; i++)
+ {
+ q = oq.elements[i];
+ if ((flags & SOLVER_TRANSACTION_SHOW_REPLACES) == 0)
+ {
+ Solvable *sq = pool->solvables + q;
+ if (sq->name != s->name)
+ continue;
+ }
+ /* check if we are referenced? */
+ if ((flags & SOLVER_TRANSACTION_SHOW_ALL) != 0)
+ {
+ solver_transaction_all_pkgs(solv, q, &rq);
+ for (j = 0; j < rq.count; j++)
+ if (rq.elements[j] == p)
+ {
+ ref = 1;
+ break;
+ }
+ if (ref)
+ break;
+ }
+ else if (solver_transaction_pkg(solv, q) == p)
+ {
+ ref = 1;
+ break;
+ }
+ }
+ queue_free(&oq);
+ queue_free(&rq);
+
+ if (!ref)
+ {
+ if (s->repo == pool->installed)
+ type = SOLVER_TRANSACTION_ERASE;
+ else if (type == SOLVER_TRANSACTION_MULTIREINSTALL)
+ type = SOLVER_TRANSACTION_MULTIINSTALL;
+ else
+ type = SOLVER_TRANSACTION_INSTALL;
+ }
+ return type;
+}
+
+static void
+create_transaction_info(Solver *solv)
+{
+ Pool *pool = solv->pool;
+ Queue *ti = &solv->transaction_info;
+ Repo *installed = solv->installed;
+ int i, j, noobs;
+ Id p, p2, pp2;
+ Solvable *s, *s2;
+
+ queue_empty(ti);
+ if (!installed)
+ return; /* no info needed */
+ for (i = 0; i < solv->decisionq.count; i++)
+ {
+ p = solv->decisionq.elements[i];
+ if (p <= 0 || p == SYSTEMSOLVABLE)
+ continue;
+ s = pool->solvables + p;
+ if (s->repo == installed)
+ continue;
+ noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p);
+ FOR_PROVIDES(p2, pp2, s->name)
+ {
+ if (solv->decisionmap[p2] > 0)
+ continue;
+ s2 = pool->solvables + p2;
+ if (s2->repo != installed)
+ continue;
+ if (noobs && (s->name != s2->name || s->evr != s2->evr || s->arch != s2->arch))
+ continue;
+ if (!solv->implicitobsoleteusesprovides && s->name != s2->name)
+ continue;
+ queue_push(ti, p);
+ queue_push(ti, p2);
+ }
+ if (s->obsoletes && !noobs)
+ {
+ Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
+ while ((obs = *obsp++) != 0)
+ {
+ FOR_PROVIDES(p2, pp2, obs)
+ {
+ s2 = pool->solvables + p2;
+ if (s2->repo != installed)
+ continue;
+ if (!solv->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p2, obs))
+ continue;
+ queue_push(ti, p);
+ queue_push(ti, p2);
+ }
+ }
+ }
+ }
+ sat_sort(ti->elements, ti->count / 2, 2 * sizeof(Id), obsq_sortcmp, pool);
+ /* now unify */
+ for (i = j = 0; i < ti->count; i += 2)
+ {
+ if (j && ti->elements[i] == ti->elements[j - 2] && ti->elements[i + 1] == ti->elements[j - 1])
+ continue;
+ ti->elements[j++] = ti->elements[i];
+ ti->elements[j++] = ti->elements[i + 1];
+ }
+ ti->count = j;
+
+ /* create transaction_installed helper */
+ solv->transaction_installed = sat_calloc(installed->end - installed->start, sizeof(Id));
+ for (i = 0; i < ti->count; i += 2)
+ {
+ j = ti->elements[i + 1] - installed->start;
+ if (!solv->transaction_installed[j])
+ solv->transaction_installed[j] = ti->elements[i];
+ else
+ {
+ /* more than one package obsoletes us. compare */
+ Id q[4];
+ if (solv->transaction_installed[j] > 0)
+ solv->transaction_installed[j] = -solv->transaction_installed[j];
+ q[0] = q[2] = ti->elements[i + 1];
+ q[1] = ti->elements[i];
+ q[3] = -solv->transaction_installed[j];
+ if (obsq_sortcmp(q, q + 2, pool) < 0)
+ solv->transaction_installed[j] = -ti->elements[i];
+ }
+ }
+}
+
+
+void
+solver_create_transaction(Solver *solv)
+{
+ Pool *pool = solv->pool;
+ Repo *installed = solv->installed;
+ int i, r, noobs;
+ Id p, p2;
+ Solvable *s, *s2;
+
+ queue_empty(&solv->transaction);
+ create_transaction_info(solv);
+
+ if (installed)
+ {
+ FOR_REPO_SOLVABLES(installed, p, s)
+ {
+ if (solv->decisionmap[p] > 0)
+ continue;
+ p2 = solver_transaction_pkg(solv, p);
+ if (!p2)
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_ERASE);
+ else
+ {
+ s2 = pool->solvables + p2;
+ if (s->name == s2->name)
+ {
+ if (s->evr == s2->evr && solvable_identical(s, s2))
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_REINSTALLED);
+ else
+ {
+ r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
+ if (r < 0)
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_UPGRADED);
+ else if (r > 0)
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_DOWNGRADED);
+ else
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_CHANGED);
+ }
+ }
+ else
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_REPLACED);
+ }
+ queue_push(&solv->transaction, p);
+ }
+ }
+ for (i = 0; i < solv->decisionq.count; i++)
+ {
+ p = solv->decisionq.elements[i];
+ if (p < 0 || p == SYSTEMSOLVABLE)
+ continue;
+ s = pool->solvables + p;
+ if (solv->installed && s->repo == solv->installed)
+ continue;
+ noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p);
+ p2 = solver_transaction_pkg(solv, p);
+ if (noobs)
+ queue_push(&solv->transaction, p2 ? SOLVER_TRANSACTION_MULTIREINSTALL : SOLVER_TRANSACTION_MULTIINSTALL);
+ else if (!p2)
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_INSTALL);
+ else
+ {
+ s2 = pool->solvables + p2;
+ if (s->name == s2->name)
+ {
+ if (s->evr == s2->evr && solvable_identical(s, s2))
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_REINSTALL);
+ else
+ {
+ r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
+ if (r > 0)
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_UPGRADE);
+ else if (r < 0)
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_DOWNGRADE);
+ else
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_CHANGE);
+ }
+ }
+ else
+ queue_push(&solv->transaction, SOLVER_TRANSACTION_REPLACE);
+ }
+ queue_push(&solv->transaction, p);
+ }
+}
+
+#define TYPE_REQ (1<<0)
+#define TYPE_PREREQ (1<<1)
+#define TYPE_CON (1<<2)
+#define TYPE_ERASE (1<<3)
+
+#define EDGEDATA_BLOCK 127
+
+struct transel {
+ Id p;
+ Id edges;
+};
+
+struct orderdata {
+ Solver *solv;
+ struct transel *tes;
+ int ntes;
+ Id *edgedata;
+ int nedgedata;
+};
+
+static void
+addedge(struct orderdata *od, Id from, Id to, int type)
+{
+ Solver *solv = od->solv;
+ Pool *pool = solv->pool;
+ Solvable *s;
+ struct transel *te;
+ int i;
+
+ // printf("addedge %d %d type %d\n", from, to, type);
+ s = pool->solvables + from;
+ if (s->repo == solv->installed && solv->transaction_installed[from - solv->installed->start])
+ {
+ /* passive, map to active */
+ if (solv->transaction_installed[from - solv->installed->start] > 0)
+ from = solv->transaction_installed[from - solv->installed->start];
+ else
+ {
+ Queue ti;
+ Id tibuf[5];
+ queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
+ solver_transaction_all_pkgs(solv, from, &ti);
+ for (i = 0; i < ti.count; i++)
+ addedge(od, ti.elements[i], to, type);
+ queue_free(&ti);
+ }
+ return;
+ }
+ s = pool->solvables + to;
+ if (s->repo == solv->installed && solv->transaction_installed[to - solv->installed->start])
+ {
+ /* passive, map to active */
+ if (solv->transaction_installed[to - solv->installed->start] > 0)
+ to = solv->transaction_installed[to - solv->installed->start];
+ else
+ {
+ Queue ti;
+ Id tibuf[5];
+ queue_init_buffer(&ti, tibuf, sizeof(tibuf)/sizeof(*tibuf));
+ solver_transaction_all_pkgs(solv, to, &ti);
+ for (i = 0; i < ti.count; i++)
+ addedge(od, from, ti.elements[i], type);
+ queue_free(&ti);
+ return;
+ }
+ }
+
+ /* map target to te num */
+ for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
+ if (te->p == to)
+ break;
+ if (i == od->ntes)
+ return;
+ to = i;
+
+ for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
+ if (te->p == from)
+ break;
+ if (i == od->ntes)
+ return;
+
+ if (i == to)
+ return; /* no edges to ourselfes */
+
+ // printf("edge %d -> %d type %x\n", i, to, type);
+
+ for (i = te->edges; od->edgedata[i]; i += 2)
+ if (od->edgedata[i] == to)
+ break;
+ if (od->edgedata[i])
+ {
+ od->edgedata[i + 1] |= type;
+ return;
+ }
+ if (i + 1 == od->nedgedata)
+ {
+ // printf("tail add %d\n", i - te->edges);
+ if (!i)
+ te->edges = ++i;
+ od->edgedata = sat_extend(od->edgedata, od->nedgedata, 3, sizeof(Id), EDGEDATA_BLOCK);
+ }
+ else
+ {
+ // printf("extend %d\n", i - te->edges);
+ od->edgedata = sat_extend(od->edgedata, od->nedgedata, 3 + (i - te->edges), sizeof(Id), EDGEDATA_BLOCK);
+ if (i > te->edges)
+ memcpy(od->edgedata + od->nedgedata, od->edgedata + te->edges, sizeof(Id) * (i - te->edges));
+ i = od->nedgedata + (i - te->edges);
+ te->edges = od->nedgedata;
+ }
+ od->edgedata[i] = to;
+ od->edgedata[i + 1] = type;
+ od->edgedata[i + 2] = 0;
+ od->nedgedata = i + 3;
+}
+
+void
+solver_order_transaction(Solver *solv)
+{
+ Pool *pool = solv->pool;
+ Queue *tr = &solv->transaction;
+ Repo *installed = solv->installed;
+ Id type, p;
+ Solvable *s, *s2;
+ Id req, *reqp, con, *conp;
+ Id p2, pp2;
+ int i, j, pre, numte, numedge;
+ struct orderdata od;
+ struct transel *te;
+
+ /* create a transaction element for every active component */
+ numte = 0;
+ for (i = 0; i < tr->count; i += 2)
+ {
+ p = tr->elements[i + 1];
+ s = pool->solvables + p;
+ if (s->repo != installed || !solv->transaction_installed[p - solv->installed->start])
+ numte++;
+ }
+ if (!numte)
+ return; /* nothing to do... */
+
+
+ printf("numte = %d\n", numte);
+ numte++; /* leave first one zero */
+ od.solv = solv;
+ od.ntes = numte;
+ od.tes = sat_calloc(numte, sizeof(*od.tes));
+ od.edgedata = sat_extend(0, 0, 1, sizeof(Id), EDGEDATA_BLOCK);
+ od.edgedata[0] = 0;
+ od.nedgedata = 1;
+
+ for (i = 0, te = od.tes + 1; i < tr->count; i += 2)
+ {
+ p = tr->elements[i + 1];
+ s = pool->solvables + p;
+ if (s->repo == installed && solv->transaction_installed[p - solv->installed->start])
+ continue;
+ te->p = p;
+ te++;
+ }
+
+ /* create dependency graph */
+ for (i = 0; i < tr->count; i += 2)
+ {
+ type = tr->elements[i];
+ p = tr->elements[i + 1];
+ s = pool->solvables + p;
+ if (s->requires)
+ {
+ reqp = s->repo->idarraydata + s->requires;
+ pre = TYPE_REQ;
+ while ((req = *reqp++) != 0)
+ {
+ int eraseonly = 0;
+ if (req == SOLVABLE_PREREQMARKER)
+ {
+ pre = TYPE_PREREQ;
+ continue;
+ }
+#if 1
+ if (s->repo == installed && pre != TYPE_PREREQ)
+ continue;
+#endif
+ FOR_PROVIDES(p2, pp2, req)
+ {
+ if (p2 == p)
+ continue;
+ s2 = pool->solvables + p2;
+ if (!s2->repo)
+ continue;
+ if (s2->repo == installed && solv->decisionmap[p2] > 0)
+ continue;
+ if (s2->repo != installed && solv->decisionmap[p2] < 0)
+ continue; /* not interesting */
+ if (s->repo == installed)
+ {
+ /* we're uninstalling s */
+ if (s2->repo == installed)
+ {
+ if (eraseonly == 0)
+ eraseonly = 1;
+ }
+ if (s2->repo != installed)
+ {
+ /* update p2 before erasing p */
+#if 1
+ addedge(&od, p, p2, pre);
+#endif
+ eraseonly = -1;
+ }
+ }
+ else
+ {
+ /* install p2 before installing p */
+ if (s2->repo != installed)
+ addedge(&od, p, p2, pre);
+ }
+ }
+ if (eraseonly == 1)
+ {
+ printf("eraseonlyedge for %s req %s\n", solvable2str(pool, s), dep2str(pool, req));
+ /* need edges to uninstalled pkgs */
+#if 1
+ FOR_PROVIDES(p2, pp2, req)
+ {
+ if (p2 == p)
+ continue;
+ s2 = pool->solvables + p2;
+ if (!s2->repo || s2->repo != installed)
+ continue;
+ if (solv->decisionmap[p2] > 0)
+ continue;
+#if 0
+ addedge(&od, p2, p, pre);
+#else
+ addedge(&od, p2, p, TYPE_ERASE);
+#endif
+ }
+#endif
+ }
+ }
+ }
+ if (s->conflicts)
+ {
+ conp = s->repo->idarraydata + s->conflicts;
+ while ((con = *conp++) != 0)
+ {
+#if 1
+ FOR_PROVIDES(p2, pp2, con)
+ {
+ if (p2 == p)
+ continue;
+ s2 = pool->solvables + p2;
+ if (!s2->repo)
+ continue;
+ if (s->repo == installed)
+ {
+ if (s2->repo != installed && solv->decisionmap[p2] >= 0)
+ {
+ /* deinstall p before installing p2 */
+ addedge(&od, p2, p, TYPE_CON);
+ }
+ }
+ else
+ {
+ if (s2->repo == installed && solv->decisionmap[p2] < 0)
+ {
+ /* deinstall p2 before installing p */
+#if 1
+ addedge(&od, p, p2, TYPE_CON);
+#endif
+ }
+ }
+
+ }
+#endif
+ }
+ }
+ }
+ numedge = 0;
+ for (i = 1, te = od.tes + i; i < numte; i++, te++)
+ {
+ printf("TE #%d, %d(%s)\n", i, te->p, solvid2str(pool, te->p));
+ for (j = te->edges; od.edgedata[j]; j += 2)
+ {
+ struct transel *te2 = od.tes + od.edgedata[j];
+ printf(" depends %x on TE %d, %d(%s)\n", od.edgedata[j + 1], od.edgedata[j], te2->p, solvid2str(pool, te2->p));
+ numedge++;
+ }
+ }
+ printf("TEs: %d, Edges: %d, Space: %d\n", numte - 1, numedge, od.nedgedata / 2);
+}
diff --git a/src/transaction.h b/src/transaction.h
new file mode 100644
index 0000000..25a7967
--- /dev/null
+++ b/src/transaction.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007-2009, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+/*
+ * transaction.h
+ *
+ */
+
+#ifndef SATSOLVER_TRANSACTION_H
+#define SATSOLVER_TRANSACTION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "pooltypes.h"
+#include "queue.h"
+
+struct _Solver;
+
+#define SOLVER_TRANSACTION_ERASE 0x10
+#define SOLVER_TRANSACTION_REINSTALLED 0x11
+#define SOLVER_TRANSACTION_DOWNGRADED 0x12
+#define SOLVER_TRANSACTION_CHANGED 0x13
+#define SOLVER_TRANSACTION_UPGRADED 0x14
+#define SOLVER_TRANSACTION_REPLACED 0x15
+
+#define SOLVER_TRANSACTION_INSTALL 0x20
+#define SOLVER_TRANSACTION_REINSTALL 0x21
+#define SOLVER_TRANSACTION_DOWNGRADE 0x22
+#define SOLVER_TRANSACTION_CHANGE 0x23
+#define SOLVER_TRANSACTION_UPGRADE 0x24
+#define SOLVER_TRANSACTION_REPLACE 0x25
+
+#define SOLVER_TRANSACTION_MULTIINSTALL 0x30
+#define SOLVER_TRANSACTION_MULTIREINSTALL 0x31
+
+#define SOLVER_TRANSACTION_SHOW_ACTIVE (1 << 0)
+#define SOLVER_TRANSACTION_SHOW_ALL (1 << 1)
+#define SOLVER_TRANSACTION_SHOW_REPLACES (1 << 2)
+
+extern void solver_create_transaction(struct _Solver *solv);
+extern void solver_transaction_all_pkgs(struct _Solver *solv, Id p, Queue *pkgs);
+extern Id solver_transaction_pkg(struct _Solver *solv, Id p);
+extern Id solver_transaction_filter(struct _Solver *solv, Id type, Id p, int mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/tests/solver/deptestomatic.c b/tests/solver/deptestomatic.c
index 945bf50..5da6b4c 100644
--- a/tests/solver/deptestomatic.c
+++ b/tests/solver/deptestomatic.c
@@ -47,14 +47,12 @@ static void rc_printdecisions(Solver *solv, Queue *job);
#define MAXNAMELEN 100
-static Pool *decision_data;
-
/*-----------------------------------------------------------------*/
static int
-transaction_sortcmp(const void *ap, const void *bp)
+transaction_sortcmp(const void *ap, const void *bp, void *dp)
{
- Pool *pool = decision_data;
+ Pool *pool = dp;
int r;
Id a = ((Id *)ap)[1];
Id b = ((Id *)bp)[1];
@@ -663,19 +661,19 @@ add_repo( Parsedata *pd, const char *name, const char *file )
err( "add_repo, no filename!" );
return NULL;
}
- char solvname[256];
+ char solvname[256 + 5];
int l = strlen( file );
if (l > 255 )
{
err( "add_repo, filename too long!" );
return NULL;
}
-
+
const char *ptr = file + l - 1;
while (*ptr)
{
if (ptr == file)
- break;
+ break;
if (*ptr == '.')
{
if (!strncmp( ptr, ".xml", 4 ))
@@ -686,6 +684,7 @@ add_repo( Parsedata *pd, const char *name, const char *file )
}
--ptr;
}
+
strncpy( solvname, file, l );
strcpy( solvname + l, ".solv" );
@@ -1441,7 +1440,7 @@ printf("hardware %s\n", dir);
static void
-rc_printdownloadsize(struct solver *solv)
+rc_printdownloadsize(Solver *solv)
{
int i;
Solvable *s;
@@ -1534,6 +1533,13 @@ endElement( void *userData, const char *name )
rc_printdownloadsize(solv);
}
rc_printdecisions(solv, &pd->trials);
+#if 0
+ if (1)
+ {
+ extern void solver_order_transaction(Solver *solv);
+ solver_order_transaction(solv);
+ }
+#endif
}
// clean up
@@ -1623,18 +1629,20 @@ rc_printdecisions(Solver *solv, Queue *job)
printf(">!> Solution #1:\n");
int installs = 0, uninstalls = 0, upgrades = 0;
+ Id type, p;
- decision_data = solv->pool;
- qsort(solv->transaction.elements, solv->transaction.count / 2, 2 * sizeof(Id), transaction_sortcmp);
+ sat_sort(solv->transaction.elements, solv->transaction.count / 2, 2 * sizeof(Id), transaction_sortcmp, pool);
for (i = 0; i < solv->transaction.count; i += 2)
{
+ type = solv->transaction.elements[i];
+ p = solv->transaction.elements[i + 1];
s = pool->solvables + solv->transaction.elements[i + 1];
- switch(solv->transaction.elements[i])
+ type = solver_transaction_filter(solv, type, p, 0);
+ switch(type)
{
case SOLVER_TRANSACTION_INSTALL:
case SOLVER_TRANSACTION_MULTIINSTALL:
- case SOLVER_TRANSACTION_RENAME:
printf(">!> install %s-%s%s", id2str(pool, s->name), id2rc(solv, s->evr), id2str(pool, s->evr));
if (!redcarpet)
printf(".%s", id2str(pool, s->arch));
@@ -1644,7 +1652,6 @@ rc_printdecisions(Solver *solv, Queue *job)
installs++;
break;
case SOLVER_TRANSACTION_ERASE:
- case SOLVER_TRANSACTION_OBSOLETED:
if (redcarpet)
printf(">!> remove %s-%s%s\n", id2str(pool, s->name), id2rc(solv, s->evr), id2str(pool, s->evr));
else
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 7fca8f3..5f20cf0 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -47,6 +47,10 @@ SET(installcheck_SOURCES installcheck.c repo_rpmmd.c repo_susetags.c)
ADD_EXECUTABLE(installcheck ${installcheck_SOURCES})
TARGET_LINK_LIBRARIES(installcheck satsolver ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
+SET(patchcheck_SOURCES patchcheck.c repo_rpmmd.c repo_susetags.c repo_updateinfoxml.c)
+ADD_EXECUTABLE(patchcheck ${patchcheck_SOURCES})
+TARGET_LINK_LIBRARIES(patchcheck satsolver ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
+
ADD_EXECUTABLE( dumpsolv dumpsolv.c )
TARGET_LINK_LIBRARIES( dumpsolv satsolver)
diff --git a/tools/patchcheck.c b/tools/patchcheck.c
new file mode 100644
index 0000000..e24d88d
--- /dev/null
+++ b/tools/patchcheck.c
@@ -0,0 +1,487 @@
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <zlib.h>
+
+#include "pool.h"
+#include "evr.h"
+#include "poolarch.h"
+#include "repo_solv.h"
+#include "repo_susetags.h"
+#include "repo_updateinfoxml.h"
+#include "repo_rpmmd.h"
+#include "solver.h"
+#include "solverdebug.h"
+
+static ssize_t
+cookie_gzread(void *cookie, char *buf, size_t nbytes)
+{
+ return gzread((gzFile *)cookie, buf, nbytes);
+}
+
+static int
+cookie_gzclose(void *cookie)
+{
+ return gzclose((gzFile *)cookie);
+}
+
+FILE *
+myfopen(const char *fn)
+{
+ cookie_io_functions_t cio;
+ char *suf;
+ gzFile *gzf;
+
+ if (!fn)
+ return 0;
+ suf = strrchr(fn, '.');
+ if (!suf || strcmp(suf, ".gz") != 0)
+ return fopen(fn, "r");
+ gzf = gzopen(fn, "r");
+ if (!gzf)
+ return 0;
+ memset(&cio, 0, sizeof(cio));
+ cio.read = cookie_gzread;
+ cio.close = cookie_gzclose;
+ return fopencookie(gzf, "r", cio);
+}
+
+void
+showproblems(Solver *solv, Solvable *s, Queue *cand, Queue *badguys)
+{
+ Pool *pool = solv->pool;
+ Queue rids, rinfo;
+ Id problem = 0;
+ int jj;
+ int rerun = 0;
+
+ queue_init(&rids);
+ queue_init(&rinfo);
+ printf("can't install %s:\n", solvable2str(pool, s));
+ while ((problem = solver_next_problem(solv, problem)) != 0)
+ {
+ solver_findallproblemrules(solv, problem, &rids);
+ for (jj = 0; jj < rids.count; jj++)
+ {
+ Id probr = rids.elements[jj];
+ int k, l;
+
+ queue_empty(&rinfo);
+ solver_allruleinfos(solv, probr, &rinfo);
+ for (k = 0; k < rinfo.count; k += 4)
+ {
+ Id dep, source, target;
+ source = rinfo.elements[k + 1];
+ target = rinfo.elements[k + 2];
+ dep = rinfo.elements[k + 3];
+ switch (rinfo.elements[k])
+ {
+ case SOLVER_PROBLEM_DISTUPGRADE_RULE:
+ break;
+ case SOLVER_PROBLEM_INFARCH_RULE:
+ printf(" %s has inferior architecture\n", solvid2str(pool, source));
+ break;
+ case SOLVER_PROBLEM_UPDATE_RULE:
+ printf(" update rule for %s\n", solvid2str(pool, source));
+ if (badguys)
+ queue_pushunique(badguys, source);
+ if (!cand)
+ break;
+ /* only drop update problem packages from cand so that we see all problems of this patch */
+ for (l = 0; l < cand->count; l++)
+ if (cand->elements[l] == source || cand->elements[l] == -source)
+ break;
+ if (l == cand->count)
+ break;
+ if (!rerun)
+ {
+ for (l = 0; l < cand->count; l++)
+ if (cand->elements[l] < 0)
+ cand->elements[l] = -cand->elements[l];
+ rerun = 1;
+ }
+ for (l = 0; l < cand->count; l++)
+ if (cand->elements[l] == source)
+ {
+ cand->elements[l] = -source;
+ }
+ break;
+ case SOLVER_PROBLEM_JOB_RULE:
+ break;
+ case SOLVER_PROBLEM_RPM_RULE:
+ printf(" some dependency problem\n");
+ break;
+ case SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP:
+ printf(" nothing provides requested %s\n", dep2str(pool, dep));
+ break;
+ case SOLVER_PROBLEM_NOT_INSTALLABLE:
+ printf(" package %s is not installable\n", solvid2str(pool, source));
+ break;
+ case SOLVER_PROBLEM_NOTHING_PROVIDES_DEP:
+ printf(" nothing provides %s needed by %s\n", dep2str(pool, dep), solvid2str(pool, source));
+ if (ISRELDEP(dep))
+ {
+ Reldep *rd = GETRELDEP(pool, dep);
+ if (!ISRELDEP(rd->name))
+ {
+ Id rp, rpp;
+ FOR_PROVIDES(rp, rpp, rd->name)
+ printf(" (we have %s)\n", solvid2str(pool, rp));
+ }
+ }
+ break;
+ case SOLVER_PROBLEM_SAME_NAME:
+ printf(" cannot install both %s and %s\n", solvid2str(pool, source), solvid2str(pool, target));
+ break;
+ case SOLVER_PROBLEM_PACKAGE_CONFLICT:
+ printf(" package %s conflicts with %s provided by %s\n", solvid2str(pool, source), dep2str(pool, dep), solvid2str(pool, target));
+ break;
+ case SOLVER_PROBLEM_PACKAGE_OBSOLETES:
+ printf(" package %s obsoletes %s provided by %s\n", solvid2str(pool, source), dep2str(pool, dep), solvid2str(pool, target));
+ break;
+ case SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE:
+ printf(" package %s requires %s, but none of the providers can be installed\n", solvid2str(pool, source), dep2str(pool, dep));
+ break;
+ case SOLVER_PROBLEM_SELF_CONFLICT:
+ printf(" package %s conflicts with %s provided by itself\n", solvid2str(pool, source), dep2str(pool, dep));
+ break;
+ }
+ }
+ }
+ }
+ queue_free(&rids);
+ queue_free(&rinfo);
+}
+
+void
+toinst(Solver *solv, Repo *repo, Repo *instrepo)
+{
+ Pool *pool = solv->pool;
+ int k;
+ Id p;
+
+ for (k = 0; k < solv->decisionq.count; k++)
+ {
+ p = solv->decisionq.elements[k];
+ if (p < 0 || p == SYSTEMSOLVABLE)
+ continue;
+ /* oh my! */
+ pool->solvables[p].repo = instrepo;
+ }
+}
+
+void
+frominst(Solver *solv, Repo *repo, Repo *instrepo)
+{
+ Pool *pool = solv->pool;
+ int k;
+
+ for (k = 1; k < pool->nsolvables; k++)
+ if (pool->solvables[k].repo == instrepo)
+ pool->solvables[k].repo = repo;
+}
+
+int
+main(int argc, char **argv)
+{
+ Pool *pool;
+ char *arch, *mypatch;
+ const char *pname;
+ int l;
+ FILE *fp;
+ int i, j;
+ Queue job;
+ Queue cand;
+ Queue badguys;
+ Id pid, p, pp;
+ Id con, *conp;
+ Solver *solv;
+ Repo *repo, *instrepo;
+ int status = 0;
+ int tests = 0;
+ int updatestart = 0;
+
+ arch = argv[1];
+ pool = pool_create();
+ pool_setarch(pool, arch);
+ mypatch = argv[2];
+
+ repo = repo_create(pool, 0);
+ instrepo = repo_create(pool, 0);
+ for (i = 3; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "--updaterepos"))
+ {
+ updatestart = pool->nsolvables;
+ continue;
+ }
+ l = strlen(argv[i]);
+ if (!strcmp(argv[i], "-"))
+ fp = stdin;
+ else if ((fp = myfopen(argv[i])) == 0)
+ {
+ perror(argv[i]);
+ exit(1);
+ }
+ if (l >= 8 && !strcmp(argv[i] + l - 8, "packages"))
+ {
+ repo_add_susetags(repo, fp, 0, 0, 0);
+ }
+ else if (l >= 11 && !strcmp(argv[i] + l - 11, "packages.gz"))
+ {
+ repo_add_susetags(repo, fp, 0, 0, 0);
+ }
+ else if (l >= 14 && !strcmp(argv[i] + l - 14, "primary.xml.gz"))
+ {
+ repo_add_rpmmd(repo, fp, 0, 0);
+ }
+ else if (l >= 17 && !strcmp(argv[i] + l - 17, "updateinfo.xml.gz"))
+ {
+ repo_add_updateinfoxml(repo, fp, 0);
+ }
+ else if (repo_add_solv(repo, fp))
+ {
+ fprintf(stderr, "could not add repo %s\n", argv[i]);
+ exit(1);
+ }
+ if (fp != stdin)
+ fclose(fp);
+ }
+
+ /* bad hack ahead: clone repo */
+ instrepo->idarraydata = repo->idarraydata;
+ instrepo->start = repo->start;
+ instrepo->end = repo->end;
+ instrepo->nsolvables = repo->nsolvables; /* sic! */
+ pool_set_installed(pool, instrepo);
+
+ pool_addfileprovides(pool);
+ pool_createwhatprovides(pool);
+
+ queue_init(&job);
+ queue_init(&cand);
+ queue_init(&badguys);
+
+#if 0
+ pool_setdebuglevel(pool, 2);
+#endif
+
+ for (pid = 1; pid < pool->nsolvables; pid++)
+ {
+ Solvable *s = pool->solvables + pid;
+ if (!s->repo)
+ continue;
+ if (!pool_installable(pool, s))
+ continue;
+ pname = id2str(pool, s->name);
+ if (strncmp(pname, "patch:", 6) != 0)
+ continue;
+ if (*mypatch)
+ {
+ if (strncmp(mypatch, pname + 6, strlen(pname + 6)) != 0)
+ continue;
+ if (strcmp(mypatch, pname + 6) != 0)
+ {
+ l = strlen(pname + 6);
+ if (mypatch[l] != '-')
+ continue;
+ if (strcmp(mypatch + l + 1, id2str(pool, s->evr)) != 0)
+ continue;
+ }
+ }
+ else
+ {
+ FOR_PROVIDES(p, pp, s->name)
+ {
+ Solvable *s2 = pool->solvables + p;
+ if (evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE) < 0)
+ break;
+ }
+ if (p)
+ continue; /* found a newer one */
+ }
+ tests++;
+ if (!s->conflicts)
+ continue;
+
+#if 0
+ printf("testing patch %s-%s\n", pname + 6, id2str(pool, s->evr));
+#endif
+
+ /* Test 1: are all old patches included */
+ FOR_PROVIDES(p, pp, s->name)
+ {
+ Solvable *s2 = pool->solvables + p;
+ Id con2, *conp2;
+ int shown = 0;
+
+ if (evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE) <= 0)
+ continue;
+ if (!s2->conflicts)
+ continue;
+ conp2 = s2->repo->idarraydata + s2->conflicts;
+ while ((con2 = *conp2++) != 0)
+ {
+ Reldep *rd2;
+ if (!ISRELDEP(con2))
+ continue;
+ rd2 = GETRELDEP(pool, con2);
+ conp = s->repo->idarraydata + s->conflicts;
+ while ((con = *conp++) != 0)
+ {
+ Reldep *rd;
+ if (!ISRELDEP(con))
+ continue;
+ rd = GETRELDEP(pool, con);
+ if (rd->name == rd2->name)
+ break;
+ }
+ if (!con)
+ {
+ if (!shown++)
+ printf("%s:\n", solvable2str(pool, s));
+ printf(" %s contained %s\n", solvable2str(pool, s2), dep2str(pool, rd2->name));
+ }
+ }
+ }
+
+ /* Test 2: are the packages installable */
+ conp = s->repo->idarraydata + s->conflicts;
+ while ((con = *conp++) != 0)
+ {
+ FOR_PROVIDES(p, pp, con)
+ {
+ queue_empty(&job);
+ queue_push(&job, SOLVER_INSTALL|SOLVER_SOLVABLE|SOLVER_WEAK);
+ queue_push(&job, p);
+
+ /* also set up some minimal system */
+ queue_push(&job, SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES|SOLVER_WEAK);
+ queue_push(&job, str2id(pool, "rpm", 1));
+ queue_push(&job, SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES|SOLVER_WEAK);
+ queue_push(&job, str2id(pool, "aaa_base", 1));
+
+ solv = solver_create(pool);
+ solv->dontinstallrecommended = 1;
+ solv = solver_create(pool);
+ solver_solve(solv, &job);
+ toinst(solv, repo, instrepo);
+ solver_free(solv);
+ queue_empty(&job);
+ for (i = 1; i < updatestart; i++)
+ {
+ if (pool->solvables[i].repo != repo || i == pid)
+ continue;
+ queue_push(&job, SOLVER_ERASE|SOLVER_SOLVABLE);
+ queue_push(&job, i);
+ }
+ queue_push(&job, SOLVER_INSTALL_SOLVABLE);
+ queue_push(&job, pid);
+ solv = solver_create(pool);
+ solv->dontinstallrecommended = 1;
+ solver_solve(solv, &job);
+ if (solv->problems.count)
+ {
+ status = 1;
+ showproblems(solv, s, 0, 0);
+ }
+ frominst(solv, repo, instrepo);
+ solver_free(solv);
+ }
+ }
+
+ if (0)
+ continue;
+
+ /* Test 3: can we upgrade all packages? */
+ queue_empty(&cand);
+ queue_empty(&badguys);
+ for (p = 1; p < pool->nsolvables; p++)
+ {
+ Solvable *s = pool->solvables + p;
+ if (!s->repo)
+ continue;
+ if (strchr(id2str(pool, s->name), ':'))
+ continue; /* only packages, please */
+ if (!pool_installable(pool, s))
+ continue;
+ queue_push(&cand, p);
+ }
+ while (cand.count)
+ {
+ solv = solver_create(pool);
+ solv->dontinstallrecommended = 1;
+ solv = solver_create(pool);
+ queue_empty(&job);
+ for (i = 0; i < badguys.count; i++)
+ {
+ queue_push(&job, SOLVER_ERASE|SOLVER_SOLVABLE|SOLVER_WEAK);
+ queue_push(&job, badguys.elements[i]);
+ }
+ conp = s->repo->idarraydata + s->conflicts;
+ while ((con = *conp++) != 0)
+ {
+ queue_push(&job, SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES|SOLVER_WEAK);
+ queue_push(&job, con);
+ }
+ for (i = 0; i < cand.count; i++)
+ {
+ p = cand.elements[i];
+ queue_push(&job, SOLVER_INSTALL|SOLVER_SOLVABLE|SOLVER_WEAK);
+ queue_push(&job, p);
+ }
+ solver_solve(solv, &job);
+#if 0
+ solver_printdecisions(solv);
+#endif
+ /* put packages into installed repo and prune them from cand */
+ toinst(solv, repo, instrepo);
+ for (i = 0; i < cand.count; i++)
+ {
+ p = cand.elements[i];
+ if (p > 0 && solv->decisionmap[p] > 0)
+ cand.elements[i] = -p; /* drop candidate */
+ }
+ solver_free(solv);
+
+ /* now the interesting part: test patch */
+ queue_empty(&job);
+#if 0
+ for (i = 1; i < updatestart; i++)
+ {
+ if (pool->solvables[i].repo != repo || i == pid)
+ continue;
+ queue_push(&job, SOLVER_ERASE|SOLVER_SOLVABLE);
+ queue_push(&job, i);
+ }
+#endif
+ queue_push(&job, SOLVER_INSTALL_SOLVABLE);
+ queue_push(&job, pid);
+ solv = solver_create(pool);
+ solv->dontinstallrecommended = 1;
+ solver_solve(solv, &job);
+
+ if (solv->problems.count)
+ {
+ status = 1;
+ showproblems(solv, s, &cand, &badguys);
+ }
+ frominst(solv, repo, instrepo);
+ solver_free(solv);
+ /* now drop all negative elements from cand */
+ for (i = j = 0; i < cand.count; i++)
+ {
+ if (cand.elements[i] < 0)
+ continue;
+ cand.elements[j++] = cand.elements[i];
+ }
+ if (i == j)
+ break; /* no progress */
+ cand.count = j;
+ }
+ }
+ exit(status);
+}
diff --git a/tools/repo_rpmmd.c b/tools/repo_rpmmd.c
index 867c026..eed0ab1 100644
--- a/tools/repo_rpmmd.c
+++ b/tools/repo_rpmmd.c
@@ -269,7 +269,7 @@ langtag(struct parsedata *pd, Id tag, const char *language)
}
static int
-id3_cmp (const void *v1, const void *v2)
+id3_cmp (const void *v1, const void *v2, void *dp)
{
Id *i1 = (Id*)v1;
Id *i2 = (Id*)v2;
@@ -284,7 +284,7 @@ commit_diskusage (struct parsedata *pd, unsigned handle)
/* Now sort in dirid order. This ensures that parents come before
their children. */
if (pd->ndirs > 1)
- qsort(pd->dirs, pd->ndirs, sizeof (pd->dirs[0]), id3_cmp);
+ sat_sort(pd->dirs, pd->ndirs, sizeof (pd->dirs[0]), id3_cmp, 0);
/* Substract leaf numbers from all parents to make the numbers
non-cumulative. This must be done post-order (i.e. all leafs
adjusted before parents). We ensure this by starting at the end of
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <zypper> master : Tell we're gonna retry after the "autoselecting 'r'" countdown.
by Ján Kupec 13 May '09
by Ján Kupec 13 May '09
13 May '09
ref: refs/heads/master
commit b9a032da868cb3b7fe7448500258eb4fddde0409
Author: Ján Kupec <jkupec(a)suse.cz>
Date: Wed May 13 10:19:04 2009 +0200
Tell we're gonna retry after the "autoselecting 'r'" countdown.
---
src/utils/prompt.cc | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/utils/prompt.cc b/src/utils/prompt.cc
index 1fef1e4..279209e 100644
--- a/src/utils/prompt.cc
+++ b/src/utils/prompt.cc
@@ -243,6 +243,9 @@ read_action_ari_with_timeout(PromptId pid, unsigned timeout, int default_action)
--timeout;
}
+ if (zypper.out().type() != Out::TYPE_XML)
+ cout << CLEARLN << _("Trying again...") << endl;
+
return default_action;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
ref: refs/heads/master
commit b3fe80613b98e2630ec85478d90ca1a8d366361d
Author: Ján Kupec <jkupec(a)suse.cz>
Date: Wed May 13 10:18:49 2009 +0200
Comments.
---
src/utils/Augeas.h | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/src/utils/Augeas.h b/src/utils/Augeas.h
index db2248d..4cabd7d 100644
--- a/src/utils/Augeas.h
+++ b/src/utils/Augeas.h
@@ -20,10 +20,6 @@ extern "C"
/**
* Zypper's wrapper around Augeas.
- *
- * \todo add root dir argument to constructor
- * \todo add conf file to load argument
- * \todo use the new API to cherry-pick the lense and conf file to load
*/
class Augeas : private zypp::base::NonCopyable
{
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> master : - define solvid2str() function, use sat_sort()
by Michael Schroeder 12 May '09
by Michael Schroeder 12 May '09
12 May '09
ref: refs/heads/master
commit e024379e5ef853b84f5add557cb546af3a37c624
Author: Michael Schroeder <mls(a)suse.de>
Date: Tue May 12 12:23:49 2009 +0200
- define solvid2str() function, use sat_sort()
---
src/policy.c | 9 +++------
src/pool.c | 9 +++------
src/pool.h | 4 ++++
tools/repo_rpmdb.c | 18 ++++++++----------
tools/repo_susetags.c | 4 ++--
tools/repo_write.c | 29 ++++++++++++++---------------
6 files changed, 34 insertions(+), 39 deletions(-)
diff --git a/src/policy.c b/src/policy.c
index 0bbe7b1..fe5c570 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -22,8 +22,6 @@
#include "poolarch.h"
-static Solver *prune_to_best_version_sortcmp_data;
-
/*-----------------------------------------------------------------*/
/*
@@ -32,9 +30,9 @@ static Solver *prune_to_best_version_sortcmp_data;
*/
static int
-prune_to_best_version_sortcmp(const void *ap, const void *bp)
+prune_to_best_version_sortcmp(const void *ap, const void *bp, void *dp)
{
- Solver *solv = prune_to_best_version_sortcmp_data;
+ Solver *solv = dp;
Pool *pool = solv->pool;
int r;
Id a = *(Id *)ap;
@@ -282,9 +280,8 @@ prune_to_best_version(Solver *solv, Queue *plist)
return;
POOL_DEBUG(SAT_DEBUG_POLICY, "prune_to_best_version %d\n", plist->count);
- prune_to_best_version_sortcmp_data = solv;
/* sort by name first, prefer installed */
- qsort(plist->elements, plist->count, sizeof(Id), prune_to_best_version_sortcmp);
+ sat_sort(plist->elements, plist->count, sizeof(Id), prune_to_best_version_sortcmp, solv);
/* delete obsoleted. hmm, looks expensive! */
/* FIXME maybe also check provides depending on noupdateprovide? */
diff --git a/src/pool.c b/src/pool.c
index 10ab817..49cc911 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -132,13 +132,11 @@ pool_set_installed(Pool *pool, Repo *installed)
pool_freewhatprovides(pool);
}
-static Pool *pool_shrink_whatprovides_sortcmp_data;
-
static int
-pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp)
+pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp, void *dp)
{
int r;
- Pool *pool = pool_shrink_whatprovides_sortcmp_data;
+ Pool *pool = dp;
Id oa, ob, *da, *db;
oa = pool->whatprovides[*(Id *)ap];
ob = pool->whatprovides[*(Id *)bp];
@@ -178,8 +176,7 @@ pool_shrink_whatprovides(Pool *pool)
sorted = sat_malloc2(pool->ss.nstrings, sizeof(Id));
for (id = 0; id < pool->ss.nstrings; id++)
sorted[id] = id;
- pool_shrink_whatprovides_sortcmp_data = pool;
- qsort(sorted + 1, pool->ss.nstrings - 1, sizeof(Id), pool_shrink_whatprovides_sortcmp);
+ sat_sort(sorted + 1, pool->ss.nstrings - 1, sizeof(Id), pool_shrink_whatprovides_sortcmp, pool);
last = 0;
lastid = 0;
for (i = 1; i < pool->ss.nstrings; i++)
diff --git a/src/pool.h b/src/pool.h
index cdf4fcb..55c047b 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -179,6 +179,10 @@ static inline Solvable *pool_id2solvable(Pool *pool, Id p)
return pool->solvables + p;
}
extern const char *solvable2str(Pool *pool, Solvable *s);
+static inline const char *solvid2str(Pool *pool, Id p)
+{
+ return solvable2str(pool, pool->solvables + p);
+}
void pool_set_languages(Pool *pool, const char **languages, int nlanguages);
Id pool_id2langid(Pool *pool, Id id, const char *lang, int create);
diff --git a/tools/repo_rpmdb.c b/tools/repo_rpmdb.c
index 1a49d3a..53451e1 100644
--- a/tools/repo_rpmdb.c
+++ b/tools/repo_rpmdb.c
@@ -1117,7 +1117,7 @@ solvable_copy(Solvable *s, Solvable *r, Repodata *data, Id *dircache)
/* used to sort entries returned in some database order */
static int
-rpmids_sort_cmp(const void *va, const void *vb)
+rpmids_sort_cmp(const void *va, const void *vb, void *dp)
{
struct rpmid const *a = va, *b = vb;
int r;
@@ -1127,20 +1127,19 @@ rpmids_sort_cmp(const void *va, const void *vb)
return a->dbid - b->dbid;
}
-static Repo *pkgids_sort_cmp_data;
-
static int
-pkgids_sort_cmp(const void *va, const void *vb)
+pkgids_sort_cmp(const void *va, const void *vb, void *dp)
{
- Pool *pool = pkgids_sort_cmp_data->pool;
+ Repo *repo = dp;
+ Pool *pool = repo->pool;
Solvable *a = pool->solvables + *(Id *)va;
Solvable *b = pool->solvables + *(Id *)vb;
Id *rpmdbid;
if (a->name != b->name)
return strcmp(id2str(pool, a->name), id2str(pool, b->name));
- rpmdbid = pkgids_sort_cmp_data->rpmdbid;
- return rpmdbid[(a - pool->solvables) - pkgids_sort_cmp_data->start] - rpmdbid[(b - pool->solvables) - pkgids_sort_cmp_data->start];
+ rpmdbid = repo->rpmdbid;
+ return rpmdbid[(a - pool->solvables) - repo->start] - rpmdbid[(b - pool->solvables) - repo->start];
}
static void
@@ -1406,8 +1405,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags)
pkgids = sat_malloc2(repo->end - repo->start, sizeof(Id));
for (i = repo->start; i < repo->end; i++)
pkgids[i - repo->start] = i;
- pkgids_sort_cmp_data = repo;
- qsort(pkgids, repo->end - repo->start, sizeof(Id), pkgids_sort_cmp);
+ sat_sort(pkgids, repo->end - repo->start, sizeof(Id), pkgids_sort_cmp, repo);
/* adapt order */
for (i = repo->start; i < repo->end; i++)
{
@@ -1476,7 +1474,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags)
db = 0;
/* sort rpmids */
- qsort(rpmids, nrpmids, sizeof(*rpmids), rpmids_sort_cmp);
+ sat_sort(rpmids, nrpmids, sizeof(*rpmids), rpmids_sort_cmp, 0);
dbidp = (unsigned char *)&dbid;
rpmheadsize = 0;
diff --git a/tools/repo_susetags.c b/tools/repo_susetags.c
index 47a3fad..66880fc 100644
--- a/tools/repo_susetags.c
+++ b/tools/repo_susetags.c
@@ -201,7 +201,7 @@ set_checksum(struct parsedata *pd, Repodata *data, Id handle, Id keyname, char *
*/
static int
-id3_cmp(const void *v1, const void *v2)
+id3_cmp(const void *v1, const void *v2, void *dp)
{
Id *i1 = (Id*)v1;
Id *i2 = (Id*)v2;
@@ -222,7 +222,7 @@ commit_diskusage(struct parsedata *pd, Id handle)
/* Now sort in dirid order. This ensures that parents come before
their children. */
if (pd->ndirs > 1)
- qsort(pd->dirs, pd->ndirs, sizeof(pd->dirs[0]), id3_cmp);
+ sat_sort(pd->dirs, pd->ndirs, sizeof(pd->dirs[0]), id3_cmp, 0);
/* Substract leaf numbers from all parents to make the numbers
non-cumulative. This must be done post-order (i.e. all leafs
adjusted before parents). We ensure this by starting at the end of
diff --git a/tools/repo_write.c b/tools/repo_write.c
index 1dcd5da..f669a01 100644
--- a/tools/repo_write.c
+++ b/tools/repo_write.c
@@ -96,7 +96,7 @@ incneedidarray(Pool *pool, Id *idarray, NeedId *needid)
*/
static int
-needid_cmp_need(const void *ap, const void *bp)
+needid_cmp_need(const void *ap, const void *bp, void *dp)
{
const NeedId *a = ap;
const NeedId *b = bp;
@@ -107,19 +107,19 @@ needid_cmp_need(const void *ap, const void *bp)
return a->map - b->map;
}
-static Stringpool *cmp_spool;
-
static int
-needid_cmp_need_s(const void *ap, const void *bp)
+needid_cmp_need_s(const void *ap, const void *bp, void *dp)
{
const NeedId *a = ap;
const NeedId *b = bp;
+ Stringpool *spool = dp;
+
int r;
r = b->need - a->need;
if (r)
return r;
- const char *as = cmp_spool->stringspace + cmp_spool->strings[a->map];
- const char *bs = cmp_spool->stringspace + cmp_spool->strings[b->map];
+ const char *as = spool->stringspace + spool->strings[a->map];
+ const char *bs = spool->stringspace + spool->strings[b->map];
return strcmp(as, bs);
}
@@ -251,7 +251,7 @@ write_idarray(FILE *fp, Pool *pool, NeedId *needid, Id *ids)
}
static int
-cmp_ids (const void *pa, const void *pb)
+cmp_ids (const void *pa, const void *pb, void *dp)
{
Id a = *(Id *)pa;
Id b = *(Id *)pb;
@@ -303,9 +303,9 @@ write_idarray_sort(FILE *fp, Pool *pool, NeedId *needid, Id *ids, Id marker)
if (sids[i] == marker)
break;
if (i > 1)
- qsort(sids, i, sizeof (Id), cmp_ids);
+ sat_sort(sids, i, sizeof (Id), cmp_ids, 0);
if ((len - i) > 2)
- qsort(sids + i + 1, len - i - 1, sizeof(Id), cmp_ids);
+ sat_sort(sids + i + 1, len - i - 1, sizeof(Id), cmp_ids, 0);
Id id, old = 0;
@@ -478,9 +478,9 @@ data_addidarray_sort(struct extdata *xd, Pool *pool, NeedId *needid, Id *ids, Id
if (sids[i] == marker)
break;
if (i > 1)
- qsort(sids, i, sizeof (Id), cmp_ids);
+ sat_sort(sids, i, sizeof (Id), cmp_ids, 0);
if ((len - i) > 2)
- qsort(sids + i + 1, len - i - 1, sizeof(Id), cmp_ids);
+ sat_sort(sids + i + 1, len - i - 1, sizeof(Id), cmp_ids, 0);
Id id, old = 0;
@@ -1509,15 +1509,14 @@ fprintf(stderr, "dir %d used %d\n", i, cbdata.dirused ? cbdata.dirused[i] : 1);
for (i = 1; i < reloff + pool->nrels; i++)
needid[i].map = i;
- cmp_spool = spool;
#if 0
- qsort(needid + 1, spool->nstrings - 1, sizeof(*needid), needid_cmp_need_s);
+ sat_sort(needid + 1, spool->nstrings - 1, sizeof(*needid), needid_cmp_need_s, spool);
#else
/* make first entry '' */
needid[1].need = 1;
- qsort(needid + 2, spool->nstrings - 2, sizeof(*needid), needid_cmp_need_s);
+ sat_sort(needid + 2, spool->nstrings - 2, sizeof(*needid), needid_cmp_need_s, spool);
#endif
- qsort(needid + reloff, pool->nrels, sizeof(*needid), needid_cmp_need);
+ sat_sort(needid + reloff, pool->nrels, sizeof(*needid), needid_cmp_need, 0);
sizeid = 0;
for (i = 1; i < reloff; i++)
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0