From 3edfc7d9c81df85e1244781abb1890ad9332877d Mon Sep 17 00:00:00 2001 From: Daniel Nicoletti Date: Sun, 15 Apr 2012 15:48:32 -0300 Subject: aptcc: Forgot to return the package found --- backends/aptcc/AptCacheFile.h | 11 +++++++++-- backends/aptcc/apt-intf.cpp | 22 +++++++++++----------- backends/aptcc/apt-intf.h | 8 +++++++- 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 -- cgit v1.2.3