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"
28 #include "zypp/Dependencies.h"
31 /////////////////////////////////////////////////////////////////////////
33 { ///////////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////
36 { /////////////////////////////////////////////////////////////////////
37 /////////////////////////////////////////////////////////////////////
39 { ///////////////////////////////////////////////////////////////////
43 IMPL_PTR_TYPE(SolutionAction);
44 IMPL_PTR_TYPE(TransactionSolutionAction);
45 IMPL_PTR_TYPE(InjectSolutionAction);
47 //---------------------------------------------------------------------------
49 SolutionAction::SolutionAction()
54 SolutionAction::~SolutionAction()
59 //---------------------------------------------------------------------------
62 TransactionSolutionAction::dumpOn( ostream& os) const
64 os << "TransactionSolutionAction: ";
66 case KEEP: os << "Keep"; break;
67 case INSTALL: os << "Install"; break;
68 case REMOVE: os << "Remove"; break;
69 case UNLOCK: os << "Unlock"; 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;
115 //---------------------------------------------------------------------------
119 SolutionAction::dumpOn( std::ostream & os ) const
121 os << "SolutionAction<";
122 os << "not specified";
129 TransactionSolutionAction::execute(Resolver & resolver) const
136 if (_item.status().isToBeUninstalled())
137 ret = _item.status().setTransact (false, ResStatus::USER);
139 _item.status().setToBeInstalled (ResStatus::USER);
142 if (_item.status().isToBeInstalled()) {
143 _item.status().setTransact (false,ResStatus::USER);
144 _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
145 } else if (_item.status().isInstalled())
146 _item.status().setToBeUninstalled (ResStatus::USER);
148 _item.status().setLock (true,ResStatus::USER); // no other dependency can set it again
151 ret = _item.status().setLock (false, ResStatus::USER);
152 if (!ret) ERR << "Cannot unlock " << _item << endl;
155 ERR << "Wrong TransactionKind" << endl;
162 InjectSolutionAction::execute(Resolver & resolver) const
166 // set item dependencies to weak
167 resolver.addWeak (_item);
170 ERR << "No valid InjectSolutionAction kind found" << endl;
177 ///////////////////////////////////////////////////////////////////
178 };// namespace detail
179 /////////////////////////////////////////////////////////////////////
180 /////////////////////////////////////////////////////////////////////
181 };// namespace solver
182 ///////////////////////////////////////////////////////////////////////
183 ///////////////////////////////////////////////////////////////////////
185 /////////////////////////////////////////////////////////////////////////