Author: jgg
Date: 1999-07-04 23:22:53 GMT
Fixed handling of missing files
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- 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.
/* ######################################################################
Order List - Represents and Manipulates an ordered list of packages.
delete [] Flags;
}
/*}}}*/
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 /*{{{*/
// ---------------------------------------------------------------------
// OrderList::DoRun - Does an order run /*{{{*/
// ---------------------------------------------------------------------
// We order missing files to toward the end
if (Me->FileList != 0)
{
// 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 &&
}
if (A.State() != pkgCache::PkgIterator::NeedsNothing &&
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- 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.
/* ######################################################################
Order List - Represents and Manipulates an ordered list of packages.
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;};
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 WipeFlags(unsigned long F);
+ void SetFileList(string *FileList) {this->FileList = FileList;};
// Accessors
inline iterator begin() {return List;};
// Accessors
inline iterator begin() {return List;};
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- 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
/* ######################################################################
Package Manager - Abstacts the package manager
bool pkgPackageManager::FixMissing()
{
pkgProblemResolver Resolve(Cache);
bool pkgPackageManager::FixMissing()
{
pkgProblemResolver Resolve(Cache);
+ List->SetFileList(FileNames);
+
bool Bad = false;
for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
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)
-
- // 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);
// Okay, this file is missing and we need it. Mark it for keep
Bad = true;
Cache.MarkKeep(I);
- 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;
{
if (Debug == true)
clog << "Sequence completed at" << Pkg.Name() << endl;
+#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/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 <signal.h>
#include <stdio.h>
+#include <malloc.h>
+
+struct Rep
+{
+ size_t len, res, ref;
+ bool selfish;
+};
int main(int argc,char *argv[])
{
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;
URI U(argv[1]);
cout << U.Access << endl;
cout << U.User << endl;
Sect.FindS("Version");
Sect.FindI("Size");
};*/
Sect.FindS("Version");
Sect.FindI("Size");
};*/