41 #define YUILogComponent "ncurses-pkg"
44 #include "NCPkgStatusStrategy.h"
50 #include <zypp/ui/Selectable.h>
51 #include <zypp/ResObject.h>
62 NCPkgStatusStrategy::NCPkgStatusStrategy()
69 NCPkgStatusStrategy::~NCPkgStatusStrategy()
84 return slbPtr->status();
88 yuiError() <<
"Selectable pointer not valid" << endl;
105 yuiError() <<
"Invalid package object" << endl;
109 ok = slbPtr->setStatus( newstatus );
111 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
112 << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
126 ZyppStatus & newStat )
132 ZyppStatus retStat = S_NoInst;
134 bool installed = !slbPtr->installedEmpty();
151 if ( oldStatus == S_NoInst
152 || oldStatus == S_AutoInstall )
157 else if ( oldStatus == S_Del
158 || oldStatus == S_AutoDel)
160 retStat = S_KeepInstalled;
162 else if ( oldStatus == S_AutoUpdate )
172 if ( oldStatus == S_KeepInstalled
173 || oldStatus == S_Del
174 || oldStatus == S_AutoDel )
176 if ( slbPtr->hasCandidateObj() )
189 if ( oldStatus == S_Install
190 || oldStatus == S_AutoInstall )
194 else if ( oldStatus == S_Update
195 || oldStatus == S_AutoUpdate )
197 retStat = S_KeepInstalled;
209 retStat = S_Protected;
213 yuiDebug() <<
"Key not valid" << endl;
232 ZyppStatus & newStat )
240 ZyppStatus newStatus = oldStatus;
241 ZyppPattern patPtr = tryCastToZyppPattern (objPtr);
246 newStatus = S_KeepInstalled;
249 newStatus =S_NoInst ;
254 case S_KeepInstalled:
256 newStatus = S_Install;
258 else if ( slbPtr->hasCandidateObj() )
260 newStatus = S_Update;
268 if ( slbPtr->hasCandidateObj() || patPtr )
270 newStatus = S_Install;
274 yuiWarning() <<
"No candidate object for " << slbPtr->theObj()->name().c_str() << endl;
275 newStatus = S_NoInst;
283 newStatus = S_KeepInstalled;
286 newStatus = S_KeepInstalled;
289 newStatus = S_NoInst;
292 newStatus = S_KeepInstalled;
296 yuiMilestone() <<
"Status toogled: old " << oldStatus <<
", new " << newStatus << endl;
310 zypp::Resolver_Ptr resolver = zypp::getZYpp()->resolver();
311 resolver->resolvePool();
323 PackageStatStrategy::PackageStatStrategy()
338 PatchStatStrategy::PatchStatStrategy()
353 ZyppStatus & newStat )
355 if ( !slbPtr || !slbPtr->hasCandidateObj() )
359 ZyppStatus retStat = S_NoInst;
361 bool toBeInst = slbPtr->candidateObj().status().isToBeInstalled();
362 bool isRelevant = slbPtr->candidateObj().isRelevant();
363 bool isBroken = slbPtr->candidateObj().isBroken();
365 yuiMilestone() << slbPtr->name() <<
": " << (toBeInst?
"to be installed":
"not to be installed,")
366 <<
" old status: " << oldStatus << endl;
377 else if ( oldStatus == S_Taboo )
396 ( oldStatus == S_NoInst ||
397 oldStatus == S_AutoInstall ||
398 oldStatus == S_KeepInstalled ) )
416 yuiDebug() <<
"Key not valid" << endl;
424 yuiMilestone() <<
"New status: " << newStat << endl;
437 ZyppStatus & newStat )
439 if ( !slbPtr || !slbPtr->hasCandidateObj() )
445 bool isBroken = slbPtr->candidateObj().isBroken();
446 ZyppStatus newStatus = oldStatus;
452 newStatus = S_NoInst ;
454 case S_KeepInstalled:
455 newStatus = S_Install;
458 newStatus = S_Install ;
463 newStatus = S_Install;
467 newStatus = S_NoInst;
471 newStatus = oldStatus;
473 yuiMilestone() <<
"Status toogled: old " << oldStatus <<
", new " << newStatus << endl;
494 yuiError() <<
"Invalid patch object" << endl;
498 ok = slbPtr->setStatus( newstatus );
499 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
500 << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
515 SelectionStatStrategy::SelectionStatStrategy()
531 if ( !slbPtr || !objPtr )
533 yuiError() <<
"Invalid selection" << endl;
537 ok = slbPtr->setStatus( newstatus );
538 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
539 << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
554 DependencyStatStrategy::DependencyStatStrategy()
566 AvailableStatStrategy::AvailableStatStrategy()
578 ZyppSel slbPtr, ZyppObj objPtr )
582 if ( !slbPtr || !objPtr )
587 ZyppObj newCandidate = objPtr;
589 if ( newCandidate != slbPtr->candidateObj() )
591 yuiMilestone() <<
"CANDIDATE changed" << endl;
594 ZyppStatus status = slbPtr->status();
596 if ( slbPtr->installedObj() &&
597 slbPtr->installedObj()->edition() == newCandidate->edition() &&
598 slbPtr->installedObj()->vendor() == newCandidate->vendor()
601 yuiMilestone() <<
"Identical package installed" << endl;
604 status = S_KeepInstalled;
610 case S_KeepInstalled:
630 ok = bool( slbPtr->setCandidate( newCandidate ) );
631 yuiMilestone() <<
"Set user candidate returns: " << (ok?
"true":
"false") << endl;
635 ok = slbPtr->setStatus( status );
636 yuiMilestone() <<
"Set status of: " << slbPtr->name() <<
" to: "
637 << status <<
" returns: " << (ok?
"true":
"false") << endl;
652 MultiVersionStatStrategy::MultiVersionStatStrategy()
666 if ( !slbPtr || !objPtr )
668 yuiError() <<
"Selectable pointer not valid" << endl;
672 zypp::PoolItem itemPtr ( objPtr->satSolvable() );
673 return slbPtr->pickStatus( itemPtr );
683 ZyppSel slbPtr, ZyppObj objPtr )
687 if ( !slbPtr || !objPtr )
692 zypp::PoolItem itemPtr ( objPtr->satSolvable() );
693 ok = slbPtr->setPickStatus( itemPtr, newstatus );
694 yuiMilestone() <<
"Set new status of: "<< slbPtr->name() <<
", " << objPtr->edition()
695 <<
" to: " << newstatus <<
" returns: " << (ok?
"true":
"false") << endl;
707 UpdateStatStrategy::UpdateStatStrategy()
720 PatchPkgStatStrategy::PatchPkgStatStrategy()
726 ZyppSel slbPtr, ZyppObj objPtr )
virtual bool keyToStatus(const int &key, ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Returns the new status to the given key (respecting the old status of th eobject).
virtual bool toggleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Toggles the package status (e.g.
virtual bool toggleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Toggles the patch status (e.g.
virtual bool keyToStatus(const int &key, ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Returns the new status to the given key (respecting the old status of the patch). ...
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status.
virtual ZyppStatus getPackageStatus(ZyppSel slbPtr, ZyppObj objPtr)
Gets the status information from the package manager.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
It is not possible to std::set the package status for packages belonging to a patch, i.e.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status and additionally sets the candidate object to the us...
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Sets the status of the patch AND the status of the patch packages.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Sets the status of the selection.
virtual ZyppStatus getPackageStatus(ZyppSel slbPtr, ZyppObj objPtr)
Gets the status information from the package manager.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status and additionally sets the candidate object to the us...
void solveResolvableCollections()
Do a "small" solver run for all "resolvable collections", i.e., for selections, patterns, languages, patches.