Read pkgcache into hash

Read the package information for sync/local databases into a pmpkghash_t
structure.

Provide a alpm_db_get_pkgcache_list() method that returns the list from
the hash object.  Most usages of alpm_db_get_pkgcache are converted to
this at this stage for ease of implementation.  Review whether these are
better accessing the hash table directly at a later stage.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2011-01-25 11:49:34 +10:00
parent 5dae577a87
commit f8fdce6cb0
16 changed files with 94 additions and 52 deletions

View file

@ -187,7 +187,8 @@ int alpm_db_setserver(pmdb_t *db, const char *url);
int alpm_db_update(int level, pmdb_t *db); int alpm_db_update(int level, pmdb_t *db);
pmpkg_t *alpm_db_get_pkg(pmdb_t *db, const char *name); pmpkg_t *alpm_db_get_pkg(pmdb_t *db, const char *name);
alpm_list_t *alpm_db_get_pkgcache(pmdb_t *db); pmpkghash_t *alpm_db_get_pkgcache(pmdb_t *db);
alpm_list_t *alpm_db_get_pkgcache_list(pmdb_t *db);
pmgrp_t *alpm_db_readgrp(pmdb_t *db, const char *name); pmgrp_t *alpm_db_readgrp(pmdb_t *db, const char *name);
alpm_list_t *alpm_db_get_grpcache(pmdb_t *db); alpm_list_t *alpm_db_get_grpcache(pmdb_t *db);

View file

@ -390,6 +390,10 @@ static int local_db_populate(pmdb_t *db)
} }
/* subtract the two always-there pointers to get # of children */ /* subtract the two always-there pointers to get # of children */
est_count = (int)buf.st_nlink - 2; est_count = (int)buf.st_nlink - 2;
/* initialize hash at 50% full */
db->pkgcache = _alpm_pkghash_create(est_count * 2);
while((ent = readdir(dbdir)) != NULL) { while((ent = readdir(dbdir)) != NULL) {
const char *name = ent->d_name; const char *name = ent->d_name;
@ -416,7 +420,7 @@ static int local_db_populate(pmdb_t *db)
} }
/* duplicated database entries are not allowed */ /* duplicated database entries are not allowed */
if(_alpm_pkg_find(db->pkgcache, pkg->name)) { if(_alpm_pkghash_find(db->pkgcache, pkg->name)) {
_alpm_log(PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name); _alpm_log(PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name);
_alpm_pkg_free(pkg); _alpm_pkg_free(pkg);
continue; continue;
@ -436,12 +440,14 @@ static int local_db_populate(pmdb_t *db)
/* add to the collection */ /* add to the collection */
_alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", _alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
pkg->name, db->treename); pkg->name, db->treename);
db->pkgcache = alpm_list_add(db->pkgcache, pkg); db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
count++; count++;
} }
closedir(dbdir); closedir(dbdir);
db->pkgcache = alpm_list_msort(db->pkgcache, (size_t)count, _alpm_pkg_cmp); if(count > 0) {
db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp);
}
return(count); return(count);
} }

View file

@ -232,6 +232,9 @@ static int sync_db_populate(pmdb_t *db)
} }
est_count = estimate_package_count(&buf, archive); est_count = estimate_package_count(&buf, archive);
/* initialize hash at 50% full */
db->pkgcache = _alpm_pkghash_create(est_count * 2);
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) { while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
const struct stat *st; const struct stat *st;
@ -256,7 +259,7 @@ static int sync_db_populate(pmdb_t *db)
} }
/* duplicated database entries are not allowed */ /* duplicated database entries are not allowed */
if(_alpm_pkg_find(db->pkgcache, pkg->name)) { if(_alpm_pkghash_find(db->pkgcache, pkg->name)) {
_alpm_log(PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name); _alpm_log(PM_LOG_ERROR, _("duplicated database entry '%s'\n"), pkg->name);
_alpm_pkg_free(pkg); _alpm_pkg_free(pkg);
continue; continue;
@ -269,7 +272,7 @@ static int sync_db_populate(pmdb_t *db)
/* add to the collection */ /* add to the collection */
_alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", _alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
pkg->name, db->treename); pkg->name, db->treename);
db->pkgcache = alpm_list_add(db->pkgcache, pkg); db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
count++; count++;
} else { } else {
/* we have desc, depends or deltas - parse it */ /* we have desc, depends or deltas - parse it */
@ -277,7 +280,9 @@ static int sync_db_populate(pmdb_t *db)
} }
} }
db->pkgcache = alpm_list_msort(db->pkgcache, (size_t)count, _alpm_pkg_cmp); if(count > 0) {
db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp);
}
archive_read_finish(archive); archive_read_finish(archive);
return(count); return(count);
@ -343,7 +348,7 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
if(likely_pkg && strcmp(likely_pkg->name, pkgname) == 0) { if(likely_pkg && strcmp(likely_pkg->name, pkgname) == 0) {
pkg = likely_pkg; pkg = likely_pkg;
} else { } else {
pkg = _alpm_pkg_find(db->pkgcache, pkgname); pkg = _alpm_pkghash_find(db->pkgcache, pkgname);
} }
if(pkg == NULL) { if(pkg == NULL) {
_alpm_log(PM_LOG_DEBUG, "package %s not found in %s sync database", _alpm_log(PM_LOG_DEBUG, "package %s not found in %s sync database",

View file

@ -207,8 +207,8 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
return(NULL); return(NULL);
} }
alpm_list_t *dblist = alpm_list_diff(_alpm_db_get_pkgcache(db), packages, alpm_list_t *dblist = alpm_list_diff(_alpm_db_get_pkgcache_list(db),
_alpm_pkg_cmp); packages, _alpm_pkg_cmp);
/* two checks to be done here for conflicts */ /* two checks to be done here for conflicts */
_alpm_log(PM_LOG_DEBUG, "check targets vs db\n"); _alpm_log(PM_LOG_DEBUG, "check targets vs db\n");

View file

@ -249,9 +249,9 @@ pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name)
/** Get the package cache of a package database /** Get the package cache of a package database
* @param db pointer to the package database to get the package from * @param db pointer to the package database to get the package from
* @return the list of packages on success, NULL on error * @return the hash of packages on success, NULL on error
*/ */
alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db) pmpkghash_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db)
{ {
ALPM_LOG_FUNC; ALPM_LOG_FUNC;
@ -262,6 +262,21 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db)
return(_alpm_db_get_pkgcache(db)); return(_alpm_db_get_pkgcache(db));
} }
/** Get the package cache of a package database
* @param db pointer to the package database to get the package from
* @return the list of packages on success, NULL on error
*/
alpm_list_t SYMEXPORT *alpm_db_get_pkgcache_list(pmdb_t *db)
{
ALPM_LOG_FUNC;
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
ASSERT(db != NULL, return(NULL));
return(_alpm_db_get_pkgcache_list(db));
}
/** Get a group entry from a package database /** Get a group entry from a package database
* @param db pointer to the package database to get the group from * @param db pointer to the package database to get the group from
* @param name of the group * @param name of the group
@ -417,7 +432,7 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles)
const alpm_list_t *i, *j, *k; const alpm_list_t *i, *j, *k;
alpm_list_t *ret = NULL; alpm_list_t *ret = NULL;
/* copy the pkgcache- we will free the list var after each needle */ /* copy the pkgcache- we will free the list var after each needle */
alpm_list_t *list = alpm_list_copy(_alpm_db_get_pkgcache(db)); alpm_list_t *list = alpm_list_copy(_alpm_db_get_pkgcache_list(db));
ALPM_LOG_FUNC; ALPM_LOG_FUNC;
@ -523,14 +538,15 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
_alpm_log(PM_LOG_DEBUG, "freeing package cache for repository '%s'\n", _alpm_log(PM_LOG_DEBUG, "freeing package cache for repository '%s'\n",
db->treename); db->treename);
alpm_list_free_inner(db->pkgcache, (alpm_list_fn_free)_alpm_pkg_free); alpm_list_free_inner(_alpm_db_get_pkgcache_list(db),
alpm_list_free(db->pkgcache); (alpm_list_fn_free)_alpm_pkg_free);
_alpm_pkghash_free(db->pkgcache);
db->pkgcache_loaded = 0; db->pkgcache_loaded = 0;
_alpm_db_free_grpcache(db); _alpm_db_free_grpcache(db);
} }
alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db) pmpkghash_t *_alpm_db_get_pkgcache(pmdb_t *db)
{ {
ALPM_LOG_FUNC; ALPM_LOG_FUNC;
@ -550,6 +566,19 @@ alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db)
return(db->pkgcache); return(db->pkgcache);
} }
alpm_list_t *_alpm_db_get_pkgcache_list(pmdb_t *db)
{
ALPM_LOG_FUNC;
pmpkghash_t *hash = _alpm_db_get_pkgcache(db);
if(hash == NULL) {
return(NULL);
}
return(hash->list);
}
/* "duplicate" pkg then add it to pkgcache */ /* "duplicate" pkg then add it to pkgcache */
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg) int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
{ {
@ -568,7 +597,7 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
_alpm_log(PM_LOG_DEBUG, "adding entry '%s' in '%s' cache\n", _alpm_log(PM_LOG_DEBUG, "adding entry '%s' in '%s' cache\n",
alpm_pkg_get_name(newpkg), db->treename); alpm_pkg_get_name(newpkg), db->treename);
db->pkgcache = alpm_list_add_sorted(db->pkgcache, newpkg, _alpm_pkg_cmp); db->pkgcache = _alpm_pkghash_add_sorted(db->pkgcache, newpkg);
_alpm_db_free_grpcache(db); _alpm_db_free_grpcache(db);
@ -577,8 +606,7 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg) int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
{ {
void *vdata; pmpkg_t *data = NULL;
pmpkg_t *data;
ALPM_LOG_FUNC; ALPM_LOG_FUNC;
@ -589,8 +617,7 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
_alpm_log(PM_LOG_DEBUG, "removing entry '%s' from '%s' cache\n", _alpm_log(PM_LOG_DEBUG, "removing entry '%s' from '%s' cache\n",
alpm_pkg_get_name(pkg), db->treename); alpm_pkg_get_name(pkg), db->treename);
db->pkgcache = alpm_list_remove(db->pkgcache, pkg, _alpm_pkg_cmp, &vdata); db->pkgcache = _alpm_pkghash_remove(db->pkgcache, pkg, data);
data = vdata;
if(data == NULL) { if(data == NULL) {
/* package not found */ /* package not found */
_alpm_log(PM_LOG_DEBUG, "cannot remove entry '%s' from '%s' cache: not found\n", _alpm_log(PM_LOG_DEBUG, "cannot remove entry '%s' from '%s' cache: not found\n",
@ -613,14 +640,14 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target)
return(NULL); return(NULL);
} }
alpm_list_t *pkgcache = _alpm_db_get_pkgcache(db); pmpkghash_t *pkgcache = _alpm_db_get_pkgcache(db);
if(!pkgcache) { if(!pkgcache) {
_alpm_log(PM_LOG_DEBUG, "warning: failed to get '%s' from NULL pkgcache\n", _alpm_log(PM_LOG_DEBUG, "warning: failed to get '%s' from NULL pkgcache\n",
target); target);
return(NULL); return(NULL);
} }
return(_alpm_pkg_find(pkgcache, target)); return(_alpm_pkghash_find(pkgcache, target));
} }
/* Returns a new group cache from db. /* Returns a new group cache from db.
@ -638,7 +665,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
_alpm_log(PM_LOG_DEBUG, "loading group cache for repository '%s'\n", _alpm_log(PM_LOG_DEBUG, "loading group cache for repository '%s'\n",
db->treename); db->treename);
for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) { for(lp = _alpm_db_get_pkgcache_list(db); lp; lp = lp->next) {
const alpm_list_t *i; const alpm_list_t *i;
pmpkg_t *pkg = lp->data; pmpkg_t *pkg = lp->data;

View file

@ -23,6 +23,8 @@
#define _ALPM_DB_H #define _ALPM_DB_H
#include "alpm.h" #include "alpm.h"
#include "pkghash.h"
#include <time.h> #include <time.h>
/* libarchive */ /* libarchive */
@ -54,7 +56,7 @@ struct __pmdb_t {
int grpcache_loaded; int grpcache_loaded;
/* also indicates whether we are RO or RW */ /* also indicates whether we are RO or RW */
int is_local; int is_local;
alpm_list_t *pkgcache; pmpkghash_t *pkgcache;
alpm_list_t *grpcache; alpm_list_t *grpcache;
alpm_list_t *servers; alpm_list_t *servers;
@ -84,7 +86,8 @@ int _alpm_db_load_pkgcache(pmdb_t *db);
void _alpm_db_free_pkgcache(pmdb_t *db); void _alpm_db_free_pkgcache(pmdb_t *db);
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg); int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg);
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg); int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg);
alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db); pmpkghash_t *_alpm_db_get_pkgcache(pmdb_t *db);
alpm_list_t *_alpm_db_get_pkgcache_list(pmdb_t *db);
int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel); int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel);
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target); pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target);
/* groups */ /* groups */

View file

@ -475,7 +475,7 @@ static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
* if checkdeps detected it would break something */ * if checkdeps detected it would break something */
/* see if other packages need it */ /* see if other packages need it */
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) { for(i = _alpm_db_get_pkgcache_list(db); i; i = i->next) {
pmpkg_t *lpkg = i->data; pmpkg_t *lpkg = i->data;
if(_alpm_dep_edge(lpkg, pkg) && !_alpm_pkg_find(targets, lpkg->name)) { if(_alpm_dep_edge(lpkg, pkg) && !_alpm_pkg_find(targets, lpkg->name)) {
return(0); return(0);
@ -508,7 +508,7 @@ void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit)
for(i = targs; i; i = i->next) { for(i = targs; i; i = i->next) {
pmpkg_t *pkg = i->data; pmpkg_t *pkg = i->data;
for(j = _alpm_db_get_pkgcache(db); j; j = j->next) { for(j = _alpm_db_get_pkgcache_list(db); j; j = j->next) {
pmpkg_t *deppkg = j->data; pmpkg_t *deppkg = j->data;
if(_alpm_dep_edge(pkg, deppkg) if(_alpm_dep_edge(pkg, deppkg)
&& can_remove_package(db, deppkg, targs, include_explicit)) { && can_remove_package(db, deppkg, targs, include_explicit)) {
@ -586,7 +586,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
} }
/* 2. satisfiers (skip literals here) */ /* 2. satisfiers (skip literals here) */
for(i = dbs; i; i = i->next) { for(i = dbs; i; i = i->next) {
for(j = _alpm_db_get_pkgcache(i->data); j; j = j->next) { for(j = _alpm_db_get_pkgcache_list(i->data); j; j = j->next) {
pmpkg_t *pkg = j->data; pmpkg_t *pkg = j->data;
if(_alpm_depcmp_tolerant(pkg, dep) && strcmp(pkg->name, dep->name) != 0 && if(_alpm_depcmp_tolerant(pkg, dep) && strcmp(pkg->name, dep->name) != 0 &&
!_alpm_pkg_find(excluding, pkg->name)) { !_alpm_pkg_find(excluding, pkg->name)) {
@ -614,7 +614,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
/* first check if one provider is already installed locally */ /* first check if one provider is already installed locally */
for(i = providers; i; i = i->next) { for(i = providers; i; i = i->next) {
pmpkg_t *pkg = i->data; pmpkg_t *pkg = i->data;
if (_alpm_pkg_find(_alpm_db_get_pkgcache(handle->db_local), pkg->name)) { if (_alpm_pkghash_find(_alpm_db_get_pkgcache(handle->db_local), pkg->name)) {
alpm_list_free(providers); alpm_list_free(providers);
return(pkg); return(pkg);
} }

View file

@ -338,7 +338,7 @@ int SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)
static void find_requiredby(pmpkg_t *pkg, pmdb_t *db, alpm_list_t **reqs) static void find_requiredby(pmpkg_t *pkg, pmdb_t *db, alpm_list_t **reqs)
{ {
const alpm_list_t *i; const alpm_list_t *i;
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) { for(i = _alpm_db_get_pkgcache_list(db); i; i = i->next) {
if(!i->data) { if(!i->data) {
continue; continue;
} }

View file

@ -95,7 +95,7 @@ static void remove_prepare_cascade(pmtrans_t *trans, pmdb_t *db,
} }
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free); alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp); alpm_list_free(lp);
lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->remove, NULL); lp = alpm_checkdeps(_alpm_db_get_pkgcache_list(db), 1, trans->remove, NULL);
} }
} }
@ -125,7 +125,7 @@ static void remove_prepare_keep_needed(pmtrans_t *trans, pmdb_t *db,
} }
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free); alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp); alpm_list_free(lp);
lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->remove, NULL); lp = alpm_checkdeps(_alpm_db_get_pkgcache_list(db), 1, trans->remove, NULL);
} }
} }
@ -147,7 +147,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL); EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n"); _alpm_log(PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
lp = alpm_checkdeps(_alpm_db_get_pkgcache(db), 1, trans->remove, NULL); lp = alpm_checkdeps(_alpm_db_get_pkgcache_list(db), 1, trans->remove, NULL);
if(lp != NULL) { if(lp != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) { if(trans->flags & PM_TRANS_FLAG_CASCADE) {

View file

@ -102,7 +102,7 @@ int SYMEXPORT alpm_sync_sysupgrade(int enable_downgrade)
ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1)); ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
_alpm_log(PM_LOG_DEBUG, "checking for package upgrades\n"); _alpm_log(PM_LOG_DEBUG, "checking for package upgrades\n");
for(i = _alpm_db_get_pkgcache(db_local); i; i = i->next) { for(i = _alpm_db_get_pkgcache_list(db_local); i; i = i->next) {
pmpkg_t *lpkg = i->data; pmpkg_t *lpkg = i->data;
if(_alpm_pkg_find(trans->add, lpkg->name)) { if(_alpm_pkg_find(trans->add, lpkg->name)) {
@ -149,7 +149,7 @@ int SYMEXPORT alpm_sync_sysupgrade(int enable_downgrade)
break; /* jump to next local package */ break; /* jump to next local package */
} else { /* 2. search for replacers in sdb */ } else { /* 2. search for replacers in sdb */
int found = 0; int found = 0;
for(k = _alpm_db_get_pkgcache(sdb); k; k = k->next) { for(k = _alpm_db_get_pkgcache_list(sdb); k; k = k->next) {
spkg = k->data; spkg = k->data;
if(alpm_list_find_str(alpm_pkg_get_replaces(spkg), lpkg->name)) { if(alpm_list_find_str(alpm_pkg_get_replaces(spkg), lpkg->name)) {
found = 1; found = 1;
@ -331,7 +331,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
} }
/* Compute the fake local database for resolvedeps (partial fix for the phonon/qt issue) */ /* Compute the fake local database for resolvedeps (partial fix for the phonon/qt issue) */
alpm_list_t *localpkgs = alpm_list_diff(_alpm_db_get_pkgcache(db_local), trans->add, _alpm_pkg_cmp); alpm_list_t *localpkgs = alpm_list_diff(_alpm_db_get_pkgcache_list(db_local), trans->add, _alpm_pkg_cmp);
/* Resolve packages in the transaction one at a time, in addtion /* Resolve packages in the transaction one at a time, in addtion
building up a list of packages which could not be resolved. */ building up a list of packages which could not be resolved. */
@ -518,7 +518,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) { if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
_alpm_log(PM_LOG_DEBUG, "checking dependencies\n"); _alpm_log(PM_LOG_DEBUG, "checking dependencies\n");
deps = alpm_checkdeps(_alpm_db_get_pkgcache(db_local), 1, trans->remove, trans->add); deps = alpm_checkdeps(_alpm_db_get_pkgcache_list(db_local), 1, trans->remove, trans->add);
if(deps) { if(deps) {
pm_errno = PM_ERR_UNSATISFIED_DEPS; pm_errno = PM_ERR_UNSATISFIED_DEPS;
ret = -1; ret = -1;

View file

@ -41,7 +41,7 @@ int pacman_deptest(alpm_list_t *targets)
for(i = targets; i; i = alpm_list_next(i)) { for(i = targets; i; i = alpm_list_next(i)) {
char *target = alpm_list_getdata(i); char *target = alpm_list_getdata(i);
if(!alpm_find_satisfier(alpm_db_get_pkgcache(localdb), target)) { if(!alpm_find_satisfier(alpm_db_get_pkgcache_list(localdb), target)) {
deps = alpm_list_add(deps, target); deps = alpm_list_add(deps, target);
} }
} }

View file

@ -170,7 +170,7 @@ static int query_fileowner(alpm_list_t *targets)
} }
free(dname); free(dname);
for(i = alpm_db_get_pkgcache(db_local); i && !found; i = alpm_list_next(i)) { for(i = alpm_db_get_pkgcache_list(db_local); i && !found; i = alpm_list_next(i)) {
alpm_list_t *j; alpm_list_t *j;
pmpkg_t *info = alpm_list_getdata(i); pmpkg_t *info = alpm_list_getdata(i);
@ -228,7 +228,7 @@ static int query_search(alpm_list_t *targets)
searchlist = alpm_db_search(db_local, targets); searchlist = alpm_db_search(db_local, targets);
freelist = 1; freelist = 1;
} else { } else {
searchlist = alpm_db_get_pkgcache(db_local); searchlist = alpm_db_get_pkgcache_list(db_local);
freelist = 0; freelist = 0;
} }
if(searchlist == NULL) { if(searchlist == NULL) {
@ -511,7 +511,7 @@ int pacman_query(alpm_list_t *targets)
return(1); return(1);
} }
for(i = alpm_db_get_pkgcache(db_local); i; i = alpm_list_next(i)) { for(i = alpm_db_get_pkgcache_list(db_local); i; i = alpm_list_next(i)) {
pkg = alpm_list_getdata(i); pkg = alpm_list_getdata(i);
if(filter(pkg)) { if(filter(pkg)) {
int value = display(pkg); int value = display(pkg);

View file

@ -328,7 +328,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
ret = alpm_db_search(db, targets); ret = alpm_db_search(db, targets);
freelist = 1; freelist = 1;
} else { } else {
ret = alpm_db_get_pkgcache(db); ret = alpm_db_get_pkgcache_list(db);
freelist = 0; freelist = 0;
} }
if(ret == NULL) { if(ret == NULL) {
@ -469,7 +469,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
return(1); return(1);
} }
for(k = alpm_db_get_pkgcache(db); k; k = alpm_list_next(k)) { for(k = alpm_db_get_pkgcache_list(db); k; k = alpm_list_next(k)) {
pmpkg_t *pkg = alpm_list_getdata(k); pmpkg_t *pkg = alpm_list_getdata(k);
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) { if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
@ -490,7 +490,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
for(j = syncs; j; j = alpm_list_next(j)) { for(j = syncs; j; j = alpm_list_next(j)) {
pmdb_t *db = alpm_list_getdata(j); pmdb_t *db = alpm_list_getdata(j);
for(k = alpm_db_get_pkgcache(db); k; k = alpm_list_next(k)) { for(k = alpm_db_get_pkgcache_list(db); k; k = alpm_list_next(k)) {
pmpkg_t *pkg = alpm_list_getdata(k); pmpkg_t *pkg = alpm_list_getdata(k);
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) { if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
@ -511,7 +511,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
for(i = syncs; i; i = alpm_list_next(i)) { for(i = syncs; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(i); pmdb_t *db = alpm_list_getdata(i);
for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) { for(j = alpm_db_get_pkgcache_list(db); j; j = alpm_list_next(j)) {
dump_pkg_sync(alpm_list_getdata(j), alpm_db_get_name(db), config->op_s_info); dump_pkg_sync(alpm_list_getdata(j), alpm_db_get_name(db), config->op_s_info);
} }
} }
@ -555,7 +555,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
for(i = ls; i; i = alpm_list_next(i)) { for(i = ls; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(i); pmdb_t *db = alpm_list_getdata(i);
for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) { for(j = alpm_db_get_pkgcache_list(db); j; j = alpm_list_next(j)) {
pmpkg_t *pkg = alpm_list_getdata(j); pmpkg_t *pkg = alpm_list_getdata(j);
if (!config->quiet) { if (!config->quiet) {

View file

@ -79,7 +79,7 @@ static void checkdbs(char *dbpath, alpm_list_t *dbnames) {
alpm_strerrorlast()); alpm_strerrorlast());
return; return;
} }
checkpkgs(alpm_db_get_pkgcache(db)); checkpkgs(alpm_db_get_pkgcache_list(db));
} }
} }

View file

@ -303,7 +303,7 @@ static void walk_deps(pmpkg_t *pkg, int depth)
for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) { for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) {
pmdepend_t *depend = alpm_list_getdata(i); pmdepend_t *depend = alpm_list_getdata(i);
pmpkg_t *provider = alpm_find_satisfier(alpm_db_get_pkgcache(db_local), pmpkg_t *provider = alpm_find_satisfier(alpm_db_get_pkgcache_list(db_local),
alpm_dep_get_name(depend)); alpm_dep_get_name(depend));
if(provider) { if(provider) {
@ -347,7 +347,7 @@ int main(int argc, char *argv[])
/* we only care about the first non option arg for walking */ /* we only care about the first non option arg for walking */
target_name = argv[optind]; target_name = argv[optind];
pkg = alpm_find_satisfier(alpm_db_get_pkgcache(db_local), target_name); pkg = alpm_find_satisfier(alpm_db_get_pkgcache_list(db_local), target_name);
if(!pkg) { if(!pkg) {
fprintf(stderr, "error: package '%s' not found\n", target_name); fprintf(stderr, "error: package '%s' not found\n", target_name);
ret = 1; ret = 1;

View file

@ -142,7 +142,7 @@ static int check_localdb(void) {
alpm_strerrorlast()); alpm_strerrorlast());
cleanup(EXIT_FAILURE); cleanup(EXIT_FAILURE);
} }
pkglist = alpm_db_get_pkgcache(db); pkglist = alpm_db_get_pkgcache_list(db);
ret += checkdeps(pkglist); ret += checkdeps(pkglist);
ret += checkconflicts(pkglist); ret += checkconflicts(pkglist);
return(ret); return(ret);
@ -162,7 +162,7 @@ static int check_syncdbs(alpm_list_t *dbnames) {
ret = 1; ret = 1;
goto cleanup; goto cleanup;
} }
pkglist = alpm_db_get_pkgcache(db); pkglist = alpm_db_get_pkgcache_list(db);
syncpkglist = alpm_list_join(syncpkglist, alpm_list_copy(pkglist)); syncpkglist = alpm_list_join(syncpkglist, alpm_list_copy(pkglist));
} }
ret += checkdeps(syncpkglist); ret += checkdeps(syncpkglist);