mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-08 12:28:00 -05:00
Remove global handle from some package and db code
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
4015b23e8e
commit
307a6de17a
@ -54,7 +54,7 @@ int SYMEXPORT alpm_initialize(void)
|
|||||||
if(handle == NULL) {
|
if(handle == NULL) {
|
||||||
RET_ERR(PM_ERR_MEMORY, -1);
|
RET_ERR(PM_ERR_MEMORY, -1);
|
||||||
}
|
}
|
||||||
if(_alpm_db_register_local() == NULL) {
|
if(_alpm_db_register_local(handle) == NULL) {
|
||||||
/* error code should be set */
|
/* error code should be set */
|
||||||
_alpm_handle_free(handle);
|
_alpm_handle_free(handle);
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
|
@ -41,12 +41,8 @@
|
|||||||
#include "package.h"
|
#include "package.h"
|
||||||
#include "deps.h"
|
#include "deps.h"
|
||||||
|
|
||||||
/* global handle variable */
|
|
||||||
extern pmhandle_t *handle;
|
|
||||||
|
|
||||||
#define LAZY_LOAD(info, errret) \
|
#define LAZY_LOAD(info, errret) \
|
||||||
do { \
|
do { \
|
||||||
ASSERT(handle != NULL, return (errret)); \
|
|
||||||
if(pkg->origin != PKG_FROM_FILE && !(pkg->infolevel & info)) { \
|
if(pkg->origin != PKG_FROM_FILE && !(pkg->infolevel & info)) { \
|
||||||
_alpm_local_db_read(pkg->origin_data.db, pkg, info); \
|
_alpm_local_db_read(pkg->origin_data.db, pkg, info); \
|
||||||
} \
|
} \
|
||||||
@ -139,9 +135,6 @@ static alpm_list_t *_cache_get_groups(pmpkg_t *pkg)
|
|||||||
|
|
||||||
static int _cache_has_scriptlet(pmpkg_t *pkg)
|
static int _cache_has_scriptlet(pmpkg_t *pkg)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(handle != NULL, return -1);
|
|
||||||
|
|
||||||
if(!(pkg->infolevel & INFRQ_SCRIPTLET)) {
|
if(!(pkg->infolevel & INFRQ_SCRIPTLET)) {
|
||||||
_alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_SCRIPTLET);
|
_alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_SCRIPTLET);
|
||||||
}
|
}
|
||||||
@ -186,9 +179,6 @@ static alpm_list_t *_cache_get_deltas(pmpkg_t UNUSED *pkg)
|
|||||||
|
|
||||||
static alpm_list_t *_cache_get_files(pmpkg_t *pkg)
|
static alpm_list_t *_cache_get_files(pmpkg_t *pkg)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(handle != NULL, return NULL);
|
|
||||||
|
|
||||||
if(pkg->origin == PKG_FROM_LOCALDB
|
if(pkg->origin == PKG_FROM_LOCALDB
|
||||||
&& !(pkg->infolevel & INFRQ_FILES)) {
|
&& !(pkg->infolevel & INFRQ_FILES)) {
|
||||||
_alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_FILES);
|
_alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_FILES);
|
||||||
@ -198,9 +188,6 @@ static alpm_list_t *_cache_get_files(pmpkg_t *pkg)
|
|||||||
|
|
||||||
static alpm_list_t *_cache_get_backup(pmpkg_t *pkg)
|
static alpm_list_t *_cache_get_backup(pmpkg_t *pkg)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(handle != NULL, return NULL);
|
|
||||||
|
|
||||||
if(pkg->origin == PKG_FROM_LOCALDB
|
if(pkg->origin == PKG_FROM_LOCALDB
|
||||||
&& !(pkg->infolevel & INFRQ_FILES)) {
|
&& !(pkg->infolevel & INFRQ_FILES)) {
|
||||||
_alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_FILES);
|
_alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_FILES);
|
||||||
@ -216,9 +203,6 @@ static alpm_list_t *_cache_get_backup(pmpkg_t *pkg)
|
|||||||
*/
|
*/
|
||||||
static void *_cache_changelog_open(pmpkg_t *pkg)
|
static void *_cache_changelog_open(pmpkg_t *pkg)
|
||||||
{
|
{
|
||||||
/* Sanity checks */
|
|
||||||
ASSERT(handle != NULL, return NULL);
|
|
||||||
|
|
||||||
char clfile[PATH_MAX];
|
char clfile[PATH_MAX];
|
||||||
snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog",
|
snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog",
|
||||||
alpm_option_get_dbpath(),
|
alpm_option_get_dbpath(),
|
||||||
@ -417,7 +401,7 @@ static int local_db_populate(pmdb_t *db)
|
|||||||
pkg->origin = PKG_FROM_LOCALDB;
|
pkg->origin = PKG_FROM_LOCALDB;
|
||||||
pkg->origin_data.db = db;
|
pkg->origin_data.db = db;
|
||||||
pkg->ops = &local_pkg_ops;
|
pkg->ops = &local_pkg_ops;
|
||||||
pkg->handle = handle;
|
pkg->handle = db->handle;
|
||||||
|
|
||||||
/* explicitly read with only 'BASE' data, accessors will handle the rest */
|
/* explicitly read with only 'BASE' data, accessors will handle the rest */
|
||||||
if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) {
|
if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) {
|
||||||
@ -944,7 +928,7 @@ struct db_operations local_db_ops = {
|
|||||||
.version = local_db_version,
|
.version = local_db_version,
|
||||||
};
|
};
|
||||||
|
|
||||||
pmdb_t *_alpm_db_register_local(void)
|
pmdb_t *_alpm_db_register_local(pmhandle_t *handle)
|
||||||
{
|
{
|
||||||
pmdb_t *db;
|
pmdb_t *db;
|
||||||
|
|
||||||
|
@ -37,9 +37,6 @@
|
|||||||
#include "deps.h"
|
#include "deps.h"
|
||||||
#include "dload.h"
|
#include "dload.h"
|
||||||
|
|
||||||
/* global handle variable */
|
|
||||||
extern pmhandle_t *handle;
|
|
||||||
|
|
||||||
/** Update a package database
|
/** Update a package database
|
||||||
*
|
*
|
||||||
* An update of the package database \a db will be attempted. Unless
|
* An update of the package database \a db will be attempted. Unless
|
||||||
@ -91,8 +88,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
|
|||||||
pgp_verify_t check_sig;
|
pgp_verify_t check_sig;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
|
ASSERT(db != NULL && db != db->handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
||||||
ASSERT(db != NULL && db != handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
|
||||||
ASSERT(db->servers != NULL, RET_ERR(PM_ERR_SERVER_NONE, -1));
|
ASSERT(db->servers != NULL, RET_ERR(PM_ERR_SERVER_NONE, -1));
|
||||||
|
|
||||||
dbpath = alpm_option_get_dbpath();
|
dbpath = alpm_option_get_dbpath();
|
||||||
@ -311,7 +307,7 @@ static int sync_db_populate(pmdb_t *db)
|
|||||||
pkg->origin = PKG_FROM_SYNCDB;
|
pkg->origin = PKG_FROM_SYNCDB;
|
||||||
pkg->origin_data.db = db;
|
pkg->origin_data.db = db;
|
||||||
pkg->ops = &default_pkg_ops;
|
pkg->ops = &default_pkg_ops;
|
||||||
pkg->handle = handle;
|
pkg->handle = db->handle;
|
||||||
|
|
||||||
/* 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",
|
||||||
@ -506,7 +502,7 @@ struct db_operations sync_db_ops = {
|
|||||||
.version = sync_db_version,
|
.version = sync_db_version,
|
||||||
};
|
};
|
||||||
|
|
||||||
pmdb_t *_alpm_db_register_sync(const char *treename)
|
pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename)
|
||||||
{
|
{
|
||||||
pmdb_t *db;
|
pmdb_t *db;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ pmdb_t SYMEXPORT *alpm_db_register_sync(const char *treename)
|
|||||||
/* Do not register a database if a transaction is on-going */
|
/* Do not register a database if a transaction is on-going */
|
||||||
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
|
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
|
||||||
|
|
||||||
return _alpm_db_register_sync(treename);
|
return _alpm_db_register_sync(handle, treename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper function for alpm_db_unregister{_all} */
|
/* Helper function for alpm_db_unregister{_all} */
|
||||||
@ -97,13 +97,12 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db)
|
|||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
|
|
||||||
ASSERT(db != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
ASSERT(db != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
||||||
/* Do not unregister a database if a transaction is on-going */
|
/* Do not unregister a database if a transaction is on-going */
|
||||||
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1));
|
ASSERT(db->handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1));
|
||||||
|
|
||||||
if(db == handle->db_local) {
|
if(db == db->handle->db_local) {
|
||||||
handle->db_local = NULL;
|
db->handle->db_local = NULL;
|
||||||
found = 1;
|
found = 1;
|
||||||
} else {
|
} else {
|
||||||
/* Warning : this function shouldn't be used to unregister all sync
|
/* Warning : this function shouldn't be used to unregister all sync
|
||||||
@ -111,7 +110,7 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db)
|
|||||||
* alpm_option_get_syncdbs, because the db is removed from that list here.
|
* alpm_option_get_syncdbs, because the db is removed from that list here.
|
||||||
*/
|
*/
|
||||||
void *data;
|
void *data;
|
||||||
handle->dbs_sync = alpm_list_remove(handle->dbs_sync,
|
db->handle->dbs_sync = alpm_list_remove(db->handle->dbs_sync,
|
||||||
db, _alpm_db_cmp, &data);
|
db, _alpm_db_cmp, &data);
|
||||||
if(data) {
|
if(data) {
|
||||||
found = 1;
|
found = 1;
|
||||||
|
@ -77,8 +77,8 @@ const char *_alpm_db_path(pmdb_t *db);
|
|||||||
int _alpm_db_version(pmdb_t *db);
|
int _alpm_db_version(pmdb_t *db);
|
||||||
int _alpm_db_cmp(const void *d1, const void *d2);
|
int _alpm_db_cmp(const void *d1, const void *d2);
|
||||||
alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles);
|
alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles);
|
||||||
pmdb_t *_alpm_db_register_local(void);
|
pmdb_t *_alpm_db_register_local(pmhandle_t *handle);
|
||||||
pmdb_t *_alpm_db_register_sync(const char *treename);
|
pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename);
|
||||||
void _alpm_db_unregister(pmdb_t *db);
|
void _alpm_db_unregister(pmdb_t *db);
|
||||||
|
|
||||||
/* be_*.c, backend specific calls */
|
/* be_*.c, backend specific calls */
|
||||||
|
@ -37,9 +37,6 @@
|
|||||||
#include "handle.h"
|
#include "handle.h"
|
||||||
#include "deps.h"
|
#include "deps.h"
|
||||||
|
|
||||||
/* global handle variable */
|
|
||||||
extern pmhandle_t *handle;
|
|
||||||
|
|
||||||
/** \addtogroup alpm_packages Package Functions
|
/** \addtogroup alpm_packages Package Functions
|
||||||
* @brief Functions to manipulate libalpm packages
|
* @brief Functions to manipulate libalpm packages
|
||||||
* @{
|
* @{
|
||||||
@ -353,7 +350,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
|
|||||||
if(db->is_local) {
|
if(db->is_local) {
|
||||||
find_requiredby(pkg, db, &reqs);
|
find_requiredby(pkg, db, &reqs);
|
||||||
} else {
|
} else {
|
||||||
for(i = handle->dbs_sync; i; i = i->next) {
|
for(i = pkg->handle->dbs_sync; i; i = i->next) {
|
||||||
db = i->data;
|
db = i->data;
|
||||||
find_requiredby(pkg, db, &reqs);
|
find_requiredby(pkg, db, &reqs);
|
||||||
}
|
}
|
||||||
@ -419,7 +416,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
|
|||||||
newpkg->origin_data.db = pkg->origin_data.db;
|
newpkg->origin_data.db = pkg->origin_data.db;
|
||||||
}
|
}
|
||||||
newpkg->ops = pkg->ops;
|
newpkg->ops = pkg->ops;
|
||||||
newpkg->handle = handle;
|
newpkg->handle = pkg->handle;
|
||||||
|
|
||||||
return newpkg;
|
return newpkg;
|
||||||
}
|
}
|
||||||
@ -542,12 +539,12 @@ int _alpm_pkg_should_ignore(pmpkg_t *pkg)
|
|||||||
alpm_list_t *groups = NULL;
|
alpm_list_t *groups = NULL;
|
||||||
|
|
||||||
/* first see if the package is ignored */
|
/* first see if the package is ignored */
|
||||||
if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) {
|
if(alpm_list_find_str(pkg->handle->ignorepkg, alpm_pkg_get_name(pkg))) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* next see if the package is in a group that is ignored */
|
/* next see if the package is in a group that is ignored */
|
||||||
for(groups = handle->ignoregrp; groups; groups = alpm_list_next(groups)) {
|
for(groups = pkg->handle->ignoregrp; groups; groups = alpm_list_next(groups)) {
|
||||||
char *grp = (char *)alpm_list_getdata(groups);
|
char *grp = (char *)alpm_list_getdata(groups);
|
||||||
if(alpm_list_find_str(alpm_pkg_get_groups(pkg), grp)) {
|
if(alpm_list_find_str(alpm_pkg_get_groups(pkg), grp)) {
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user