summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:54:11 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:54:11 +0000
commit2fd65468b3cb25c725a709f9b470ced0ab4823a6 (patch)
treeca4ae9007380e92eac7b4c9b0ac14f0335413543
parent29f7b36cd63f16ceab825531b5c131eac4b99f9b (diff)
Fixed handling of missing files
Author: jgg Date: 1999-07-04 23:22:53 GMT Fixed handling of missing files
-rw-r--r--apt-pkg/orderlist.cc27
-rw-r--r--apt-pkg/orderlist.h4
-rw-r--r--apt-pkg/packagemanager.cc23
-rw-r--r--test/scratch.cc54
4 files changed, 85 insertions, 23 deletions
diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc
index c831e9a71..7cdea188e 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.4 1999/07/03 03:10:35 jgg Exp $
+// $Id: orderlist.cc,v 1.5 1999/07/04 23:22:53 jgg Exp $
/* ######################################################################
Order List - Represents and Manipulates an ordered list of packages.
@@ -89,6 +89,25 @@ pkgOrderList::~pkgOrderList()
delete [] Flags;
}
/*}}}*/
+// OrderList::IsMissing - Check if a file is missing /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgOrderList::IsMissing(PkgIterator Pkg)
+{
+ // Skip packages to erase
+ if (Cache[Pkg].Delete() == true)
+ return false;
+
+ // Skip Packages that need configure only.
+ if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
+ Cache[Pkg].Keep() == true)
+ return false;
+
+ if (FileList != 0 && FileList[Pkg->ID].empty() == false)
+ return false;
+ return true;
+}
+ /*}}}*/
// OrderList::DoRun - Does an order run /*{{{*/
// ---------------------------------------------------------------------
@@ -299,9 +318,9 @@ int pkgOrderList::OrderCompareA(const void *a, const void *b)
// 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 ((Res = BoolCompare(Me->IsMissing(A),
+ Me->IsMissing(B))) == 0)
+ return Res;
}
if (A.State() != pkgCache::PkgIterator::NeedsNothing &&
diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h
index 7a33b97cc..5456984e4 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.3 1999/07/03 03:10:35 jgg Exp $
+// $Id: orderlist.h,v 1.4 1999/07/04 23:22:53 jgg Exp $
/* ######################################################################
Order List - Represents and Manipulates an ordered list of packages.
@@ -99,7 +99,9 @@ class pkgOrderList
inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & States) == 0;};
+ bool IsMissing(PkgIterator Pkg);
void WipeFlags(unsigned long F);
+ void SetFileList(string *FileList) {this->FileList = FileList;};
// Accessors
inline iterator begin() {return List;};
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 8556687ad..9e2eee969 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.15 1999/07/03 03:10:35 jgg Exp $
+// $Id: packagemanager.cc,v 1.16 1999/07/04 23:22:53 jgg Exp $
/* ######################################################################
Package Manager - Abstacts the package manager
@@ -89,25 +89,14 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
bool pkgPackageManager::FixMissing()
{
pkgProblemResolver Resolve(Cache);
-
+ List->SetFileList(FileNames);
+
bool Bad = false;
for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
- // These don't need files
- if (Cache[I].Keep() == true)
- continue;
- if (Cache[I].Delete() == true)
- continue;
-
- // We have a filename
- if (FileNames[I->ID].empty() == false)
+ if (List->IsMissing(I) == false)
continue;
-
- // Skip Packages that need configure only.
- if (I.State() == pkgCache::PkgIterator::NeedsConfigure &&
- Cache[I].Keep() == true)
- continue;
-
+
// Okay, this file is missing and we need it. Mark it for keep
Bad = true;
Cache.MarkKeep(I);
@@ -526,7 +515,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
continue;
}
- if (Cache[Pkg].Delete() == false && FileNames[Pkg->ID].empty() == true)
+ if (List->IsMissing(Pkg) == true)
{
if (Debug == true)
clog << "Sequence completed at" << Pkg.Name() << endl;
diff --git a/test/scratch.cc b/test/scratch.cc
index d3ca58a77..c48f3f594 100644
--- a/test/scratch.cc
+++ b/test/scratch.cc
@@ -1,11 +1,63 @@
+#include <string>
+/*void basic_string<char,string_char_traits<char>,alloc>::Rep::release()
+{
+ cout << "Release " << (void *)this << ' ' << ref << endl;
+ if (--ref == 0) delete this;
+}
+
+basic_string<char,string_char_traits<char>,alloc>::~basic_string()
+{
+ cout << "Destroy " << (void *)this << ',' << rep()->ref << endl;
+ rep ()->release ();
+}*/
+
+
+
#include <apt-pkg/tagfile.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/cachefile.h>
+#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/init.h>
+
#include <signal.h>
#include <stdio.h>
+#include <malloc.h>
+
+struct Rep
+{
+ size_t len, res, ref;
+ bool selfish;
+};
int main(int argc,char *argv[])
{
+ pkgCacheFile Cache;
+ OpProgress Prog;
+ pkgInitialize(*_config);
+ if (Cache.Open(Prog,false) == false)
+ {
+ _error->DumpErrors();
+ return 0;
+ }
+
+ pkgRecords rec(*Cache);
+ while (1)
+ {
+ pkgCache::VerIterator V = (*Cache)[Cache->PkgBegin()].CandidateVerIter(*Cache);
+ pkgRecords::Parser &Parse = rec.Lookup(V.FileList());
+ string Foo = Parse.ShortDesc();
+
+ cout << (reinterpret_cast<Rep *>(Foo.begin()) - 1)[0].ref << endl;
+
+// cout << Foo << endl;
+
+// cout << rec.Lookup(V.FileList()).ShortDesc() << endl;
+ malloc_stats();
+ }
+
+#if 0
URI U(argv[1]);
cout << U.Access << endl;
cout << U.User << endl;
@@ -26,6 +78,6 @@ int main(int argc,char *argv[])
Sect.FindS("Version");
Sect.FindI("Size");
};*/
-
+#endif
return 0;
}