[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

kdenonbeta/kdedebian/kapture/libcapture



CVS commit by mornfall: 

Implement the load and initialization of extended state. It is stored in
working directory, in file debug-libcapture.extstate, for now. If the
file does not exist, kapture will initialize it from cache by simulating
installation of every already-installed package. Due to AMAS system
employed by pkgcache.cpp, this can take quite a bit of time (~ 70
seconds on my system). I'll try to reduce this, but i guess i'll have to
implement progress bar for it anyway. Will see...


  M +20 -3     pkgcache.cpp   1.15


--- kdenonbeta/kdedebian/kapture/libcapture/pkgcache.cpp  #1.14:1.15
@@ -68,4 +68,6 @@
 #include <apt-pkg/init.h>
 #include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/tagfile.h>
 #include "pkgcache.h"
 #include "grouper.h"
@@ -561,8 +563,9 @@ void PkgCache::processPriAgents ()
 bool PkgCache::initExtState (std::string file)
 {
-    if (access (file . c_str (), R_OK)) {
+    if (! access (file . c_str (), R_OK)) {
         if (loadExtState (file))
             return true;
     }
+    cerr << "loading extended state failed, initializing..." << endl;
     for (PkgIterator mP = PkgBegin (); ! mP . end (); mP ++) {
         ExtState *es = m_es + mP -> ID;
@@ -576,5 +579,5 @@ bool PkgCache::initExtState (std::string
         }
     }
-    // XXX: processPriAgents ();
+    processPriAgents ();
 }
                                                                     /* }}} */
@@ -582,5 +585,19 @@ bool PkgCache::initExtState (std::string
 bool PkgCache::loadExtState (std::string file)
 {
-    return false;
+    FileFd fd (file, FileFd::ReadOnly);
+    pkgTagFile f (& fd);
+    pkgTagSection s;
+    cerr << "loading extended state..." << endl;
+    while (f . Step (s)) {
+        string pkg = s . FindS ("package");
+        PkgIterator P = Cache -> FindPkg (pkg);
+        ExtState *es = m_es + P -> ID;
+        es -> u_wanted = s . FindI ("wanted");
+        es -> pri = s . FindI ("priority");
+        es -> a_wanted_pri = s . FindI ("WantPri"); // XXX: cache?
+        es -> a_unwanted_pri = s . FindI ("UnWantPri");
+        // cerr << "loading: " << pkg << "wanted: " << es -> a_wanted_pri << endl;
+    }
+    return true;
 }
                                                                     /* }}} */




Reply to: