- /* Because of the ordered list, most dependancies should be unpacked,
- however if there is a loop this is not the case, so check for dependancies before configuring.
- This is done after the package installation as it makes it easier to deal with conflicts problems */
- bool Bad = true;
- for (DepIterator D = instVer.DependsList();
- D.end() == false; )
- {
- // Compute a single dependency element (glob or)
- pkgCache::DepIterator Start;
- pkgCache::DepIterator End;
- D.GlobOr(Start,End);
-
- if (End->Type == pkgCache::Dep::Depends)
- Bad = true;
-
- // Check for dependanices that have not been unpacked, probably due to loops.
- while (End->Type == pkgCache::Dep::Depends) {
- PkgIterator DepPkg;
- VerIterator InstallVer;
- SPtrArray<Version *> VList = Start.AllTargets();
-
- for (Version **I = VList; *I != 0; I++) {
- VerIterator Ver(Cache,*I);
- DepPkg = Ver.ParentPkg();
-
- if (!Bad) continue;
-
- InstallVer = VerIterator(Cache,Cache[DepPkg].InstallVer);
- VerIterator CandVer(Cache,Cache[DepPkg].CandidateVer);
-
- if (Debug && false) {
- if (Ver==0) {
- cout << " Checking if " << Ver << " of " << DepPkg.Name() << " satisfies this dependancy" << endl;
- } else {
- cout << " Checking if " << Ver.VerStr() << " of " << DepPkg.Name() << " satisfies this dependancy" << endl;
- }
-
- if (DepPkg.CurrentVer()==0) {
- cout << " CurrentVer " << DepPkg.CurrentVer() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl;
- } else {
- cout << " CurrentVer " << DepPkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl;
- }
-
- if (InstallVer==0) {
- cout << " InstallVer " << InstallVer << endl;
- } else {
- cout << " InstallVer " << InstallVer.VerStr() << endl;
- }
- if (CandVer != 0)
- cout << " CandVer " << CandVer.VerStr() << endl;
-
- cout << " Keep " << Cache[DepPkg].Keep() << " Unpacked " << List->IsFlag(DepPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(DepPkg,pkgOrderList::Configured) << endl;
-
- }
-
- // Check if it satisfies this dependancy
- if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true &&
- DepPkg.State() == PkgIterator::NeedsNothing)
- {
- Bad = false;
- continue;
- }
-
- if (Cache[DepPkg].InstallVer == *I && !List->IsNow(DepPkg)) {
- Bad = false;
- continue;
- }
- }
-
- if (InstallVer != 0 && Bad) {
- Bad = false;
- // Found a break, so unpack the package
- List->Flag(Pkg,pkgOrderList::Loop);
- if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) {
- if (Debug)
- cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl;
- SmartUnPack(DepPkg, false);
- }
- }
-
- if (Start==End) {
- if (Bad && Debug) {
- if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) {
- _error->Warning("Could not satisfy dependancies for %s",Pkg.Name());
- }
- }
- break;
-
- } else {
- Start++;
- }
- }