diff options
author | Dan McGee <dan@archlinux.org> | 2011-06-07 20:46:11 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-06-14 02:35:22 +0200 |
commit | d76341297a089864cf9bb509873bdcff83755f6c (patch) | |
tree | 30f154fb6e6d24357f7902ab5c2e7622c66173ae | |
parent | fb3ad7f8823dd3300528b44427d40e17594b1400 (diff) | |
download | pacman-d76341297a089864cf9bb509873bdcff83755f6c.tar.gz pacman-d76341297a089864cf9bb509873bdcff83755f6c.tar.xz |
Require handle for alpm_pkg_load()
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | lib/libalpm/alpm.h | 5 | ||||
-rw-r--r-- | lib/libalpm/be_package.c | 16 | ||||
-rw-r--r-- | lib/libalpm/package.h | 6 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 2 | ||||
-rw-r--r-- | src/pacman/query.c | 2 | ||||
-rw-r--r-- | src/pacman/sync.c | 2 | ||||
-rw-r--r-- | src/pacman/upgrade.c | 2 | ||||
-rw-r--r-- | src/util/testpkg.c | 2 |
8 files changed, 20 insertions, 17 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 8742eacd..f0af9451 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -368,6 +368,7 @@ int alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason); * metadata is found. If it is true, the entire archive is read, which * serves as a verification of integrity and the filelist can be created. * The allocated structure should be freed using alpm_pkg_free(). + * @param handle the context handle * @param filename location of the package tarball * @param full whether to stop the load after metadata is read or continue * through the full archive @@ -376,8 +377,8 @@ int alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason); * @param pkg address of the package pointer * @return 0 on success, -1 on error (pm_errno is set accordingly) */ -int alpm_pkg_load(const char *filename, int full, pgp_verify_t check_sig, - pmpkg_t **pkg); +int alpm_pkg_load(pmhandle_t *handle, const char *filename, int full, + pgp_verify_t check_sig, pmpkg_t **pkg); /** Free a package. * @param pkg package pointer to free diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 639179b9..9f8264b4 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -30,15 +30,13 @@ /* libalpm */ #include "alpm_list.h" +#include "alpm.h" #include "util.h" #include "log.h" #include "handle.h" #include "package.h" #include "deps.h" /* _alpm_splitdep */ -/* global handle variable */ -extern pmhandle_t *handle; - /** * Open a package changelog for reading. Similar to fopen in functionality, * except that the returned 'file stream' is from an archive. @@ -225,13 +223,15 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg) /** * Load a package and create the corresponding pmpkg_t struct. + * @param handle the context handle * @param pkgfile path to the package file * @param full whether to stop the load after metadata is read or continue * through the full archive * @return An information filled pmpkg_t struct */ -pmpkg_t *_alpm_pkg_load_internal(const char *pkgfile, int full, - const char *md5sum, const char *base64_sig, pgp_verify_t check_sig) +pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile, + int full, const char *md5sum, const char *base64_sig, + pgp_verify_t check_sig) { int ret; int config = 0; @@ -384,13 +384,13 @@ error: return NULL; } -int SYMEXPORT alpm_pkg_load(const char *filename, int full, +int SYMEXPORT alpm_pkg_load(pmhandle_t *handle, const char *filename, int full, pgp_verify_t check_sig, pmpkg_t **pkg) { - /* Sanity checks */ + ASSERT(handle != NULL, return -1); ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); - *pkg = _alpm_pkg_load_internal(filename, full, NULL, NULL, check_sig); + *pkg = _alpm_pkg_load_internal(handle, filename, full, NULL, NULL, check_sig); if(*pkg == NULL) { /* pm_errno is set by pkg_load */ return -1; diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index 4e2dcf3d..b5d8f738 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -141,8 +141,10 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg); void _alpm_pkg_free(pmpkg_t *pkg); void _alpm_pkg_free_trans(pmpkg_t *pkg); -pmpkg_t *_alpm_pkg_load_internal(const char *filename, int full, - const char *md5sum, const char *base64_sig, pgp_verify_t check_sig); + +pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile, + int full, const char *md5sum, const char *base64_sig, + pgp_verify_t check_sig); int _alpm_pkg_cmp(const void *p1, const void *p2); int _alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 16be6d9a..18828881 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -876,7 +876,7 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data) /* load the package file and replace pkgcache entry with it in the target list */ /* TODO: alpm_pkg_get_db() will not work on this target anymore */ _alpm_log(PM_LOG_DEBUG, "replacing pkgcache entry with package file for target %s\n", spkg->name); - pmpkg_t *pkgfile =_alpm_pkg_load_internal(filepath, 1, spkg->md5sum, + pmpkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1, spkg->md5sum, spkg->base64_sig, check_sig); if(!pkgfile) { errors++; diff --git a/src/pacman/query.c b/src/pacman/query.c index c12aa91f..06fd704a 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -552,7 +552,7 @@ int pacman_query(alpm_list_t *targets) char *strname = alpm_list_getdata(i); if(config->op_q_isfile) { - alpm_pkg_load(strname, 1, PM_PGP_VERIFY_OPTIONAL, &pkg); + alpm_pkg_load(config->handle, strname, 1, PM_PGP_VERIFY_OPTIONAL, &pkg); } else { pkg = alpm_db_get_pkg(db_local, strname); } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 57fec4bc..be6f147f 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -220,7 +220,7 @@ static int sync_cleancache(int level) /* attempt to load the package, prompt removal on failures as we may have * files here that aren't valid packages. we also don't need a full * load of the package, just the metadata. */ - if(alpm_pkg_load(path, 0, PM_PGP_VERIFY_NEVER, &localpkg) != 0 + if(alpm_pkg_load(config->handle, path, 0, PM_PGP_VERIFY_NEVER, &localpkg) != 0 || localpkg == NULL) { if(yesno(_("File %s does not seem to be a valid package, remove it?"), path)) { diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index fe49d882..8db88265 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -76,7 +76,7 @@ int pacman_upgrade(alpm_list_t *targets) char *targ = alpm_list_getdata(i); pmpkg_t *pkg; - if(alpm_pkg_load(targ, 1, check_sig, &pkg) != 0) { + if(alpm_pkg_load(config->handle, targ, 1, check_sig, &pkg) != 0) { pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ, alpm_strerrorlast()); trans_release(); diff --git a/src/util/testpkg.c b/src/util/testpkg.c index 32011d46..5b8831de 100644 --- a/src/util/testpkg.c +++ b/src/util/testpkg.c @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) /* let us get log messages from libalpm */ alpm_option_set_logcb(handle, output_cb); - if(alpm_pkg_load(argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1 + if(alpm_pkg_load(handle, argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1 || pkg == NULL) { switch(pm_errno) { case PM_ERR_PKG_OPEN: |