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 #include "zypp/solver/detail/Resolver.h"
25 #include "zypp/solver/detail/SolutionAction.h"
26 #include "zypp/Capabilities.h"
27 #include "zypp/base/Logger.h"
29 /////////////////////////////////////////////////////////////////////////
31 { ///////////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////////
34 { /////////////////////////////////////////////////////////////////////
35 /////////////////////////////////////////////////////////////////////
37 { ///////////////////////////////////////////////////////////////////
41 IMPL_PTR_TYPE(SolutionAction);
42 IMPL_PTR_TYPE(TransactionSolutionAction);
43 IMPL_PTR_TYPE(InjectSolutionAction);
45 //---------------------------------------------------------------------------
47 SolutionAction::SolutionAction()
52 SolutionAction::~SolutionAction()
57 //---------------------------------------------------------------------------
60 TransactionSolutionAction::dumpOn( ostream& os) const
62 os << "TransactionSolutionAction: ";
64 case KEEP: os << "Keep " << _item; break;
65 case INSTALL: os << "Install " << _item; break;
66 case REMOVE: os << "Remove " << _item; break;
67 case UNLOCK: os << "Unlock " << _item; break;
68 case LOCK: os << "Lock " << _item; break;
69 case REMOVE_EXTRA_REQUIRE: os << "Remove require " << _capability; break;
70 case REMOVE_EXTRA_CONFLICT: os << "Remove conflict " << _capability; break;
71 case ADD_SOLVE_QUEUE_ITEM: os << "Add SolveQueueItem " << _solverQueueItem; break;
72 case REMOVE_SOLVE_QUEUE_ITEM: os << "Remove SolveQueueItem " << _solverQueueItem; break;
79 operator<<( ostream& os, const SolutionActionList & actionlist)
81 for (SolutionActionList::const_iterator iter = actionlist.begin(); iter != actionlist.end(); ++iter) {
90 operator<<( ostream& os, const CSolutionActionList & actionlist)
92 for (CSolutionActionList::const_iterator iter = actionlist.begin(); iter != actionlist.end(); ++iter) {
99 //---------------------------------------------------------------------------
102 InjectSolutionAction::dumpOn( ostream& os ) const
104 os << "InjectSolutionAction: ";
106 case WEAK: os << "Weak"; break;
107 default: os << "Wrong kind"; break;
114 //---------------------------------------------------------------------------
118 SolutionAction::dumpOn( std::ostream & os ) const
120 os << "SolutionAction<";
121 os << "not specified";
128 TransactionSolutionAction::execute(Resolver & resolver) const
133 _item.status().resetTransact (ResStatus::USER);
134 ret = _item.status().setTransact (false, ResStatus::APPL_HIGH); // APPL_HIGH: Locking should not be saved permanently
137 if (_item.status().isToBeUninstalled())
138 ret = _item.status().setTransact (false, ResStatus::USER);
140 _item.status().setToBeInstalled (ResStatus::USER);
143 if (_item.status().isToBeInstalled()) {
144 _item.status().setTransact (false,ResStatus::USER);
145 _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
146 } else if (_item.status().isInstalled())
147 _item.status().setToBeUninstalled (ResStatus::USER);
149 _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
152 ret = _item.status().setLock (false, ResStatus::USER);
153 if (!ret) ERR << "Cannot unlock " << _item << endl;
156 _item.status().resetTransact (ResStatus::USER);
157 ret = _item.status().setLock (true, ResStatus::APPL_HIGH); // APPL_HIGH: Locking should not be saved permanently
158 if (!ret) ERR << "Cannot lock " << _item << endl;
160 case REMOVE_EXTRA_REQUIRE:
161 resolver.removeExtraRequire (_capability);
163 case REMOVE_EXTRA_CONFLICT:
164 resolver.removeExtraConflict (_capability);
166 case ADD_SOLVE_QUEUE_ITEM:
167 resolver.addQueueItem(_solverQueueItem);
169 case REMOVE_SOLVE_QUEUE_ITEM:
170 resolver.removeQueueItem(_solverQueueItem);
173 ERR << "Wrong TransactionKind" << endl;
180 InjectSolutionAction::execute(Resolver & resolver) const
184 // set item dependencies to weak
185 resolver.addWeak (_item);
188 ERR << "No valid InjectSolutionAction kind found" << endl;
195 ///////////////////////////////////////////////////////////////////
196 };// namespace detail
197 /////////////////////////////////////////////////////////////////////
198 /////////////////////////////////////////////////////////////////////
199 };// namespace solver
200 ///////////////////////////////////////////////////////////////////////
201 ///////////////////////////////////////////////////////////////////////
203 /////////////////////////////////////////////////////////////////////////