+// PM::CreateOrderList - Create the ordering class /*{{{*/
+// ---------------------------------------------------------------------
+/* This populates the ordering list with all the packages that are
+ going to change. */
+bool pkgPackageManager::CreateOrderList()
+{
+ if (List != 0)
+ return true;
+
+ delete List;
+ List = new pkgOrderList(&Cache);
+
+ bool NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true);
+
+ // Generate the list of affected packages and sort it
+ for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+ {
+ // Ignore no-version packages
+ if (I->VersionList == 0)
+ continue;
+
+ // Mark the package and its dependends for immediate configuration
+ if (((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential ||
+ (I->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important) &&
+ NoImmConfigure == false)
+ {
+ List->Flag(I,pkgOrderList::Immediate);
+
+ // Look for other packages to make immediate configurea
+ if (Cache[I].InstallVer != 0)
+ for (DepIterator D = Cache[I].InstVerIter(Cache).DependsList();
+ D.end() == false; D++)
+ if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
+ List->Flag(D.TargetPkg(),pkgOrderList::Immediate);
+
+ // And again with the current version.
+ if (I->CurrentVer != 0)
+ for (DepIterator D = I.CurrentVer().DependsList();
+ D.end() == false; D++)
+ if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
+ List->Flag(D.TargetPkg(),pkgOrderList::Immediate);
+ }
+
+ // Not interesting
+ if ((Cache[I].Keep() == true ||
+ Cache[I].InstVerIter(Cache) == I.CurrentVer()) &&
+ I.State() == pkgCache::PkgIterator::NeedsNothing &&
+ (Cache[I].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall &&
+ (I.Purge() != false || Cache[I].Mode != pkgDepCache::ModeDelete ||
+ (Cache[I].iFlags & pkgDepCache::Purge) != pkgDepCache::Purge))
+ continue;
+
+ // Append it to the list
+ List->push_back(I);
+ }
+
+ return true;
+}
+ /*}}}*/