Fixed handling of missing files
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:54:11 +0000 (16:54 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:54:11 +0000 (16:54 +0000)
Author: jgg
Date: 1999-07-04 23:22:53 GMT
Fixed handling of missing files

apt-pkg/orderlist.cc
apt-pkg/orderlist.h
apt-pkg/packagemanager.cc
test/scratch.cc

index c831e9a..7cdea18 100644 (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 && 
index 7a33b97..5456984 100644 (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;};
index 8556687..9e2eee9 100644 (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;
index d3ca58a..c48f3f5 100644 (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;
 }