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>
34 /////////////////////////////////////////////////////////////////////////
36 { ///////////////////////////////////////////////////////////////////////
37 ///////////////////////////////////////////////////////////////////////
39 { /////////////////////////////////////////////////////////////////////
40 /////////////////////////////////////////////////////////////////////
42 { ///////////////////////////////////////////////////////////////////
45 IMPL_PTR_TYPE(SolutionAction);
47 //---------------------------------------------------------------------------
49 SolutionAction::SolutionAction()
54 SolutionAction::~SolutionAction()
59 //---------------------------------------------------------------------------
62 TransactionSolutionAction::dumpOn( std::ostream& os) const
64 os << "TransactionSolutionAction: ";
66 case KEEP: os << "Keep " << _item; break;
67 case INSTALL: os << "Install " << _item; break;
68 case REMOVE: os << "Remove " << _item; break;
69 case UNLOCK: os << "Unlock " << _item; break;
70 case LOCK: os << "Lock " << _item; break;
71 case REMOVE_EXTRA_REQUIRE: os << "Remove require " << _capability; break;
72 case REMOVE_EXTRA_CONFLICT: os << "Remove conflict " << _capability; break;
73 case ADD_SOLVE_QUEUE_ITEM: os << "Add SolveQueueItem " << _solverQueueItem; break;
74 case REMOVE_SOLVE_QUEUE_ITEM: os << "Remove SolveQueueItem " << _solverQueueItem; break;
81 operator<<( std::ostream& os, const SolutionActionList & actionlist)
83 for (SolutionActionList::const_iterator iter = actionlist.begin(); iter != actionlist.end(); ++iter) {
90 //---------------------------------------------------------------------------
93 InjectSolutionAction::dumpOn( std::ostream& os ) const
95 os << "InjectSolutionAction: ";
97 case WEAK: os << "Weak"; break;
98 default: os << "Wrong kind"; break;
105 //---------------------------------------------------------------------------
109 SolutionAction::dumpOn( std::ostream & os ) const
111 os << "SolutionAction<";
112 os << "not specified";
119 TransactionSolutionAction::execute(ResolverInternal & resolver) const
124 _item.status().resetTransact (ResStatus::USER);
125 ret = _item.status().setTransact (false, ResStatus::APPL_HIGH); // APPL_HIGH: Locking should not be saved permanently
128 if (_item.status().isToBeUninstalled())
129 ret = _item.status().setTransact (false, ResStatus::USER);
131 _item.status().setToBeInstalled (ResStatus::USER);
134 if (_item.status().isToBeInstalled()) {
135 _item.status().setTransact (false,ResStatus::USER);
136 _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
137 } else if (_item.status().isInstalled())
138 _item.status().setToBeUninstalled (ResStatus::USER);
140 _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
143 ret = _item.status().setLock (false, ResStatus::USER);
144 if (!ret) ERR << "Cannot unlock " << _item << endl;
147 _item.status().resetTransact (ResStatus::USER);
148 ret = _item.status().setLock (true, ResStatus::APPL_HIGH); // APPL_HIGH: Locking should not be saved permanently
149 if (!ret) ERR << "Cannot lock " << _item << endl;
151 case REMOVE_EXTRA_REQUIRE:
152 resolver.removeExtraRequire (_capability);
154 case REMOVE_EXTRA_CONFLICT:
155 resolver.removeExtraConflict (_capability);
157 case ADD_SOLVE_QUEUE_ITEM:
158 resolver.addQueueItem(_solverQueueItem);
160 case REMOVE_SOLVE_QUEUE_ITEM:
161 resolver.removeQueueItem(_solverQueueItem);
164 ERR << "Wrong TransactionKind" << endl;
171 InjectSolutionAction::execute(ResolverInternal & resolver) const
175 // set item dependencies to weak
176 resolver.addWeak (_item);
179 ERR << "No valid InjectSolutionAction kind found" << endl;
186 ///////////////////////////////////////////////////////////////////
187 };// namespace detail
188 /////////////////////////////////////////////////////////////////////
189 /////////////////////////////////////////////////////////////////////
190 };// namespace solver
191 ///////////////////////////////////////////////////////////////////////
192 ///////////////////////////////////////////////////////////////////////
194 /////////////////////////////////////////////////////////////////////////