Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=4cb02a6ab141be3e6fd8de8b74766a137b9cedf3

commit 4cb02a6ab141be3e6fd8de8b74766a137b9cedf3
Author: Michel Hermier <[email protected]>
Date:   Fri Aug 15 11:34:31 2014 +0200

libpacman: s/_pacman_db_get_pkgfromcache/Database::find/

diff --git a/lib/libpacman/cache.cpp b/lib/libpacman/cache.cpp
index 756c1b7..85f8598 100644
--- a/lib/libpacman/cache.cpp
+++ b/lib/libpacman/cache.cpp
@@ -145,12 +145,6 @@ int _pacman_db_remove_pkgfromcache(Database *db, Package 
*pkg)
return(0);
}

-Package *_pacman_db_get_pkgfromcache(Database *db, const char *target)
-{
-       ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, NULL));
-       return db->find(target);
-}
-
/* return a pmlist_t of packages in "db" that provide "package"
*/
pmlist_t *_pacman_db_whatprovides(Database *db, char *package)
diff --git a/lib/libpacman/cache.h b/lib/libpacman/cache.h
index 396e4b3..79f4fe0 100644
--- a/lib/libpacman/cache.h
+++ b/lib/libpacman/cache.h
@@ -31,7 +31,6 @@ 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);
pmlist_t *_pacman_db_get_pkgcache(libpacman::Database *db);
-libpacman::Package *_pacman_db_get_pkgfromcache(libpacman::Database *db, const 
char *target);
pmlist_t *_pacman_db_whatprovides(libpacman::Database *db, char *package);
/* groups */
pmlist_t *_pacman_db_get_grpcache(libpacman::Database *db);
diff --git a/lib/libpacman/conflict.cpp b/lib/libpacman/conflict.cpp
index 8b7de2a..0f648cb 100644
--- a/lib/libpacman/conflict.cpp
+++ b/lib/libpacman/conflict.cpp
@@ -296,7 +296,7 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans)
ok = 1;
} else {
if(dbpkg == NULL) {
-                                               dbpkg = 
_pacman_db_get_pkgfromcache(db_local, p->name());
+                                               dbpkg = 
db_local->find(p->name());
}
if(dbpkg && !(dbpkg->flags & INFRQ_FILES)) {
_pacman_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), dbpkg->name());
@@ -313,7 +313,7 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans)
/* As long as they're not the current package */
if(strcmp(p2->name(), p->name())) {
Package *dbpkg2 = NULL;
-                                                               dbpkg2 = 
_pacman_db_get_pkgfromcache(db_local, p2->name());
+                                                               dbpkg2 = 
db_local->find(p2->name());
if(dbpkg2 && !(dbpkg2->flags & INFRQ_FILES)) {
_pacman_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), dbpkg2->name());
dbpkg2->read(INFRQ_FILES);
diff --git a/lib/libpacman/deps.cpp b/lib/libpacman/deps.cpp
index 264582a..9e4b4a9 100644
--- a/lib/libpacman/deps.cpp
+++ b/lib/libpacman/deps.cpp
@@ -233,7 +233,7 @@ pmlist_t *_pacman_checkdeps(pmtrans_t *trans, unsigned char 
op, pmlist_t *packag
}

if(op == PM_TRANS_TYPE_UPGRADE) {
-                       pkg_local = _pacman_db_get_pkgfromcache(db_local, 
tp->name());
+                       pkg_local = db_local->find(tp->name());
} else if (PM_TRANS_TYPE_REMOVE) {
pkg_local = tp;
}
@@ -249,7 +249,7 @@ pmlist_t *_pacman_checkdeps(pmtrans_t *trans, unsigned char 
op, pmlist_t *packag
*/
Package *p;

-                                       if((p = 
_pacman_db_get_pkgfromcache(db_local, requiredby_name)) == NULL) {
+                                       if((p = 
db_local->find(requiredby_name)) == NULL) {
/* hmmm... package isn't installed.. */
continue;
}
@@ -499,7 +499,7 @@ pmlist_t *_pacman_removedeps(Database *db, pmlist_t *targs)
continue;
}

-                       dep = _pacman_db_get_pkgfromcache(db, depend.name);
+                       dep = db->find(depend.name);
if(dep == NULL) {
/* package not found... look for a provisio instead */
k = _pacman_db_whatprovides(db, depend.name);
@@ -507,7 +507,7 @@ pmlist_t *_pacman_removedeps(Database *db, pmlist_t *targs)
_pacman_log(PM_LOG_WARNING, _("cannot find package \"%s\" or anything that 
provides it!"), depend.name);
continue;
}
-                               dep = _pacman_db_get_pkgfromcache(db, ((Package 
*)k->data)->name());
+                               dep = db->find(((Package *)k->data)->name());
if(dep == NULL) {
_pacman_log(PM_LOG_ERROR, _("dep is NULL!"));
/* wtf */
@@ -527,7 +527,7 @@ pmlist_t *_pacman_removedeps(Database *db, pmlist_t *targs)

/* see if other packages need it */
for(k = dep->requiredby(); k && !needed; k = k->next) {
-                               Package *dummy = 
_pacman_db_get_pkgfromcache(db, f_stringlistitem_to_str(k));
+                               Package *dummy = 
db->find(f_stringlistitem_to_str(k));
if(!_pacman_pkg_isin(dummy->name(), targs)) {
needed = 1;
}
@@ -597,7 +597,7 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, 
pmlist_t *list,
/* find the package in one of the repositories */
/* check literals */
for(j = dbs_sync; !ps && j; j = j->next) {
-                       ps = _pacman_db_get_pkgfromcache(j->data, 
miss->depend.name);
+                       ps = ((Database *)j->data)->find(miss->depend.name);
}
/* check provides */
for(j = dbs_sync; !ps && j; j = j->next) {
diff --git a/lib/libpacman/pacman.cpp b/lib/libpacman/pacman.cpp
index 8cbb244..7641fb0 100644
--- a/lib/libpacman/pacman.cpp
+++ b/lib/libpacman/pacman.cpp
@@ -585,7 +585,7 @@ pmpkg_t *pacman_db_readpkg(pmdb_t *_db, const char *name)
ASSERT(db != NULL, return(NULL));
ASSERT(!_pacman_strempty(name), return(NULL));

-       return c_cast(_pacman_db_get_pkgfromcache(db, name));
+       return c_cast(db->find(name));
}

/** Get the package cache of a package database
diff --git a/lib/libpacman/sync.cpp b/lib/libpacman/sync.cpp
index a0d7915..a8396cd 100644
--- a/lib/libpacman/sync.cpp
+++ b/lib/libpacman/sync.cpp
@@ -68,7 +68,7 @@ __pmsyncpkg_t::__pmsyncpkg_t(int type, Package *spkg, void 
*data)
this->pkg_new = spkg;
fAcquire(this->pkg_new);
this->data = data;
-       this->pkg_local = _pacman_db_get_pkgfromcache(handle->db_local, 
this->pkg_name);
+       this->pkg_local = handle->db_local->find(this->pkg_name);
fAcquire(this->pkg_local);
}

diff --git a/lib/libpacman/trans.cpp b/lib/libpacman/trans.cpp
index a23be85..0b968b3 100644
--- a/lib/libpacman/trans.cpp
+++ b/lib/libpacman/trans.cpp
@@ -333,7 +333,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags)
for(i = dbs_sync; i && !spkg; i = i->next) {
Database *dbs = i->data;
if(strcmp(dbs->treename, targline) == 0) {
-                               spkg = _pacman_db_get_pkgfromcache(dbs, targ);
+                               spkg = dbs->find(targ);
if(spkg == NULL) {
/* Search provides */
pmlist_t *p;
@@ -343,7 +343,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags)
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
}
_pacman_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), 
f_stringlistitem_to_str(p), targ);
-                                       spkg = _pacman_db_get_pkgfromcache(dbs, 
f_stringlistitem_to_str(p));
+                                       spkg = 
dbs->find(f_stringlistitem_to_str(p));
FREELISTPTR(p);
}
}
@@ -352,7 +352,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags)
targ = targline;
for(i = dbs_sync; i && !spkg; i = i->next) {
Database *dbs = i->data;
-                       spkg = _pacman_db_get_pkgfromcache(dbs, targ);
+                       spkg = dbs->find(targ);
}
if(spkg == NULL) {
/* Search provides */
@@ -362,7 +362,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags)
pmlist_t *p = _pacman_db_whatprovides(dbs, targ);
if(p) {
_pacman_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), 
f_stringlistitem_to_str(p), targ);
-                                       spkg = _pacman_db_get_pkgfromcache(dbs, 
f_stringlistitem_to_str(p));
+                                       spkg = 
dbs->find(f_stringlistitem_to_str(p));
FREELISTPTR(p);
}
}
@@ -372,7 +372,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags)
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
}

-       pkg_local = _pacman_db_get_pkgfromcache(db_local, spkg->name());
+       pkg_local = db_local->find(spkg->name());
if(pkg_local) {
cmp = _pacman_versioncmp(pkg_local->version(), spkg->version());
if(cmp > 0) {
@@ -414,7 +414,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags)
goto error;
}

-       pkg_local = _pacman_db_get_pkgfromcache(db_local, pkg_new->name());
+       pkg_local = db_local->find(pkg_new->name());
if(type != PM_TRANS_TYPE_UPGRADE) {
/* only install this package if it is not already installed */
if(pkg_local != NULL) {
@@ -639,7 +639,7 @@ int __pmtrans_t::prepare(pmlist_t **data)
miss->target);
continue;
}
-                               local = _pacman_db_get_pkgfromcache(db_local, 
miss->depend.name);
+                               local = db_local->find(miss->depend.name);
/* check if this package also "provides" the package it's conflicting with
*/
if(ps->pkg_new->provides(miss->depend.name)) {
@@ -805,8 +805,8 @@ int __pmtrans_t::prepare(pmlist_t **data)
int pfound = 0;
/* If miss->depend.name depends on something that miss->target and a
* package in final both provide, then it's okay...  */
-                                               Package *leavingp  = 
_pacman_db_get_pkgfromcache(db_local, miss->target);
-                                               Package *conflictp = 
_pacman_db_get_pkgfromcache(db_local, miss->depend.name);
+                                               Package *leavingp  = 
db_local->find(miss->target);
+                                               Package *conflictp = 
db_local->find(miss->depend.name);
if(!leavingp || !conflictp) {
_pacman_log(PM_LOG_ERROR, _("something has gone horribly wrong"));
ret = -1;
@@ -1631,7 +1631,7 @@ int __pmtrans_t::commit(pmlist_t **data)
for(i = syncpkgs; i; i = i->next) {
pmsyncpkg_t *ps = i->data;
if(ps->type == PM_SYNC_TYPE_REPLACE) {
-                               Package *pkg_new = 
_pacman_db_get_pkgfromcache(db_local, ps->pkg_name);
+                               Package *pkg_new = db_local->find(ps->pkg_name);
for(j = ps->data; j; j = j->next) {
pmlist_t *k;
Package *old = j->data;
@@ -1640,7 +1640,7 @@ int __pmtrans_t::commit(pmlist_t **data)
if(!_pacman_list_is_strin(f_stringlistitem_to_str(k), pkg_new->requiredby())) {
/* replace old's name with new's name in the requiredby's dependency list */
pmlist_t *m;
-                                                       Package *depender = 
_pacman_db_get_pkgfromcache(db_local, f_stringlistitem_to_str(k));
+                                                       Package *depender = 
db_local->find(f_stringlistitem_to_str(k));
if(depender == NULL) {
/* If the depending package no longer exists in the local db,
* then it must have ALSO conflicted with ps->pkg.  If
@@ -1709,7 +1709,7 @@ int __pmtrans_t::commit(pmlist_t **data)

/* see if this is an upgrade.  if so, remove the old package first */
if(pkg_local == NULL) {
-                       pkg_local = _pacman_db_get_pkgfromcache(db_local, 
pkg_new->name());
+                       pkg_local = db_local->find(pkg_new->name());
if(pkg_local == NULL) {
/* no previous package version is installed, so this is actually
* just an install.  */
@@ -1802,7 +1802,7 @@ int __pmtrans_t::commit(pmlist_t **data)
if(_pacman_pkg_isin(depend.name, packages)) {
continue;
}
-                       depinfo = _pacman_db_get_pkgfromcache(db_local, 
depend.name);
+                       depinfo = db_local->find(depend.name);
if(depinfo == NULL) {
/* look for a provides package */
pmlist_t *provides = _pacman_db_whatprovides(db_local, depend.name);
@@ -1811,7 +1811,7 @@ int __pmtrans_t::commit(pmlist_t **data)
*                        the first one.
*/
/* use the first one */
-                                       depinfo = 
_pacman_db_get_pkgfromcache(db_local, ((Package *)provides->data)->name());
+                                       depinfo = db_local->find(((Package 
*)provides->data)->name());
FREELISTPTR(provides);
}
if(depinfo == NULL) {
@@ -1895,7 +1895,7 @@ int __pmtrans_t::commit(pmlist_t **data)
if(_pacman_splitdep(lp->data, &depend)) {
continue;
}
-                       depinfo = _pacman_db_get_pkgfromcache(db_local, 
depend.name);
+                       depinfo = db_local->find(depend.name);
if(depinfo == NULL) {
/* look for a provides package */
pmlist_t *provides = _pacman_db_whatprovides(db_local, depend.name);
@@ -1904,7 +1904,7 @@ int __pmtrans_t::commit(pmlist_t **data)
*       the first one.
*/
/* use the first one */
-                                       depinfo = 
_pacman_db_get_pkgfromcache(db_local, ((Package *)provides->data)->name());
+                                       depinfo = db_local->find(((Package 
*)provides->data)->name());
FREELISTPTR(provides);
}
if(depinfo == NULL) {
diff --git a/lib/libpacman/trans_sysupgrade.cpp 
b/lib/libpacman/trans_sysupgrade.cpp
index e70006f..91bd9b7 100644
--- a/lib/libpacman/trans_sysupgrade.cpp
+++ b/lib/libpacman/trans_sysupgrade.cpp
@@ -147,7 +147,7 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans)
pmsyncpkg_t *ps;

for(j = dbs_sync; !spkg && j; j = j->next) {
-                       spkg = _pacman_db_get_pkgfromcache(j->data, 
local->name());
+                       spkg = ((Database *)j->data)->find(local->name());
}
if(spkg == NULL) {
_pacman_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), 
local->name());
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to