1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Easy-to use interface to the ZYPP dependency resolver
6 * Copyright (C) 2000-2002 Ximian, Inc.
7 * Copyright (C) 2005 SUSE Linux Products GmbH
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 #define ZYPP_USE_RESOLVER_INTERNALS
26 #include "zypp/solver/detail/Resolver.h"
27 #include "zypp/solver/detail/SolutionAction.h"
28 #include "zypp/solver/detail/SolverQueueItem.h"
29 #include "zypp/Capabilities.h"
30 #include "zypp/base/Logger.h"
32 /////////////////////////////////////////////////////////////////////////
34 { ///////////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////////
37 { /////////////////////////////////////////////////////////////////////
38 /////////////////////////////////////////////////////////////////////
40 { ///////////////////////////////////////////////////////////////////
44 IMPL_PTR_TYPE(SolutionAction);
46 //---------------------------------------------------------------------------
48 SolutionAction::SolutionAction()
53 SolutionAction::~SolutionAction()
58 //---------------------------------------------------------------------------
61 TransactionSolutionAction::dumpOn( ostream& os) const
63 os << "TransactionSolutionAction: ";
65 case KEEP: os << "Keep " << _item; break;
66 case INSTALL: os << "Install " << _item; break;
67 case REMOVE: os << "Remove " << _item; break;
68 case UNLOCK: os << "Unlock " << _item; break;
69 case LOCK: os << "Lock " << _item; break;
70 case REMOVE_EXTRA_REQUIRE: os << "Remove require " << _capability; break;
71 case REMOVE_EXTRA_CONFLICT: os << "Remove conflict " << _capability; break;
72 case ADD_SOLVE_QUEUE_ITEM: os << "Add SolveQueueItem " << _solverQueueItem; break;
73 case REMOVE_SOLVE_QUEUE_ITEM: os << "Remove SolveQueueItem " << _solverQueueItem; break;
80 operator<<( ostream& os, const SolutionActionList & actionlist)
82 for (SolutionActionList::const_iterator iter = actionlist.begin(); iter != actionlist.end(); ++iter) {
89 //---------------------------------------------------------------------------
92 InjectSolutionAction::dumpOn( ostream& os ) const
94 os << "InjectSolutionAction: ";
96 case WEAK: os << "Weak"; break;
97 default: os << "Wrong kind"; break;
104 //---------------------------------------------------------------------------
108 SolutionAction::dumpOn( std::ostream & os ) const
110 os << "SolutionAction<";
111 os << "not specified";
118 TransactionSolutionAction::execute(ResolverInternal & resolver) const
123 _item.status().resetTransact (ResStatus::USER);
124 ret = _item.status().setTransact (false, ResStatus::APPL_HIGH); // APPL_HIGH: Locking should not be saved permanently
127 if (_item.status().isToBeUninstalled())
128 ret = _item.status().setTransact (false, ResStatus::USER);
130 _item.status().setToBeInstalled (ResStatus::USER);
133 if (_item.status().isToBeInstalled()) {
134 _item.status().setTransact (false,ResStatus::USER);
135 _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
136 } else if (_item.status().isInstalled())
137 _item.status().setToBeUninstalled (ResStatus::USER);
139 _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
142 ret = _item.status().setLock (false, ResStatus::USER);
143 if (!ret) ERR << "Cannot unlock " << _item << endl;
146 _item.status().resetTransact (ResStatus::USER);
147 ret = _item.status().setLock (true, ResStatus::APPL_HIGH); // APPL_HIGH: Locking should not be saved permanently
148 if (!ret) ERR << "Cannot lock " << _item << endl;
150 case REMOVE_EXTRA_REQUIRE:
151 resolver.removeExtraRequire (_capability);
153 case REMOVE_EXTRA_CONFLICT:
154 resolver.removeExtraConflict (_capability);
156 case ADD_SOLVE_QUEUE_ITEM:
157 resolver.addQueueItem(_solverQueueItem);
159 case REMOVE_SOLVE_QUEUE_ITEM:
160 resolver.removeQueueItem(_solverQueueItem);
163 ERR << "Wrong TransactionKind" << endl;
170 InjectSolutionAction::execute(ResolverInternal & resolver) const
174 // set item dependencies to weak
175 resolver.addWeak (_item);
178 ERR << "No valid InjectSolutionAction kind found" << endl;
185 ///////////////////////////////////////////////////////////////////
186 };// namespace detail
187 /////////////////////////////////////////////////////////////////////
188 /////////////////////////////////////////////////////////////////////
189 };// namespace solver
190 ///////////////////////////////////////////////////////////////////////
191 ///////////////////////////////////////////////////////////////////////
193 /////////////////////////////////////////////////////////////////////////