Does not work with preferences.d

Bug #668297 reported by Julian Andres Klode
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
qapt (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

You must also call ReadPinDir(), not just ReadPinFile() in order to work correctly with preferences.d - My suggestion would be to use pkgCacheFile instead of pkgCache and friends anyway.

Revision history for this message
Jonathan Thomas (echidnaman) wrote : extragear/sysadmin/libqapt/src

SVN commit 1191149 by jmthomas:

Also read the pin file so that settings in /etc/apt/preferences.d/ will work as well.
I'll see about using pkgCacheFile in QApt::Cache once I can get a feel for how it works/what I'll have to do differently in Cache to maintain binary compatibility, etc.

CCMAIL: <email address hidden>

 M +1 -1 cache.cpp

--- trunk/extragear/sysadmin/libqapt/src/cache.cpp #1191148:1191149
@@ -123,7 +123,7 @@
     // Open the cache file
     d->cache = new pkgCache(d->mmap);
     d->policy = new pkgPolicy(d->cache);
- if (!ReadPinFile(*(d->policy))) {
+ if (!ReadPinFile(*(d->policy)) || !ReadPinDir(*(d->policy))) {
         return false;
     }

Revision history for this message
Jonathan Thomas (echidnaman) wrote :

Fix committed for QApt 1.1, and also backported to the 1.0.x branch.
Thanks!

Changed in qapt (Ubuntu):
status: New → Fix Committed
Revision history for this message
Jonathan Thomas (echidnaman) wrote :
Download full text (3.5 KiB)

SVN commit 1191219 by jmthomas:

Use libapt-pkg's pkgCacheFile for a bunch of cache-related stuff inside QApt::Cache, rather than rolling our own. This results in the nice loss of 51 lines of code.
The class will stay due to the trustCache stuff it implements (and obviously binary/API compatibility) Whenever the need arises for a QApt2 (API break) this will likely become a thin(er) wrapper over the pkgCacheFile, with its main objective being to provide a Qt-style API. (Hopefully a trustCache solution will make it in to APT in the meanwhile, so that we and synaptic don't have to have two imlementations)

But, in the meantime, less stuff to maintain/worry about breaking. :)

CCMAIL:<email address hidden>

 M +10 -62 cache.cpp

--- trunk/extragear/sysadmin/libqapt/src/cache.cpp #1191218:1191219
@@ -22,11 +22,7 @@

 #include <QtCore/QCoreApplication>

-#include <apt-pkg/depcache.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/pkgcachegen.h>
-#include <apt-pkg/policy.h>
+#include <apt-pkg/cachefile.h>

 namespace QApt {

@@ -45,34 +41,20 @@
 {
 public:
     CachePrivate()
- : mmap(0)
- , cache(0)
- , policy(0)
- , depCache(0)
- , list(new pkgSourceList)
+ : cache(new pkgCacheFile())
         , trustCache(new QHash<pkgCache::PkgFileIterator, pkgIndexFile*>)
     {
     }

     virtual ~CachePrivate()
     {
- delete list;
         delete cache;
- delete policy;
- delete depCache;
- delete mmap;
         delete trustCache;
     }

- CacheBuildProgress m_progressMeter;
- MMap *mmap;
+ CacheBuildProgress progressMeter;
+ pkgCacheFile *cache;

- pkgCache *cache;
- pkgPolicy *policy;
-
- pkgDepCache *depCache;
- pkgSourceList *list;
-
     QHash<pkgCache::PkgFileIterator, pkgIndexFile*> *trustCache;
 };

@@ -92,51 +74,17 @@
     Q_D(Cache);

    // delete any old structures
- if (d->cache) {
- delete d->cache;
- d->cache = 0;
- }
- if (d->policy) {
- delete d->policy;
- d->policy = 0;
- }
- if (d->depCache) {
- delete d->depCache;
- d->depCache = 0;
- }
- if (d->mmap) {
- delete d->mmap;
- d->mmap = 0;
- }
+ d->cache->Close();

- // Read the sources list
- if (!d->list->ReadMainList()) {
- return false;
- }
-
- pkgMakeStatusCache(*(d->list), d->m_progressMeter, &(d->mmap), true);
- d->m_progressMeter.Done();
- if (_error->PendingError()) {
- return false;
- }
-
     // Open the cache file
- d->cache = new pkgCache(d->mmap);
- d->policy = new pkgPolicy(d->cache);
- if (!ReadPinFile(*(d->policy)) || !ReadPinDir(*(d->policy))) {
+ if (!d->cache->ReadOnlyOpen(&d->progressMeter)) {
         return false;
     }

- if (_error->PendingError()) {
- return false;
- }
-
- d->depCache = new pkgDepCache(d->cache, d->policy);
- d->depCache->Init(&(d->m_progressMeter));
-
     d->trustCache->clear();

- if (d->depCache->DelCount() != 0 || d->depCache->InstCount() != 0) {
+ if (d->cache->GetDepCache()->DelCount() != 0 ||
+ d->cache->GetDepCache()->InstCount() ...

Read more...

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qapt - 1.0.60-0ubuntu1

---------------
qapt (1.0.60-0ubuntu1) natty; urgency=low

  * New upstream release: (LP: #490353, #668297, #670294)
    - Bump build-depend version on libapt-pkg-dev to 0.8.0 or higher
    - Update libqapt1.symbols
  * Bump Standards-Version to 3.9.1, no changes
 -- Jonathan Thomas <email address hidden> Mon, 01 Nov 2010 22:46:18 -0400

Changed in qapt (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.