diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire.cc | 18 | ||||
-rw-r--r-- | apt-pkg/acquire.h | 9 | ||||
-rw-r--r-- | apt-pkg/algorithms.cc | 7 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 10 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.h | 3 | ||||
-rw-r--r-- | apt-pkg/orderlist.cc | 104 | ||||
-rw-r--r-- | apt-pkg/orderlist.h | 5 | ||||
-rw-r--r-- | apt-pkg/packagemanager.cc | 82 | ||||
-rw-r--r-- | apt-pkg/packagemanager.h | 13 |
9 files changed, 182 insertions, 69 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 734f5e7ab..6ea1e3526 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire.cc,v 1.36 1999/06/13 05:06:40 jgg Exp $ +// $Id: acquire.cc,v 1.37 1999/07/03 03:10:35 jgg Exp $ /* ###################################################################### Acquire - File Acquiration @@ -53,15 +53,23 @@ pkgAcquire::pkgAcquire(pkgAcquireStatus *Log) : Log(Log) /* Free our memory, clean up the queues (destroy the workers) */ pkgAcquire::~pkgAcquire() { - while (Items.size() != 0) - delete Items[0]; - while (Configs != 0) { MethodConfig *Jnk = Configs; Configs = Configs->Next; delete Jnk; } + + Shutdown(); +} + /*}}}*/ +// pkgAcquire::Shutdown - Clean out the acquire object /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgAcquire::Shutdown() +{ + while (Items.size() != 0) + delete Items[0]; while (Queues != 0) { @@ -125,7 +133,7 @@ void pkgAcquire::Remove(Worker *Work) // Acquire::Enqueue - Queue an URI for fetching /*{{{*/ // --------------------------------------------------------------------- /* This is the entry point for an item. An item calls this function when - it is construction which creates a queue (based on the current queue + it is constructed which creates a queue (based on the current queue mode) and puts the item in that queue. If the system is running then the queue might be started. */ void pkgAcquire::Enqueue(ItemDesc &Item) diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 6a1583cca..447761521 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire.h,v 1.21 1999/06/13 05:06:40 jgg Exp $ +// $Id: acquire.h,v 1.22 1999/07/03 03:10:35 jgg Exp $ /* ###################################################################### Acquire - File Acquiration @@ -82,8 +82,8 @@ class pkgAcquire string QueueName(string URI,MethodConfig const *&Config); // FDSET managers for derived classes - void SetFds(int &Fd,fd_set *RSet,fd_set *WSet); - void RunFds(fd_set *RSet,fd_set *WSet); + virtual void SetFds(int &Fd,fd_set *RSet,fd_set *WSet); + virtual void RunFds(fd_set *RSet,fd_set *WSet); // A queue calls this when it dequeues an item void Bump(); @@ -95,7 +95,8 @@ class pkgAcquire enum RunResult {Continue,Failed,Cancelled}; RunResult Run(); - + void Shutdown(); + // Simple iteration mechanism inline Worker *WorkersBegin() {return Workers;}; Worker *WorkerStep(Worker *I); diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 60da32d78..21db98941 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: algorithms.cc,v 1.19 1999/06/28 03:11:24 jgg Exp $ +// $Id: algorithms.cc,v 1.20 1999/07/03 03:10:35 jgg Exp $ /* ###################################################################### Algorithms - A set of misc algorithms @@ -33,6 +33,11 @@ pkgSimulate::pkgSimulate(pkgDepCache &Cache) : pkgPackageManager(Cache), { Flags = new unsigned char[Cache.HeaderP->PackageCount]; memset(Flags,0,sizeof(*Flags)*Cache.HeaderP->PackageCount); + + // Fake a filename so as not to activate the media swapping + string Jnk = "SIMULATE"; + for (int I = 0; I != Cache.Head().PackageCount; I++) + FileNames[I] = Jnk; } /*}}}*/ // Simulate::Install - Simulate unpacking of a package /*{{{*/ diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 478b119cf..998750b3b 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: dpkgpm.cc,v 1.9 1999/04/20 05:02:09 jgg Exp $ +// $Id: dpkgpm.cc,v 1.10 1999/07/03 03:10:35 jgg Exp $ /* ###################################################################### DPKG Package Manager - Provide an interface to dpkg @@ -299,3 +299,11 @@ bool pkgDPkgPM::Go() return true; } /*}}}*/ +// pkgDpkgPM::Reset - Dump the contents of the command list /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgDPkgPM::Reset() +{ + List.erase(List.begin(),List.end()); +} + /*}}}*/ diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index db6ce2a28..d7898daf1 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: dpkgpm.h,v 1.3 1999/01/31 08:49:39 jgg Exp $ +// $Id: dpkgpm.h,v 1.4 1999/07/03 03:10:35 jgg Exp $ /* ###################################################################### DPKG Package Manager - Provide an interface to dpkg @@ -41,6 +41,7 @@ class pkgDPkgPM : public pkgPackageManager virtual bool Configure(PkgIterator Pkg); virtual bool Remove(PkgIterator Pkg); virtual bool Go(); + virtual void Reset(); public: diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 04d8c4c7e..c831e9a71 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: orderlist.cc,v 1.3 1998/09/26 05:34:21 jgg Exp $ +// $Id: orderlist.cc,v 1.4 1999/07/03 03:10:35 jgg Exp $ /* ###################################################################### Order List - Represents and Manipulates an ordered list of packages. @@ -42,7 +42,7 @@ arbitary priority to give quite abit of control over the final unpacking order. - The rules listed above my never be violated and are called Critical. + The rules listed above may never be violated and are called Critical. When a critical rule is violated then a loop condition is recorded and will have to be delt with in the caller. @@ -65,6 +65,7 @@ pkgOrderList *pkgOrderList::Me = 0; /* */ pkgOrderList::pkgOrderList(pkgDepCache &Cache) : Cache(Cache) { + FileList = 0; Primary = 0; Secondary = 0; RevDepends = 0; @@ -93,7 +94,7 @@ pkgOrderList::~pkgOrderList() // --------------------------------------------------------------------- /* The caller is expeted to have setup the desired probe state */ bool pkgOrderList::DoRun() -{ +{ // Temp list unsigned long Size = Cache.HeaderP->PackageCount; Package **NList = new Package *[Size]; @@ -128,6 +129,8 @@ bool pkgOrderList::DoRun() fatal and indicate that the packages cannot be installed. */ bool pkgOrderList::OrderCritical() { + FileList = 0; + Primary = &DepUnPackPre; Secondary = 0; RevDepends = 0; @@ -150,8 +153,10 @@ bool pkgOrderList::OrderCritical() // --------------------------------------------------------------------- /* This performs complete unpacking ordering and creates an order that is suitable for unpacking */ -bool pkgOrderList::OrderUnpack() +bool pkgOrderList::OrderUnpack(string *FileList) { + this->FileList = FileList; + Primary = &DepUnPackCrit; Secondary = &DepConfigure; RevDepends = &DepUnPackDep; @@ -161,7 +166,7 @@ bool pkgOrderList::OrderUnpack() // Sort Me = this; qsort(List,End - List,sizeof(*List),&OrderCompareA); - + if (DoRun() == false) return false; @@ -197,6 +202,7 @@ bool pkgOrderList::OrderUnpack() for configuration */ bool pkgOrderList::OrderConfigure() { + FileList = 0; Primary = &DepConfigure; Secondary = 0; RevDepends = 0; @@ -214,7 +220,11 @@ int pkgOrderList::Score(PkgIterator Pkg) // Removal is always done first if (Cache[Pkg].Delete() == true) return 200; - + + // This should never happen.. + if (Cache[Pkg].InstVerIter(Cache).end() == true) + return -1; + int Score = 0; if ((Pkg->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) Score += 100; @@ -248,7 +258,7 @@ int pkgOrderList::FileCmp(PkgIterator A,PkgIterator B) if (Cache[A].InstVerIter(Cache).FileList().end() == true) return -1; - if (Cache[A].InstVerIter(Cache).FileList().end() == true) + if (Cache[B].InstVerIter(Cache).FileList().end() == true) return 1; pkgCache::PackageFile *FA = Cache[A].InstVerIter(Cache).FileList().File(); @@ -260,6 +270,18 @@ int pkgOrderList::FileCmp(PkgIterator A,PkgIterator B) return 0; } /*}}}*/ +// BoolCompare - Comparison function for two booleans /*{{{*/ +// --------------------------------------------------------------------- +/* */ +static int BoolCompare(bool A,bool B) +{ + if (A == B) + return 0; + if (A == false) + return -1; + return 1; +} + /*}}}*/ // OrderList::OrderCompareA - Order the installation by op /*{{{*/ // --------------------------------------------------------------------- /* This provides a first-pass sort of the list and gives a decent starting @@ -269,6 +291,19 @@ int pkgOrderList::OrderCompareA(const void *a, const void *b) PkgIterator A(Me->Cache,*(Package **)a); PkgIterator B(Me->Cache,*(Package **)b); + // We order packages with a set state toward the front + int Res; + if ((Res = BoolCompare(Me->IsNow(A),Me->IsNow(B))) == 0) + return -1*Res; + + // We order missing files to toward the end + if (Me->FileList != 0) + { + if ((Res = BoolCompare(Me->FileList[A->ID].empty() && !Me->Cache[A].Delete(), + Me->FileList[B->ID].empty() && !Me->Cache[B].Delete())) == 0) + return -1*Res; + } + if (A.State() != pkgCache::PkgIterator::NeedsNothing && B.State() == pkgCache::PkgIterator::NeedsNothing) return -1; @@ -419,34 +454,37 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg) // Perform immedate configuration of the package if so flagged. if (IsFlag(Pkg,Immediate) == true && Primary != &DepUnPackPre) Primary = &DepUnPackPreD; - - bool Res = true; - if (Cache[Pkg].Delete() == false) + + if (IsNow(Pkg) == true) { - // Primary - Res &= Res && VisitDeps(Primary,Pkg); - Res &= Res && VisitRDeps(Primary,Pkg); - Res &= Res && VisitRProvides(Primary,Pkg.CurrentVer()); - Res &= Res && VisitRProvides(Primary,Cache[Pkg].InstVerIter(Cache)); - - // RevDep - Res &= Res && VisitRDeps(RevDepends,Pkg); - Res &= Res && VisitRProvides(RevDepends,Pkg.CurrentVer()); - Res &= Res && VisitRProvides(RevDepends,Cache[Pkg].InstVerIter(Cache)); - - // Secondary - Res &= Res && VisitDeps(Secondary,Pkg); - Res &= Res && VisitRDeps(Secondary,Pkg); - Res &= Res && VisitRProvides(Secondary,Pkg.CurrentVer()); - Res &= Res && VisitRProvides(Secondary,Cache[Pkg].InstVerIter(Cache)); - } - else - { - // RevDep - Res &= Res && VisitRDeps(Remove,Pkg); - Res &= Res && VisitRProvides(Remove,Pkg.CurrentVer()); + bool Res = true; + if (Cache[Pkg].Delete() == false) + { + // Primary + Res &= Res && VisitDeps(Primary,Pkg); + Res &= Res && VisitRDeps(Primary,Pkg); + Res &= Res && VisitRProvides(Primary,Pkg.CurrentVer()); + Res &= Res && VisitRProvides(Primary,Cache[Pkg].InstVerIter(Cache)); + + // RevDep + Res &= Res && VisitRDeps(RevDepends,Pkg); + Res &= Res && VisitRProvides(RevDepends,Pkg.CurrentVer()); + Res &= Res && VisitRProvides(RevDepends,Cache[Pkg].InstVerIter(Cache)); + + // Secondary + Res &= Res && VisitDeps(Secondary,Pkg); + Res &= Res && VisitRDeps(Secondary,Pkg); + Res &= Res && VisitRProvides(Secondary,Pkg.CurrentVer()); + Res &= Res && VisitRProvides(Secondary,Cache[Pkg].InstVerIter(Cache)); + } + else + { + // RevDep + Res &= Res && VisitRDeps(Remove,Pkg); + Res &= Res && VisitRProvides(Remove,Pkg.CurrentVer()); + } } - + if (IsFlag(Pkg,Added) == false) { Flag(Pkg,Added,Added | AddPending); diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index 2065fc4c8..7a33b97cc 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: orderlist.h,v 1.2 1998/07/12 23:58:29 jgg Exp $ +// $Id: orderlist.h,v 1.3 1999/07/03 03:10:35 jgg Exp $ /* ###################################################################### Order List - Represents and Manipulates an ordered list of packages. @@ -48,6 +48,7 @@ class pkgOrderList // State Package **End; Package **List; + string *FileList; DepIterator Loops[20]; int LoopCount; int Depth; @@ -111,7 +112,7 @@ class pkgOrderList // Ordering modes bool OrderCritical(); - bool OrderUnpack(); + bool OrderUnpack(string *FileList = 0); bool OrderConfigure(); int Score(PkgIterator Pkg); diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 3b09871e5..8556687ad 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: packagemanager.cc,v 1.14 1999/02/21 08:38:53 jgg Exp $ +// $Id: packagemanager.cc,v 1.15 1999/07/03 03:10:35 jgg Exp $ /* ###################################################################### Package Manager - Abstacts the package manager @@ -60,7 +60,8 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) { PkgIterator Pkg(Cache,*I); - + FileNames[Pkg->ID] = string(); + // Skip packages to erase if (Cache[Pkg].Delete() == true) continue; @@ -69,7 +70,11 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && Cache[Pkg].Keep() == true) continue; - + + // Skip already processed packages + if (List->IsNow(Pkg) == false) + continue; + new pkgAcqArchive(Owner,Sources,Recs,Cache[Pkg].InstVerIter(Cache), FileNames[Pkg->ID]); } @@ -122,6 +127,9 @@ bool pkgPackageManager::FixMissing() going to change. */ bool pkgPackageManager::CreateOrderList() { + if (List != 0) + return true; + delete List; List = new pkgOrderList(Cache); @@ -487,58 +495,96 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) // PM::OrderInstall - Installation ordering routine /*{{{*/ // --------------------------------------------------------------------- /* */ -bool pkgPackageManager::OrderInstall() +pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() { if (CreateOrderList() == false) - return false; + return Failed; + + Reset(); if (Debug == true) clog << "Begining to order" << endl; - - if (List->OrderUnpack() == false) - return _error->Error("Internal ordering error"); + if (List->OrderUnpack(FileNames) == false) + { + _error->Error("Internal ordering error"); + return Failed; + } + if (Debug == true) clog << "Done ordering" << endl; + bool DoneSomething = false; for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) { PkgIterator Pkg(Cache,*I); + + if (List->IsNow(Pkg) == false) + { + if (Debug == true) + clog << "Skipping already done " << Pkg.Name() << endl; + continue; + } + + if (Cache[Pkg].Delete() == false && FileNames[Pkg->ID].empty() == true) + { + if (Debug == true) + clog << "Sequence completed at" << Pkg.Name() << endl; + if (DoneSomething == false) + { + _error->Error("Internal Error, ordering was unable to handle the media swap"); + return Failed; + } + return Incomplete; + } // Sanity check if (Cache[Pkg].Keep() == true && Pkg.State() == pkgCache::PkgIterator::NeedsNothing) - return _error->Error("Internal Error, trying to manipulate a kept package"); + { + _error->Error("Internal Error, trying to manipulate a kept package"); + return Failed; + } // Perform a delete or an install if (Cache[Pkg].Delete() == true) { if (SmartRemove(Pkg) == false) - return false; + return Failed; } else if (SmartUnPack(Pkg) == false) - return false; + return Failed; + DoneSomething = true; } // Final run through the configure phase if (ConfigureAll() == false) - return false; + return Failed; // Sanity check for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + { if (List->IsFlag(*I,pkgOrderList::Configured) == false) - return _error->Error("Internal error, packages left unconfigured. %s", - PkgIterator(Cache,*I).Name()); - - return true; + { + _error->Error("Internal error, packages left unconfigured. %s", + PkgIterator(Cache,*I).Name()); + return Failed; + } + } + + return Completed; } /*}}}*/ // PM::DoInstall - Does the installation /*{{{*/ // --------------------------------------------------------------------- /* This uses the filenames in FileNames and the information in the DepCache to perform the installation of packages.*/ -bool pkgPackageManager::DoInstall() +pkgPackageManager::OrderResult pkgPackageManager::DoInstall() { - return OrderInstall() && Go(); + OrderResult Res = OrderInstall(); + if (Res != Failed) + if (Go() == false) + return Failed; + return Res; } /*}}}*/ diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index 5265c315c..6dbf94def 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: packagemanager.h,v 1.7 1998/11/22 23:37:06 jgg Exp $ +// $Id: packagemanager.h,v 1.8 1999/07/03 03:10:35 jgg Exp $ /* ###################################################################### Package Manager - Abstacts the package manager @@ -38,6 +38,10 @@ class pkgOrderList; class pkgRecords; class pkgPackageManager { + public: + + enum OrderResult {Completed,Failed,Incomplete}; + protected: string *FileNames; pkgDepCache &Cache; @@ -53,7 +57,7 @@ class pkgPackageManager typedef pkgCache::Package Package; bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0); - bool OrderInstall(); + OrderResult OrderInstall(); bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver); bool CreateOrderList(); @@ -72,13 +76,14 @@ class pkgPackageManager virtual bool Configure(PkgIterator /*Pkg*/) {return false;}; virtual bool Remove(PkgIterator /*Pkg*/) {return false;}; virtual bool Go() {return true;}; + virtual void Reset() {}; public: - + // Main action members bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, pkgRecords *Recs); - bool DoInstall(); + OrderResult DoInstall(); bool FixMissing(); pkgPackageManager(pkgDepCache &Cache); |