Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=c3035b9aa9f5eca9827fa3adefb49a94b5d76103
commit c3035b9aa9f5eca9827fa3adefb49a94b5d76103 Author: Michel Hermier <[email protected]> Date: Mon Oct 6 11:42:39 2014 +0200 libpacman: Make package and groups accessors, member functions of Database. diff --git a/lib/libpacman/cache.h b/lib/libpacman/cache.h index 11cdd88..f2d4627 100644 --- a/lib/libpacman/cache.h +++ b/lib/libpacman/cache.h @@ -30,9 +30,7 @@ int _pacman_db_load_pkgcache(libpacman::Database *db); void _pacman_db_free_pkgcache(libpacman::Database *db); int _pacman_db_add_pkgincache(libpacman::Database *db, libpacman::Package *pkg); int _pacman_db_remove_pkgfromcache(libpacman::Database *db, libpacman::Package *pkg); -libpacman::package_set &_pacman_db_get_pkgcache(libpacman::Database *db); /* groups */ -libpacman::group_set &_pacman_db_get_grpcache(libpacman::Database *db); libpacman::Group *_pacman_db_get_grpfromcache(libpacman::Database *db, const char *target); #endif /* _PACMAN_CACHE_H */ diff --git a/lib/libpacman/conflict.cpp b/lib/libpacman/conflict.cpp index b7e9daf..32ff8b6 100644 --- a/lib/libpacman/conflict.cpp +++ b/lib/libpacman/conflict.cpp @@ -87,7 +87,7 @@ FPtrList pmtrans_t::checkconflicts() } /* CHECK 1: check targets against database */ _pacman_log(PM_LOG_DEBUG, _("checkconflicts: targ '%s' vs db"), tp->name()); - auto &cache = _pacman_db_get_pkgcache(db_local); + auto &cache = db_local->get_packages(); for(auto k = cache.begin(), k_end = cache.end(); k != k_end; ++k) { Package *dp = *k; if(!strcmp(dp->name(), tp->name())) { @@ -144,7 +144,7 @@ FPtrList pmtrans_t::checkconflicts() } /* CHECK 3: check database against targets */ _pacman_log(PM_LOG_DEBUG, _("checkconflicts: db vs targ '%s'"), tp->name()); - auto &cache = _pacman_db_get_pkgcache(db_local); + auto &cache = db_local->get_packages(); for(auto k = cache.begin(), k_end = cache.end(); k != k_end; ++k) { FStringList *conflicts; int usenewconflicts = 0; diff --git a/lib/libpacman/database_cache.cpp b/lib/libpacman/database_cache.cpp index 16d19c2..661b674 100644 --- a/lib/libpacman/database_cache.cpp +++ b/lib/libpacman/database_cache.cpp @@ -93,12 +93,12 @@ void _pacman_db_free_pkgcache(Database *db) _pacman_db_clear_grpcache(db); } -libpacman::package_set &_pacman_db_get_pkgcache(Database *db) +libpacman::package_set &Database::get_packages() { - if(db->pkgcache.empty()) { - _pacman_db_load_pkgcache(db); + if(pkgcache.empty()) { + _pacman_db_load_pkgcache(this); } - return db->pkgcache; + return pkgcache; } int _pacman_db_add_pkgincache(Database *db, Package *pkg) @@ -163,7 +163,7 @@ int _pacman_db_load_grpcache(Database *db) { ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); - auto &cache = _pacman_db_get_pkgcache(db); + auto &cache = db->get_packages(); _pacman_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename()); @@ -201,19 +201,19 @@ int _pacman_db_clear_grpcache(Database *db) return 0; } -libpacman::group_set &_pacman_db_get_grpcache(Database *db) +libpacman::group_set &Database::get_groups() { - if(db->grpcache.empty()) { - _pacman_db_load_grpcache(db); + if(grpcache.empty()) { + _pacman_db_load_grpcache(this); } - return db->grpcache; + return grpcache; } Group *_pacman_db_get_grpfromcache(Database *db, const char *target) { ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, NULL)); - return _pacman_db_get_grpfromlist(_pacman_db_get_grpcache(db), target); + return _pacman_db_get_grpfromlist(db->get_groups(), target); } /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/db.cpp b/lib/libpacman/db.cpp index bbd288b..848edab 100644 --- a/lib/libpacman/db.cpp +++ b/lib/libpacman/db.cpp @@ -97,7 +97,7 @@ FList<Package *> Database::filter(const PackageMatcher &packagematcher) { FList<Package *> ret; - auto &cache = _pacman_db_get_pkgcache(this); + auto &cache = get_packages(); for(auto it = cache.begin(), end = cache.end(); it != end; ++it) { Package *pkg = (Package *)*it; @@ -127,7 +127,7 @@ FList<Package *> Database::filter(const FStringList &needles, int packagestrmatc PackageMatcher packagematcher(pattern, packagestrmatcher_flags, strmatcher_flags); - auto &cache = _pacman_db_get_pkgcache(this); + auto &cache = get_packages(); for(auto j = cache.begin(), j_end = cache.end(); j != j_end; ++j) { Package *pkg = (Package *)*j; @@ -151,7 +151,7 @@ Package *Database::find(const PackageMatcher &packagematcher) { Package *ret = NULL; - auto &cache = _pacman_db_get_pkgcache(this); + auto &cache = get_packages(); for(auto i = cache.begin(), end = cache.end(); i != end; ++i) { Package *pkg = (Package *)*i; diff --git a/lib/libpacman/db.h b/lib/libpacman/db.h index 18abed5..883f587 100644 --- a/lib/libpacman/db.h +++ b/lib/libpacman/db.h @@ -80,6 +80,8 @@ public: libpacman::Package *find(const char *target, int packagestrmatcher_flags = PM_PACKAGE_FLAG_NAME, int strmatcher_flags = FStrMatcher::EQUAL); + libpacman::package_set &get_packages(); + libpacman::group_set &get_groups(); FList<libpacman::Package *> whatPackagesProvide(const char *target); virtual FList<libpacman::Package *> getowners(const char *filename); /* Make pure virtual */ diff --git a/lib/libpacman/db/localdb.cpp b/lib/libpacman/db/localdb.cpp index 6884730..9ef93ae 100644 --- a/lib/libpacman/db/localdb.cpp +++ b/lib/libpacman/db/localdb.cpp @@ -508,7 +508,7 @@ FList<Package *> LocalDatabase::getowners(const char *filename) rpath[strlen(rpath)] = '/'; } - auto &cache = _pacman_db_get_pkgcache(this); + auto &cache = get_packages(); for(auto lp = cache.begin(), end = cache.end(); lp != end; ++lp) { Package *info = *lp; diff --git a/lib/libpacman/deps.cpp b/lib/libpacman/deps.cpp index 210ce17..c97f75c 100644 --- a/lib/libpacman/deps.cpp +++ b/lib/libpacman/deps.cpp @@ -274,7 +274,7 @@ FPtrList pmtrans_t::checkdeps(unsigned char op) _pacman_splitdep(depend_name, &depend); bool found = false; /* check database for literal packages */ - auto &cache = _pacman_db_get_pkgcache(db_local); + auto &cache = db_local->get_packages(); for(auto k = cache.begin(), k_end = cache.end(); k != k_end && !found; ++k) { found = (*k)->match(depend); } diff --git a/lib/libpacman/pacman.cpp b/lib/libpacman/pacman.cpp index ddc3b34..0e7a041 100644 --- a/lib/libpacman/pacman.cpp +++ b/lib/libpacman/pacman.cpp @@ -569,7 +569,7 @@ pmlist_t *pacman_db_getpkgcache(pmdb_t *_db) ASSERT(handle != NULL, return(NULL)); ASSERT(db != NULL, return(NULL)); - return c_cast(_pacman_db_get_pkgcache(db)); + return c_cast(db->get_packages()); } /** Get the list of packages that a package provides @@ -619,7 +619,7 @@ pmlist_t *pacman_db_getgrpcache(pmdb_t *_db) ASSERT(handle != NULL, return(NULL)); ASSERT(db != NULL, return(NULL)); - return c_cast(_pacman_db_get_grpcache(db)); + return c_cast(db->get_groups()); } /** @} */ diff --git a/lib/libpacman/trans.cpp b/lib/libpacman/trans.cpp index 2400da9..9067492 100644 --- a/lib/libpacman/trans.cpp +++ b/lib/libpacman/trans.cpp @@ -1725,7 +1725,7 @@ int __pmtrans_t::commit(FPtrList **data) /* Update the requiredby field by scanning the whole database * looking for packages depending on the package to add */ - auto &cache = _pacman_db_get_pkgcache(db_local); + auto &cache = db_local->get_packages(); for(auto lp = cache.begin(), lp_end = cache.end(); lp != lp_end; ++lp) { Package *tmpp = *lp; if(tmpp == NULL) { diff --git a/lib/libpacman/trans_sysupgrade.cpp b/lib/libpacman/trans_sysupgrade.cpp index e795f61..3294633 100644 --- a/lib/libpacman/trans_sysupgrade.cpp +++ b/lib/libpacman/trans_sysupgrade.cpp @@ -83,12 +83,12 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans) /* check for "recommended" package replacements */ _pacman_log(PM_LOG_FLOW1, _("checking for package replacements")); for(auto i = handle->dbs_sync.begin(), end = handle->dbs_sync.end(); i != end; ++i) { - auto &cache = _pacman_db_get_pkgcache(*i); + auto &cache = (*i)->get_packages(); for(auto j = cache.begin(), end = cache.end(); j != end; ++j) { Package *spkg = *j; auto &replaces = spkg->replaces(); for(auto k = replaces.begin(), end = replaces.end(); k != end; ++k) { - auto &cache_local = _pacman_db_get_pkgcache(db_local); + auto &cache_local = db_local->get_packages(); for(auto m = cache_local.begin(), end = cache_local.end(); m != end; ++m) { Package *lpkg = *m; if(!strcmp((const char *)*k, lpkg->name())) { @@ -132,7 +132,7 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans) /* match installed packages with the sync dbs and compare versions */ _pacman_log(PM_LOG_FLOW1, _("checking for package upgrades")); - auto &cache_local = _pacman_db_get_pkgcache(db_local); + auto &cache_local = db_local->get_packages(); for(auto i = cache_local.begin(), end= cache_local.end(); i != end; ++i) { int cmp; int replace=0; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
