summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2012-04-15 15:48:32 -0300
committerDaniel Nicoletti <dantti12@gmail.com>2012-04-15 15:48:32 -0300
commit3edfc7d9c81df85e1244781abb1890ad9332877d (patch)
tree93414958c13305bae505116c8ebc9ff57644df47
parentae6b2c8725c979e6e3bab9b2756fc46c6ebeab90 (diff)
aptcc: Forgot to return the package found
-rw-r--r--backends/aptcc/AptCacheFile.h11
-rw-r--r--backends/aptcc/apt-intf.cpp22
-rw-r--r--backends/aptcc/apt-intf.h8
3 files changed, 27 insertions, 14 deletions
diff --git a/backends/aptcc/AptCacheFile.h b/backends/aptcc/AptCacheFile.h
index 809283b2..dc884645 100644
--- a/backends/aptcc/AptCacheFile.h
+++ b/backends/aptcc/AptCacheFile.h
@@ -39,11 +39,18 @@ public:
bool buildCaches(bool withLock = false);
inline pkgRecords* GetPkgRecords() { buildPkgRecords(); return m_packageRecords; }
+
+ /**
+ * GetPolicy will build the policy object if needed and return it
+ * @note This override if because the cache should be built before the policy
+ */
+ inline pkgPolicy* GetPolicy() { BuildCaches(NULL, false); BuildPolicy(); return Policy; }
+
/**
* GetDepCache will build the dependency cache if needed and return it
- * @note This override if because the policy should be built before the cache
+ * @note This override if because the policy should be built before the dependency cache
*/
- inline pkgDepCache* GetDepCache() { BuildPolicy(); BuildDepCache(); return DCache; }
+ inline pkgDepCache* GetDepCache() { BuildCaches(NULL, false); BuildPolicy(); BuildDepCache(); return DCache; }
private:
void buildPkgRecords();
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index 414e9fc0..d6a030ba 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -93,9 +93,8 @@ bool AptIntf::init()
setenv("ftp_proxy", ftp_proxy, 1);
// Tries to open the cache
-// if (!m_cache.open()) {
-// return false;
-// }
+// return !m_cache.open();
+ return false; // WTF why it was expecting this?
}
AptIntf::~AptIntf()
@@ -114,9 +113,14 @@ void AptIntf::cancel()
}
}
-pkgCache::PkgIterator AptIntf::findPackage(const std::string &packageName)
+pkgCache::PkgIterator AptIntf::findPackage(const std::string &name)
{
- m_cache.GetPkgCache()->FindPkg(packageName);
+ return m_cache.GetDepCache()->FindPkg(name);
+}
+
+pkgCache::PkgIterator AptIntf::findPackageArch(const std::string &name, const std::string &arch)
+{
+ return m_cache.GetDepCache()->FindPkg(name, arch);
}
pkgCache::VerIterator AptIntf::findPackageId(const gchar *packageId)
@@ -125,14 +129,10 @@ pkgCache::VerIterator AptIntf::findPackageId(const gchar *packageId)
pkgCache::PkgIterator pkg;
parts = pk_package_id_split(packageId);
- gchar *pkgNameArch;
- pkgNameArch = g_strdup_printf("%s:%s", parts[PK_PACKAGE_ID_NAME], parts[PK_PACKAGE_ID_ARCH]);
- pkg = findPackage(pkgNameArch);
- g_free(pkgNameArch);
+ pkg = findPackageArch(parts[PK_PACKAGE_ID_NAME], parts[PK_PACKAGE_ID_ARCH]);
// Ignore packages that could not be found or that exist only due to dependencies.
- if (pkg.end() == true ||
- (pkg.VersionList().end() && pkg.ProvidesList().end())) {
+ if (pkg.end() || (pkg.VersionList().end() && pkg.ProvidesList().end())) {
g_strfreev(parts);
return pkgCache::VerIterator();
}
diff --git a/backends/aptcc/apt-intf.h b/backends/aptcc/apt-intf.h
index ec6e5de5..add4f7df 100644
--- a/backends/aptcc/apt-intf.h
+++ b/backends/aptcc/apt-intf.h
@@ -65,7 +65,13 @@ public:
* Tries to find a package with the given packageId
* @returns pkgCache::VerIterator that if .end() is true the package could not be found
*/
- pkgCache::PkgIterator findPackage(const std::string &packageName);
+ pkgCache::PkgIterator findPackage(const std::string &name);
+
+ /**
+ * Tries to find a package with the given packageId
+ * @returns pkgCache::VerIterator that if .end() is true the package could not be found
+ */
+ pkgCache::PkgIterator findPackageArch(const std::string &name, const std::string &arch = std::string());
/**
* Tries to find a package with the given packageId