Browse Source

Fixed handling of missing files

Author: jgg
Date: 1999-07-04 23:22:53 GMT
Fixed handling of missing files
tags/debian/0.7.21
Arch Librarian 17 years ago
parent
commit
2fd65468b3
4 changed files with 85 additions and 23 deletions
  1. +23
    -4
      apt-pkg/orderlist.cc
  2. +3
    -1
      apt-pkg/orderlist.h
  3. +6
    -17
      apt-pkg/packagemanager.cc
  4. +53
    -1
      test/scratch.cc

+ 23
- 4
apt-pkg/orderlist.cc View File

@@ -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 &&


+ 3
- 1
apt-pkg/orderlist.h View File

@@ -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;};


+ 6
- 17
apt-pkg/packagemanager.cc View File

@@ -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;


+ 53
- 1
test/scratch.cc View File

@@ -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;
}

Loading…
Cancel
Save