[pacman-dev] [PATCH 02/13] Require handle argument to all alpm_option_(get|set)_*() methods
Dan McGee
dan at archlinux.org
Tue Jun 7 17:36:31 EDT 2011
This requires a lot of line changes, but not many functional changes as
more often than not our handle variable is already available in some
fashion.
Signed-off-by: Dan McGee <dan at archlinux.org>
---
lib/libalpm/alpm.h | 97 +++++++++---------
lib/libalpm/be_local.c | 2 +-
lib/libalpm/be_package.c | 2 +-
lib/libalpm/be_sync.c | 2 +-
lib/libalpm/db.c | 2 +-
lib/libalpm/delta.c | 11 +-
lib/libalpm/delta.h | 2 +-
lib/libalpm/diskspace.c | 2 +-
lib/libalpm/dload.c | 6 +-
lib/libalpm/handle.c | 249 ++++++++++++++++++----------------------------
lib/libalpm/log.c | 2 +-
lib/libalpm/package.c | 4 +-
lib/libalpm/signing.c | 19 ++--
lib/libalpm/signing.h | 3 +-
lib/libalpm/sync.c | 28 +++---
lib/libalpm/trans.c | 6 +-
lib/libalpm/util.c | 12 ++-
lib/libalpm/util.h | 4 +-
src/pacman/conf.c | 42 ++++----
src/pacman/database.c | 2 +-
src/pacman/deptest.c | 3 +-
src/pacman/package.c | 5 +-
src/pacman/pacman.c | 12 +-
src/pacman/query.c | 19 ++--
src/pacman/remove.c | 2 +-
src/pacman/sync.c | 28 +++---
src/pacman/upgrade.c | 4 +-
src/pacman/util.c | 7 +-
src/util/cleanupdelta.c | 2 +-
src/util/pactree.c | 6 +-
src/util/testdb.c | 11 +--
src/util/testpkg.c | 2 +-
32 files changed, 274 insertions(+), 324 deletions(-)
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index f46c154..26ed1e5 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -127,10 +127,11 @@ typedef int (*alpm_cb_fetch)(const char *url, const char *localpath,
int force);
/** Fetch a remote pkg.
+ * @param handle the context handle
* @param url URL of the package to download
* @return the downloaded filepath on success, NULL on error
*/
-char *alpm_fetch_pkgurl(const char *url);
+char *alpm_fetch_pkgurl(pmhandle_t *handle, const char *url);
/** @addtogroup alpm_api_options Options
* Libalpm option getters and setters
@@ -138,67 +139,67 @@ char *alpm_fetch_pkgurl(const char *url);
*/
/** Returns the callback used for logging. */
-alpm_cb_log alpm_option_get_logcb(void);
+alpm_cb_log alpm_option_get_logcb(pmhandle_t *handle);
/** Sets the callback used for logging. */
-int alpm_option_set_logcb(alpm_cb_log cb);
+int alpm_option_set_logcb(pmhandle_t *handle, alpm_cb_log cb);
/** Returns the callback used to report download progress. */
-alpm_cb_download alpm_option_get_dlcb(void);
+alpm_cb_download alpm_option_get_dlcb(pmhandle_t *handle);
/** Sets the callback used to report download progress. */
-int alpm_option_set_dlcb(alpm_cb_download cb);
+int alpm_option_set_dlcb(pmhandle_t *handle, alpm_cb_download cb);
/** Returns the downloading callback. */
-alpm_cb_fetch alpm_option_get_fetchcb(void);
+alpm_cb_fetch alpm_option_get_fetchcb(pmhandle_t *handle);
/** Sets the downloading callback. */
-int alpm_option_set_fetchcb(alpm_cb_fetch cb);
+int alpm_option_set_fetchcb(pmhandle_t *handle, alpm_cb_fetch cb);
/** Returns the callback used to report total download size. */
-alpm_cb_totaldl alpm_option_get_totaldlcb(void);
+alpm_cb_totaldl alpm_option_get_totaldlcb(pmhandle_t *handle);
/** Sets the callback used to report total download size. */
-int alpm_option_set_totaldlcb(alpm_cb_totaldl cb);
+int alpm_option_set_totaldlcb(pmhandle_t *handle, alpm_cb_totaldl cb);
/** Returns the root of the destination filesystem. Read-only. */
-const char *alpm_option_get_root(void);
+const char *alpm_option_get_root(pmhandle_t *handle);
/** Returns the path to the database directory. Read-only. */
-const char *alpm_option_get_dbpath(void);
+const char *alpm_option_get_dbpath(pmhandle_t *handle);
/** Get the name of the database lock file. Read-only. */
-const char *alpm_option_get_lockfile(void);
+const char *alpm_option_get_lockfile(pmhandle_t *handle);
/** @name Accessors to the list of package cache directories.
* @{
*/
-alpm_list_t *alpm_option_get_cachedirs(void);
-int alpm_option_set_cachedirs(alpm_list_t *cachedirs);
-int alpm_option_add_cachedir(const char *cachedir);
-int alpm_option_remove_cachedir(const char *cachedir);
+alpm_list_t *alpm_option_get_cachedirs(pmhandle_t *handle);
+int alpm_option_set_cachedirs(pmhandle_t *handle, alpm_list_t *cachedirs);
+int alpm_option_add_cachedir(pmhandle_t *handle, const char *cachedir);
+int alpm_option_remove_cachedir(pmhandle_t *handle, const char *cachedir);
/** @} */
/** Returns the logfile name. */
-const char *alpm_option_get_logfile(void);
+const char *alpm_option_get_logfile(pmhandle_t *handle);
/** Sets the logfile name. */
-int alpm_option_set_logfile(const char *logfile);
+int alpm_option_set_logfile(pmhandle_t *handle, const char *logfile);
/** Returns the signature directory path. */
-const char *alpm_option_get_signaturedir(void);
+const char *alpm_option_get_signaturedir(pmhandle_t *handle);
/** Sets the signature directory path. */
-int alpm_option_set_signaturedir(const char *signaturedir);
+int alpm_option_set_signaturedir(pmhandle_t *handle, const char *signaturedir);
/** Returns whether to use syslog (0 is FALSE, TRUE otherwise). */
-int alpm_option_get_usesyslog(void);
+int alpm_option_get_usesyslog(pmhandle_t *handle);
/** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */
-int alpm_option_set_usesyslog(int usesyslog);
+int alpm_option_set_usesyslog(pmhandle_t *handle, int usesyslog);
/** @name Accessors to the list of no-upgrade files.
* These functions modify the list of files which should
* not be updated by package installation.
* @{
*/
-alpm_list_t *alpm_option_get_noupgrades(void);
-int alpm_option_add_noupgrade(const char *pkg);
-int alpm_option_set_noupgrades(alpm_list_t *noupgrade);
-int alpm_option_remove_noupgrade(const char *pkg);
+alpm_list_t *alpm_option_get_noupgrades(pmhandle_t *handle);
+int alpm_option_add_noupgrade(pmhandle_t *handle, const char *pkg);
+int alpm_option_set_noupgrades(pmhandle_t *handle, alpm_list_t *noupgrade);
+int alpm_option_remove_noupgrade(pmhandle_t *handle, const char *pkg);
/** @} */
/** @name Accessors to the list of no-extract files.
@@ -207,10 +208,10 @@ int alpm_option_remove_noupgrade(const char *pkg);
* not be upgraded by a sysupgrade operation.
* @{
*/
-alpm_list_t *alpm_option_get_noextracts(void);
-int alpm_option_add_noextract(const char *pkg);
-int alpm_option_set_noextracts(alpm_list_t *noextract);
-int alpm_option_remove_noextract(const char *pkg);
+alpm_list_t *alpm_option_get_noextracts(pmhandle_t *handle);
+int alpm_option_add_noextract(pmhandle_t *handle, const char *pkg);
+int alpm_option_set_noextracts(pmhandle_t *handle, alpm_list_t *noextract);
+int alpm_option_remove_noextract(pmhandle_t *handle, const char *pkg);
/** @} */
/** @name Accessors to the list of ignored packages.
@@ -218,10 +219,10 @@ int alpm_option_remove_noextract(const char *pkg);
* should be ignored by a sysupgrade.
* @{
*/
-alpm_list_t *alpm_option_get_ignorepkgs(void);
-int alpm_option_add_ignorepkg(const char *pkg);
-int alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs);
-int alpm_option_remove_ignorepkg(const char *pkg);
+alpm_list_t *alpm_option_get_ignorepkgs(pmhandle_t *handle);
+int alpm_option_add_ignorepkg(pmhandle_t *handle, const char *pkg);
+int alpm_option_set_ignorepkgs(pmhandle_t *handle, alpm_list_t *ignorepkgs);
+int alpm_option_remove_ignorepkg(pmhandle_t *handle, const char *pkg);
/** @} */
/** @name Accessors to the list of ignored groups.
@@ -229,25 +230,25 @@ int alpm_option_remove_ignorepkg(const char *pkg);
* should be ignored by a sysupgrade.
* @{
*/
-alpm_list_t *alpm_option_get_ignoregrps(void);
-int alpm_option_add_ignoregrp(const char *grp);
-int alpm_option_set_ignoregrps(alpm_list_t *ignoregrps);
-int alpm_option_remove_ignoregrp(const char *grp);
+alpm_list_t *alpm_option_get_ignoregrps(pmhandle_t *handle);
+int alpm_option_add_ignoregrp(pmhandle_t *handle, const char *grp);
+int alpm_option_set_ignoregrps(pmhandle_t *handle, alpm_list_t *ignoregrps);
+int alpm_option_remove_ignoregrp(pmhandle_t *handle, const char *grp);
/** @} */
/** Returns the targeted architecture. */
-const char *alpm_option_get_arch(void);
+const char *alpm_option_get_arch(pmhandle_t *handle);
/** Sets the targeted architecture. */
-int alpm_option_set_arch(const char *arch);
+int alpm_option_set_arch(pmhandle_t *handle, const char *arch);
-int alpm_option_get_usedelta(void);
-int alpm_option_set_usedelta(int usedelta);
+int alpm_option_get_usedelta(pmhandle_t *handle);
+int alpm_option_set_usedelta(pmhandle_t *handle, int usedelta);
-int alpm_option_get_checkspace(void);
-int alpm_option_set_checkspace(int checkspace);
+int alpm_option_get_checkspace(pmhandle_t *handle);
+int alpm_option_set_checkspace(pmhandle_t *handle, int checkspace);
-pgp_verify_t alpm_option_get_default_sigverify(void);
-int alpm_option_set_default_sigverify(pgp_verify_t level);
+pgp_verify_t alpm_option_get_default_sigverify(pmhandle_t *handle);
+int alpm_option_set_default_sigverify(pmhandle_t *handle, pgp_verify_t level);
/** @} */
@@ -262,14 +263,14 @@ int alpm_option_set_default_sigverify(pgp_verify_t level);
* libalpm functions.
* @return a reference to the local database
*/
-pmdb_t *alpm_option_get_localdb(void);
+pmdb_t *alpm_option_get_localdb(pmhandle_t *handle);
/** Get the list of sync databases.
* Returns a list of pmdb_t structures, one for each registered
* sync database.
* @return a reference to an internal list of pmdb_t structures
*/
-alpm_list_t *alpm_option_get_syncdbs(void);
+alpm_list_t *alpm_option_get_syncdbs(pmhandle_t *handle);
/** Register a sync database of packages.
* @param treename the name of the sync repository
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 3a0887d..42ddaf5 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -205,7 +205,7 @@ static void *_cache_changelog_open(pmpkg_t *pkg)
{
char clfile[PATH_MAX];
snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog",
- alpm_option_get_dbpath(),
+ alpm_option_get_dbpath(pkg->handle),
alpm_db_get_name(alpm_pkg_get_db(pkg)),
alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg));
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index c89365a..0545167 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -270,7 +270,7 @@ pmpkg_t *_alpm_pkg_load_internal(const char *pkgfile, int full,
_alpm_log(PM_LOG_DEBUG, "base64_sig: %s\n", base64_sig);
if(check_sig != PM_PGP_VERIFY_NEVER) {
_alpm_log(PM_LOG_DEBUG, "checking signature for %s\n", pkgfile);
- ret = _alpm_gpgme_checksig(pkgfile, base64_sig);
+ ret = _alpm_gpgme_checksig(handle, pkgfile, base64_sig);
if((check_sig == PM_PGP_VERIFY_ALWAYS && ret != 0) ||
(check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) {
RET_ERR(PM_ERR_SIG_INVALID, NULL);
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index aeba86f..c8d3758 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -91,7 +91,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
ASSERT(db != NULL && db != db->handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1));
ASSERT(db->servers != NULL, RET_ERR(PM_ERR_SERVER_NONE, -1));
- dbpath = alpm_option_get_dbpath();
+ dbpath = alpm_option_get_dbpath(db->handle);
len = strlen(dbpath) + 6;
MALLOC(syncpath, len, RET_ERR(PM_ERR_MEMORY, -1));
sprintf(syncpath, "%s%s", dbpath, "sync/");
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index fda8428..6114334 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -360,7 +360,7 @@ const char *_alpm_db_path(pmdb_t *db)
const char *dbpath;
size_t pathsize;
- dbpath = alpm_option_get_dbpath();
+ dbpath = alpm_option_get_dbpath(db->handle);
if(!dbpath) {
_alpm_log(PM_LOG_ERROR, _("database path is undefined\n"));
RET_ERR(PM_ERR_DB_OPEN, NULL);
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index cd23487..645c7ba 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -111,7 +111,7 @@ static alpm_list_t *graph_init(alpm_list_t *deltas, int reverse)
return vertices;
}
-static void graph_init_size(alpm_list_t *vertices)
+static void graph_init_size(pmhandle_t *handle, alpm_list_t *vertices)
{
alpm_list_t *i;
@@ -121,7 +121,7 @@ static void graph_init_size(alpm_list_t *vertices)
pmdelta_t *vdelta = v->data;
/* determine whether the delta file already exists */
- fpath = _alpm_filecache_find(vdelta->delta);
+ fpath = _alpm_filecache_find(handle, vdelta->delta);
md5sum = alpm_compute_md5sum(fpath);
if(fpath && md5sum && strcmp(md5sum, vdelta->delta_md5) == 0) {
vdelta->download_size = 0;
@@ -130,7 +130,7 @@ static void graph_init_size(alpm_list_t *vertices)
FREE(md5sum);
/* determine whether a base 'from' file exists */
- fpath = _alpm_filecache_find(vdelta->from);
+ fpath = _alpm_filecache_find(handle, vdelta->from);
if(fpath) {
v->weight = vdelta->download_size;
}
@@ -211,6 +211,7 @@ static off_t shortest_path(alpm_list_t *vertices, const char *to, alpm_list_t **
/** Calculates the shortest path from one version to another.
* The shortest path is defined as the path with the smallest combined
* size, not the length of the path.
+ * @param handle the context handle
* @param deltas the list of pmdelta_t * objects that a file has
* @param to the file to start the search at
* @param path the pointer to a list location where pmdelta_t * objects that
@@ -218,7 +219,7 @@ static off_t shortest_path(alpm_list_t *vertices, const char *to, alpm_list_t **
* possible with the files available.
* @return the size of the path stored, or LONG_MAX if path is unfindable
*/
-off_t _alpm_shortest_delta_path(alpm_list_t *deltas,
+off_t _alpm_shortest_delta_path(pmhandle_t *handle, alpm_list_t *deltas,
const char *to, alpm_list_t **path)
{
alpm_list_t *bestpath = NULL;
@@ -233,7 +234,7 @@ off_t _alpm_shortest_delta_path(alpm_list_t *deltas,
_alpm_log(PM_LOG_DEBUG, "started delta shortest-path search for '%s'\n", to);
vertices = graph_init(deltas, 0);
- graph_init_size(vertices);
+ graph_init_size(handle, vertices);
dijkstra(vertices);
bestsize = shortest_path(vertices, to, &bestpath);
diff --git a/lib/libalpm/delta.h b/lib/libalpm/delta.h
index bd196ba..d7725f5 100644
--- a/lib/libalpm/delta.h
+++ b/lib/libalpm/delta.h
@@ -43,7 +43,7 @@ struct __pmdelta_t {
pmdelta_t *_alpm_delta_parse(char *line);
void _alpm_delta_free(pmdelta_t *delta);
-off_t _alpm_shortest_delta_path(alpm_list_t *deltas,
+off_t _alpm_shortest_delta_path(pmhandle_t *handle, alpm_list_t *deltas,
const char *to, alpm_list_t **path);
/* max percent of package size to download deltas */
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index c6c0b98..7be5464 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -226,7 +226,7 @@ static int calculate_installed_size(pmhandle_t *handle,
/* approximate space requirements for db entries */
if(filename[0] == '.') {
- filename = alpm_option_get_dbpath();
+ filename = alpm_option_get_dbpath(handle);
}
snprintf(path, PATH_MAX, "%s%s", handle->root, filename);
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 8591c9d..0ba3bc1 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -332,7 +332,7 @@ int _alpm_download(const char *url, const char *localpath,
}
/** Fetch a remote pkg. */
-char SYMEXPORT *alpm_fetch_pkgurl(const char *url)
+char SYMEXPORT *alpm_fetch_pkgurl(pmhandle_t *handle, const char *url)
{
char *filepath;
const char *filename, *cachedir;
@@ -341,7 +341,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(const char *url)
filename = get_filename(url);
/* find a valid cache dir to download to */
- cachedir = _alpm_filecache_setup();
+ cachedir = _alpm_filecache_setup(handle);
/* download the file */
ret = _alpm_download(url, cachedir, 0, 1, 0);
@@ -374,7 +374,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(const char *url)
}
/* we should be able to find the file the second time around */
- filepath = _alpm_filecache_find(filename);
+ filepath = _alpm_filecache_find(handle, filename);
return filepath;
}
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 80ad560..0e50cbd 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -90,210 +90,150 @@ void _alpm_handle_free(pmhandle_t *handle)
}
-alpm_cb_log SYMEXPORT alpm_option_get_logcb()
+alpm_cb_log SYMEXPORT alpm_option_get_logcb(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->logcb;
}
-alpm_cb_download SYMEXPORT alpm_option_get_dlcb()
+alpm_cb_download SYMEXPORT alpm_option_get_dlcb(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->dlcb;
}
-alpm_cb_fetch SYMEXPORT alpm_option_get_fetchcb()
+alpm_cb_fetch SYMEXPORT alpm_option_get_fetchcb(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->fetchcb;
}
-alpm_cb_totaldl SYMEXPORT alpm_option_get_totaldlcb()
+alpm_cb_totaldl SYMEXPORT alpm_option_get_totaldlcb(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->totaldlcb;
}
-const char SYMEXPORT *alpm_option_get_root()
+const char SYMEXPORT *alpm_option_get_root(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->root;
}
-const char SYMEXPORT *alpm_option_get_dbpath()
+const char SYMEXPORT *alpm_option_get_dbpath(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->dbpath;
}
-alpm_list_t SYMEXPORT *alpm_option_get_cachedirs()
+alpm_list_t SYMEXPORT *alpm_option_get_cachedirs(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->cachedirs;
}
-const char SYMEXPORT *alpm_option_get_logfile()
+const char SYMEXPORT *alpm_option_get_logfile(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->logfile;
}
-const char SYMEXPORT *alpm_option_get_lockfile()
+const char SYMEXPORT *alpm_option_get_lockfile(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->lockfile;
}
-const char SYMEXPORT *alpm_option_get_signaturedir()
+const char SYMEXPORT *alpm_option_get_signaturedir(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->signaturedir;
}
-int SYMEXPORT alpm_option_get_usesyslog()
+int SYMEXPORT alpm_option_get_usesyslog(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return -1;
- }
+ ASSERT(handle != NULL, return -1);
return handle->usesyslog;
}
-alpm_list_t SYMEXPORT *alpm_option_get_noupgrades()
+alpm_list_t SYMEXPORT *alpm_option_get_noupgrades(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->noupgrade;
}
-alpm_list_t SYMEXPORT *alpm_option_get_noextracts()
+alpm_list_t SYMEXPORT *alpm_option_get_noextracts(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->noextract;
}
-alpm_list_t SYMEXPORT *alpm_option_get_ignorepkgs()
+alpm_list_t SYMEXPORT *alpm_option_get_ignorepkgs(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->ignorepkg;
}
-alpm_list_t SYMEXPORT *alpm_option_get_ignoregrps()
+alpm_list_t SYMEXPORT *alpm_option_get_ignoregrps(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->ignoregrp;
}
-const char SYMEXPORT *alpm_option_get_arch()
+const char SYMEXPORT *alpm_option_get_arch(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->arch;
}
-int SYMEXPORT alpm_option_get_usedelta()
+int SYMEXPORT alpm_option_get_usedelta(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return -1;
- }
+ ASSERT(handle != NULL, return -1);
return handle->usedelta;
}
-int SYMEXPORT alpm_option_get_checkspace()
+int SYMEXPORT alpm_option_get_checkspace(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return -1;
- }
+ ASSERT(handle != NULL, return -1);
return handle->checkspace;
}
-pmdb_t SYMEXPORT *alpm_option_get_localdb()
+pmdb_t SYMEXPORT *alpm_option_get_localdb(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->db_local;
}
-alpm_list_t SYMEXPORT *alpm_option_get_syncdbs()
+alpm_list_t SYMEXPORT *alpm_option_get_syncdbs(pmhandle_t *handle)
{
- if(handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
+ ASSERT(handle != NULL, return NULL);
return handle->dbs_sync;
}
-int SYMEXPORT alpm_option_set_logcb(alpm_cb_log cb)
+int SYMEXPORT alpm_option_set_logcb(pmhandle_t *handle, alpm_cb_log cb)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->logcb = cb;
return 0;
}
-int SYMEXPORT alpm_option_set_dlcb(alpm_cb_download cb)
+int SYMEXPORT alpm_option_set_dlcb(pmhandle_t *handle, alpm_cb_download cb)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->dlcb = cb;
return 0;
}
-int SYMEXPORT alpm_option_set_fetchcb(alpm_cb_fetch cb)
+int SYMEXPORT alpm_option_set_fetchcb(pmhandle_t *handle, alpm_cb_fetch cb)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->fetchcb = cb;
return 0;
}
-int SYMEXPORT alpm_option_set_totaldlcb(alpm_cb_totaldl cb)
+int SYMEXPORT alpm_option_set_totaldlcb(pmhandle_t *handle, alpm_cb_totaldl cb)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->totaldlcb = cb;
return 0;
}
@@ -344,11 +284,11 @@ enum _pmerrno_t _alpm_set_directory_option(const char *value,
return 0;
}
-int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
+int SYMEXPORT alpm_option_add_cachedir(pmhandle_t *handle, const char *cachedir)
{
char *newcachedir;
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
if(!cachedir) {
pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -362,15 +302,15 @@ int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
return 0;
}
-int SYMEXPORT alpm_option_set_cachedirs(alpm_list_t *cachedirs)
+int SYMEXPORT alpm_option_set_cachedirs(pmhandle_t *handle, alpm_list_t *cachedirs)
{
alpm_list_t *i;
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
if(handle->cachedirs) {
FREELIST(handle->cachedirs);
}
for(i = cachedirs; i; i = i->next) {
- int ret = alpm_option_add_cachedir(i->data);
+ int ret = alpm_option_add_cachedir(handle, i->data);
if(ret) {
return ret;
}
@@ -378,12 +318,12 @@ int SYMEXPORT alpm_option_set_cachedirs(alpm_list_t *cachedirs)
return 0;
}
-int SYMEXPORT alpm_option_remove_cachedir(const char *cachedir)
+int SYMEXPORT alpm_option_remove_cachedir(pmhandle_t *handle, const char *cachedir)
{
char *vdata = NULL;
char *newcachedir;
size_t cachedirlen;
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
/* verify cachedir ends in a '/' */
cachedirlen = strlen(cachedir);
if(cachedir[cachedirlen-1] != '/') {
@@ -401,11 +341,11 @@ int SYMEXPORT alpm_option_remove_cachedir(const char *cachedir)
return 0;
}
-int SYMEXPORT alpm_option_set_logfile(const char *logfile)
+int SYMEXPORT alpm_option_set_logfile(pmhandle_t *handle, const char *logfile)
{
char *oldlogfile = handle->logfile;
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
if(!logfile) {
pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -426,8 +366,9 @@ int SYMEXPORT alpm_option_set_logfile(const char *logfile)
return 0;
}
-int SYMEXPORT alpm_option_set_signaturedir(const char *signaturedir)
+int SYMEXPORT alpm_option_set_signaturedir(pmhandle_t *handle, const char *signaturedir)
{
+ ASSERT(handle != NULL, return -1);
if(!signaturedir) {
pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -442,32 +383,32 @@ int SYMEXPORT alpm_option_set_signaturedir(const char *signaturedir)
return 0;
}
-int SYMEXPORT alpm_option_set_usesyslog(int usesyslog)
+int SYMEXPORT alpm_option_set_usesyslog(pmhandle_t *handle, int usesyslog)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->usesyslog = usesyslog;
return 0;
}
-int SYMEXPORT alpm_option_add_noupgrade(const char *pkg)
+int SYMEXPORT alpm_option_add_noupgrade(pmhandle_t *handle, const char *pkg)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
return 0;
}
-int SYMEXPORT alpm_option_set_noupgrades(alpm_list_t *noupgrade)
+int SYMEXPORT alpm_option_set_noupgrades(pmhandle_t *handle, alpm_list_t *noupgrade)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
if(handle->noupgrade) FREELIST(handle->noupgrade);
handle->noupgrade = alpm_list_strdup(noupgrade);
return 0;
}
-int SYMEXPORT alpm_option_remove_noupgrade(const char *pkg)
+int SYMEXPORT alpm_option_remove_noupgrade(pmhandle_t *handle, const char *pkg)
{
char *vdata = NULL;
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->noupgrade = alpm_list_remove_str(handle->noupgrade, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -476,25 +417,25 @@ int SYMEXPORT alpm_option_remove_noupgrade(const char *pkg)
return 0;
}
-int SYMEXPORT alpm_option_add_noextract(const char *pkg)
+int SYMEXPORT alpm_option_add_noextract(pmhandle_t *handle, const char *pkg)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->noextract = alpm_list_add(handle->noextract, strdup(pkg));
return 0;
}
-int SYMEXPORT alpm_option_set_noextracts(alpm_list_t *noextract)
+int SYMEXPORT alpm_option_set_noextracts(pmhandle_t *handle, alpm_list_t *noextract)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
if(handle->noextract) FREELIST(handle->noextract);
handle->noextract = alpm_list_strdup(noextract);
return 0;
}
-int SYMEXPORT alpm_option_remove_noextract(const char *pkg)
+int SYMEXPORT alpm_option_remove_noextract(pmhandle_t *handle, const char *pkg)
{
char *vdata = NULL;
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->noextract = alpm_list_remove_str(handle->noextract, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -503,25 +444,25 @@ int SYMEXPORT alpm_option_remove_noextract(const char *pkg)
return 0;
}
-int SYMEXPORT alpm_option_add_ignorepkg(const char *pkg)
+int SYMEXPORT alpm_option_add_ignorepkg(pmhandle_t *handle, const char *pkg)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->ignorepkg = alpm_list_add(handle->ignorepkg, strdup(pkg));
return 0;
}
-int SYMEXPORT alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs)
+int SYMEXPORT alpm_option_set_ignorepkgs(pmhandle_t *handle, alpm_list_t *ignorepkgs)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
if(handle->ignorepkg) FREELIST(handle->ignorepkg);
handle->ignorepkg = alpm_list_strdup(ignorepkgs);
return 0;
}
-int SYMEXPORT alpm_option_remove_ignorepkg(const char *pkg)
+int SYMEXPORT alpm_option_remove_ignorepkg(pmhandle_t *handle, const char *pkg)
{
char *vdata = NULL;
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->ignorepkg = alpm_list_remove_str(handle->ignorepkg, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -530,25 +471,25 @@ int SYMEXPORT alpm_option_remove_ignorepkg(const char *pkg)
return 0;
}
-int SYMEXPORT alpm_option_add_ignoregrp(const char *grp)
+int SYMEXPORT alpm_option_add_ignoregrp(pmhandle_t *handle, const char *grp)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->ignoregrp = alpm_list_add(handle->ignoregrp, strdup(grp));
return 0;
}
-int SYMEXPORT alpm_option_set_ignoregrps(alpm_list_t *ignoregrps)
+int SYMEXPORT alpm_option_set_ignoregrps(pmhandle_t *handle, alpm_list_t *ignoregrps)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
if(handle->ignoregrp) FREELIST(handle->ignoregrp);
handle->ignoregrp = alpm_list_strdup(ignoregrps);
return 0;
}
-int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp)
+int SYMEXPORT alpm_option_remove_ignoregrp(pmhandle_t *handle, const char *grp)
{
char *vdata = NULL;
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->ignoregrp = alpm_list_remove_str(handle->ignoregrp, grp, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -557,9 +498,9 @@ int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp)
return 0;
}
-int SYMEXPORT alpm_option_set_arch(const char *arch)
+int SYMEXPORT alpm_option_set_arch(pmhandle_t *handle, const char *arch)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
if(handle->arch) FREE(handle->arch);
if(arch) {
handle->arch = strdup(arch);
@@ -569,31 +510,31 @@ int SYMEXPORT alpm_option_set_arch(const char *arch)
return 0;
}
-int SYMEXPORT alpm_option_set_usedelta(int usedelta)
+int SYMEXPORT alpm_option_set_usedelta(pmhandle_t *handle, int usedelta)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->usedelta = usedelta;
return 0;
}
-int SYMEXPORT alpm_option_set_checkspace(int checkspace)
+int SYMEXPORT alpm_option_set_checkspace(pmhandle_t *handle, int checkspace)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
handle->checkspace = checkspace;
return 0;
}
-int SYMEXPORT alpm_option_set_default_sigverify(pgp_verify_t level)
+int SYMEXPORT alpm_option_set_default_sigverify(pmhandle_t *handle, pgp_verify_t level)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ ASSERT(handle != NULL, return -1);
ASSERT(level != PM_PGP_VERIFY_UNKNOWN, RET_ERR(PM_ERR_WRONG_ARGS, -1));
handle->sigverify = level;
return 0;
}
-pgp_verify_t SYMEXPORT alpm_option_get_default_sigverify()
+pgp_verify_t SYMEXPORT alpm_option_get_default_sigverify(pmhandle_t *handle)
{
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, PM_PGP_VERIFY_UNKNOWN));
+ ASSERT(handle != NULL, return PM_PGP_VERIFY_UNKNOWN);
return handle->sigverify;
}
diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c
index 30d1d6f..023bfc9 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -89,7 +89,7 @@ int SYMEXPORT alpm_logaction(pmhandle_t *handle, const char *fmt, ...)
void _alpm_log(pmloglevel_t flag, const char *fmt, ...)
{
va_list args;
- alpm_cb_log logcb = alpm_option_get_logcb();
+ alpm_cb_log logcb = alpm_option_get_logcb(handle);
if(logcb == NULL) {
return;
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index d6edca1..67d31c3 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -65,7 +65,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg)
/* We only inspect packages from sync repositories */
ASSERT(pkg->origin == PKG_FROM_SYNCDB, RET_ERR(PM_ERR_PKG_INVALID, -1));
- fpath = _alpm_filecache_find(alpm_pkg_get_filename(pkg));
+ fpath = _alpm_filecache_find(pkg->handle, alpm_pkg_get_filename(pkg));
retval = _alpm_test_md5sum(fpath, alpm_pkg_get_md5sum(pkg));
@@ -341,7 +341,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
if(pkg->origin == PKG_FROM_FILE) {
/* The sane option; search locally for things that require this. */
- db = alpm_option_get_localdb();
+ db = alpm_option_get_localdb(pkg->handle);
find_requiredby(pkg, db, &reqs);
} else {
/* We have a DB package. if it is a local package, then we should
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index f6a5a1a..6ce56e5 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -104,7 +104,7 @@ static alpm_list_t *gpgme_list_sigsum(gpgme_sigsum_t sigsum)
return summary;
}
-static int gpgme_init(void)
+static int gpgme_init(pmhandle_t *handle)
{
static int init = 0;
const char *version;
@@ -116,7 +116,7 @@ static int gpgme_init(void)
return 0;
}
- if(!alpm_option_get_signaturedir()) {
+ if(!alpm_option_get_signaturedir(handle)) {
RET_ERR(PM_ERR_SIG_MISSINGDIR, 1);
}
@@ -142,7 +142,7 @@ static int gpgme_init(void)
/* set and check engine information */
err = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, NULL,
- alpm_option_get_signaturedir());
+ alpm_option_get_signaturedir(handle));
CHECK_ERR();
err = gpgme_get_engine_info(&enginfo);
CHECK_ERR();
@@ -194,12 +194,14 @@ error:
/**
* Check the PGP signature for the given file.
+ * @param handle the context handle
* @param path the full path to a file
* @param base64_sig PGP signature data in base64 encoding; if NULL, expect a
* signature file next to 'path'
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occured)
*/
-int _alpm_gpgme_checksig(const char *path, const char *base64_sig)
+int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
+ const char *base64_sig)
{
int ret = 0;
gpgme_error_t err;
@@ -226,7 +228,7 @@ int _alpm_gpgme_checksig(const char *path, const char *base64_sig)
}
}
- if(gpgme_init()) {
+ if(gpgme_init(handle)) {
/* pm_errno was set in gpgme_init() */
return -1;
}
@@ -372,7 +374,7 @@ pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db)
if(db->pgp_verify != PM_PGP_VERIFY_UNKNOWN) {
return db->pgp_verify;
} else {
- return alpm_option_get_default_sigverify();
+ return alpm_option_get_default_sigverify(db->handle);
}
}
@@ -385,7 +387,8 @@ int SYMEXPORT alpm_pkg_check_pgp_signature(pmpkg_t *pkg)
{
ASSERT(pkg != NULL, return 0);
- return _alpm_gpgme_checksig(alpm_pkg_get_filename(pkg), pkg->base64_sig);
+ return _alpm_gpgme_checksig(pkg->handle, alpm_pkg_get_filename(pkg),
+ pkg->base64_sig);
}
/**
@@ -397,7 +400,7 @@ int SYMEXPORT alpm_db_check_pgp_signature(pmdb_t *db)
{
ASSERT(db != NULL, return 0);
- return _alpm_gpgme_checksig(_alpm_db_path(db), NULL);
+ return _alpm_gpgme_checksig(db->handle, _alpm_db_path(db), NULL);
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/signing.h b/lib/libalpm/signing.h
index 8d8c164..fdf81fc 100644
--- a/lib/libalpm/signing.h
+++ b/lib/libalpm/signing.h
@@ -21,7 +21,8 @@
#include "alpm.h"
-int _alpm_gpgme_checksig(const char *path, const char *base64_sig);
+int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
+ const char *base64_sig);
pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db);
#endif /* _ALPM_SIGNING_H */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 7a33bc9..41f9f99 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -265,7 +265,7 @@ static int compute_download_size(pmpkg_t *newpkg)
fname = alpm_pkg_get_filename(newpkg);
ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1));
- fpath = _alpm_filecache_find(fname);
+ fpath = _alpm_filecache_find(newpkg->handle, fname);
if(fpath) {
FREE(fpath);
@@ -274,7 +274,7 @@ static int compute_download_size(pmpkg_t *newpkg)
off_t dltsize;
off_t pkgsize = alpm_pkg_get_size(newpkg);
- dltsize = _alpm_shortest_delta_path(
+ dltsize = _alpm_shortest_delta_path(newpkg->handle,
alpm_pkg_get_deltas(newpkg),
alpm_pkg_get_filename(newpkg),
&newpkg->delta_path);
@@ -577,15 +577,16 @@ static int endswith(const char *filename, const char *extension)
* All intermediate files are deleted, leaving only the starting and
* ending package files.
*
- * @param trans the transaction
+ * @param handle the context handle
*
* @return 0 if all delta files were able to be applied, 1 otherwise.
*/
-static int apply_deltas(pmtrans_t *trans)
+static int apply_deltas(pmhandle_t *handle)
{
alpm_list_t *i;
int ret = 0;
- const char *cachedir = _alpm_filecache_setup();
+ const char *cachedir = _alpm_filecache_setup(handle);
+ pmtrans_t *trans = handle->trans;
for(i = trans->add; i; i = i->next) {
pmpkg_t *spkg = i->data;
@@ -602,10 +603,10 @@ static int apply_deltas(pmtrans_t *trans)
char command[PATH_MAX];
size_t len = 0;
- delta = _alpm_filecache_find(d->delta);
+ delta = _alpm_filecache_find(handle, d->delta);
/* the initial package might be in a different cachedir */
if(dlts == delta_path) {
- from = _alpm_filecache_find(d->from);
+ from = _alpm_filecache_find(handle, d->from);
} else {
/* len = cachedir len + from len + '/' + null */
len = strlen(cachedir) + strlen(d->from) + 2;
@@ -686,11 +687,12 @@ static int test_md5sum(pmtrans_t *trans, const char *filepath,
return ret;
}
-static int validate_deltas(pmtrans_t *trans, alpm_list_t *deltas,
+static int validate_deltas(pmhandle_t *handle, alpm_list_t *deltas,
alpm_list_t **data)
{
int errors = 0, ret = 0;
alpm_list_t *i;
+ pmtrans_t *trans = handle->trans;
if(!deltas) {
return 0;
@@ -702,7 +704,7 @@ static int validate_deltas(pmtrans_t *trans, alpm_list_t *deltas,
for(i = deltas; i; i = i->next) {
pmdelta_t *d = alpm_list_getdata(i);
const char *filename = alpm_delta_get_filename(d);
- char *filepath = _alpm_filecache_find(filename);
+ char *filepath = _alpm_filecache_find(handle, filename);
const char *md5sum = alpm_delta_get_md5sum(d);
if(test_md5sum(trans, filepath, md5sum) != 0) {
@@ -719,7 +721,7 @@ static int validate_deltas(pmtrans_t *trans, alpm_list_t *deltas,
/* Use the deltas to generate the packages */
EVENT(trans, PM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL);
- ret = apply_deltas(trans);
+ ret = apply_deltas(handle);
EVENT(trans, PM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL);
return ret;
}
@@ -731,7 +733,7 @@ static int download_files(pmhandle_t *handle, alpm_list_t **deltas)
alpm_list_t *files = NULL;
int errors = 0;
- cachedir = _alpm_filecache_setup();
+ cachedir = _alpm_filecache_setup(handle);
handle->trans->state = STATE_DOWNLOADING;
/* Total progress - figure out the total download size if required to
@@ -844,7 +846,7 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
return -1;
}
- if(validate_deltas(trans, deltas, data)) {
+ if(validate_deltas(handle, deltas, data)) {
alpm_list_free(deltas);
return -1;
}
@@ -870,7 +872,7 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
}
filename = alpm_pkg_get_filename(spkg);
- filepath = _alpm_filecache_find(filename);
+ filepath = _alpm_filecache_find(handle, filename);
pmdb_t *sdb = alpm_pkg_get_db(spkg);
check_sig = _alpm_db_get_sigverify_level(sdb);
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index a7d762e..59f6aec 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -149,7 +149,7 @@ static alpm_list_t *check_arch(alpm_list_t *pkgs)
alpm_list_t *i;
alpm_list_t *invalid = NULL;
- const char *arch = alpm_option_get_arch();
+ const char *arch = alpm_option_get_arch(handle);
if(!arch) {
return NULL;
}
@@ -291,9 +291,9 @@ int SYMEXPORT alpm_trans_release(void)
if(!nolock_flag) {
if(remove_lock(handle)) {
_alpm_log(PM_LOG_WARNING, _("could not remove lock file %s\n"),
- alpm_option_get_lockfile());
+ alpm_option_get_lockfile(handle));
alpm_logaction(handle, "warning: could not remove lock file %s\n",
- alpm_option_get_lockfile());
+ alpm_option_get_lockfile(handle));
}
}
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index c6dba5d..174af8c 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -559,10 +559,11 @@ int _alpm_str_cmp(const void *s1, const void *s2)
}
/** Find a filename in a registered alpm cachedir.
+ * @param handle the context handle
* @param filename name of file to find
* @return malloced path of file, NULL if not found
*/
-char *_alpm_filecache_find(const char* filename)
+char *_alpm_filecache_find(pmhandle_t *handle, const char *filename)
{
char path[PATH_MAX];
char *retpath;
@@ -570,7 +571,7 @@ char *_alpm_filecache_find(const char* filename)
struct stat buf;
/* Loop through the cache dirs until we find a matching file */
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
+ for(i = alpm_option_get_cachedirs(handle); i; i = alpm_list_next(i)) {
snprintf(path, PATH_MAX, "%s%s", (char *)alpm_list_getdata(i),
filename);
if(stat(path, &buf) == 0 && S_ISREG(buf.st_mode)) {
@@ -585,16 +586,17 @@ char *_alpm_filecache_find(const char* filename)
/** Check the alpm cachedirs for existance and find a writable one.
* If no valid cache directory can be found, use /tmp.
+ * @param handle the context handle
* @return pointer to a writable cache directory.
*/
-const char *_alpm_filecache_setup(void)
+const char *_alpm_filecache_setup(pmhandle_t *handle)
{
struct stat buf;
alpm_list_t *i, *tmp;
char *cachedir;
/* Loop through the cache dirs until we find a writeable dir */
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
+ for(i = alpm_option_get_cachedirs(handle); i; i = alpm_list_next(i)) {
cachedir = alpm_list_getdata(i);
if(stat(cachedir, &buf) != 0) {
/* cache directory does not exist.... try creating it */
@@ -614,7 +616,7 @@ const char *_alpm_filecache_setup(void)
/* we didn't find a valid cache directory. use /tmp. */
tmp = alpm_list_add(NULL, "/tmp/");
- alpm_option_set_cachedirs(tmp);
+ alpm_option_set_cachedirs(handle, tmp);
alpm_list_free(tmp);
_alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", "/tmp/");
_alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 86968ae..839b802 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -97,8 +97,8 @@ int _alpm_logaction(pmhandle_t *handle, const char *fmt, va_list args);
int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[]);
int _alpm_ldconfig(pmhandle_t *handle);
int _alpm_str_cmp(const void *s1, const void *s2);
-char *_alpm_filecache_find(const char *filename);
-const char *_alpm_filecache_setup(void);
+char *_alpm_filecache_find(pmhandle_t *handle, const char *filename);
+const char *_alpm_filecache_setup(pmhandle_t *handle);
int _alpm_lstat(const char *path, struct stat *buf);
int _alpm_test_md5sum(const char *filepath, const char *md5sum);
int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b);
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index b16be04..a9ff14c 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -421,6 +421,7 @@ static int setup_libalpm(void)
{
int ret = 0;
enum _pmerrno_t err;
+ pmhandle_t *handle;
pm_printf(PM_LOG_DEBUG, "setup_libalpm called\n");
@@ -444,18 +445,19 @@ static int setup_libalpm(void)
}
/* initialize library */
- config->handle = alpm_initialize(config->rootdir, config->dbpath, &err);
- if(!config->handle) {
+ handle = alpm_initialize(config->rootdir, config->dbpath, &err);
+ if(!handle) {
pm_printf(PM_LOG_ERROR, _("failed to initialize alpm library (%s)\n"),
alpm_strerror(err));
return -1;
}
+ config->handle = handle;
- alpm_option_set_logcb(cb_log);
- alpm_option_set_dlcb(cb_dl_progress);
+ alpm_option_set_logcb(handle, cb_log);
+ alpm_option_set_dlcb(handle, cb_dl_progress);
config->logfile = config->logfile ? config->logfile : strdup(LOGFILE);
- ret = alpm_option_set_logfile(config->logfile);
+ ret = alpm_option_set_logfile(handle, config->logfile);
if(ret != 0) {
pm_printf(PM_LOG_ERROR, _("problem setting logfile '%s' (%s)\n"),
config->logfile, alpm_strerrorlast());
@@ -465,7 +467,7 @@ static int setup_libalpm(void)
/* Set GnuPG's home directory. This is not relative to rootdir, even if
* rootdir is defined. Reasoning: gpgdir contains configuration data. */
config->gpgdir = config->gpgdir ? config->gpgdir : strdup(GPGDIR);
- ret = alpm_option_set_signaturedir(config->gpgdir);
+ ret = alpm_option_set_signaturedir(handle, config->gpgdir);
if(ret != 0) {
pm_printf(PM_LOG_ERROR, _("problem setting gpgdir '%s' (%s)\n"),
config->gpgdir, alpm_strerrorlast());
@@ -474,33 +476,33 @@ static int setup_libalpm(void)
/* add a default cachedir if one wasn't specified */
if(config->cachedirs == NULL) {
- alpm_option_add_cachedir(CACHEDIR);
+ alpm_option_add_cachedir(handle, CACHEDIR);
} else {
- alpm_option_set_cachedirs(config->cachedirs);
+ alpm_option_set_cachedirs(handle, config->cachedirs);
}
if(config->sigverify != PM_PGP_VERIFY_UNKNOWN) {
- alpm_option_set_default_sigverify(config->sigverify);
+ alpm_option_set_default_sigverify(handle, config->sigverify);
}
if(config->xfercommand) {
- alpm_option_set_fetchcb(download_with_xfercommand);
+ alpm_option_set_fetchcb(handle, download_with_xfercommand);
}
if(config->totaldownload) {
- alpm_option_set_totaldlcb(cb_dl_total);
+ alpm_option_set_totaldlcb(handle, cb_dl_total);
}
- alpm_option_set_arch(config->arch);
- alpm_option_set_checkspace(config->checkspace);
- alpm_option_set_usesyslog(config->usesyslog);
- alpm_option_set_usedelta(config->usedelta);
- alpm_option_set_default_sigverify(config->sigverify);
+ alpm_option_set_arch(handle, config->arch);
+ alpm_option_set_checkspace(handle, config->checkspace);
+ alpm_option_set_usesyslog(handle, config->usesyslog);
+ alpm_option_set_usedelta(handle, config->usedelta);
+ alpm_option_set_default_sigverify(handle, config->sigverify);
- alpm_option_set_ignorepkgs(config->ignorepkg);
- alpm_option_set_ignoregrps(config->ignoregrp);
- alpm_option_set_noupgrades(config->noupgrade);
- alpm_option_set_noextracts(config->noextract);
+ alpm_option_set_ignorepkgs(handle, config->ignorepkg);
+ alpm_option_set_ignoregrps(handle, config->ignoregrp);
+ alpm_option_set_noupgrades(handle, config->noupgrade);
+ alpm_option_set_noextracts(handle, config->noextract);
return 0;
}
diff --git a/src/pacman/database.c b/src/pacman/database.c
index 123f72d..33cd49e 100644
--- a/src/pacman/database.c
+++ b/src/pacman/database.c
@@ -63,7 +63,7 @@ int pacman_database(alpm_list_t *targets)
return 1;
}
- db_local = alpm_option_get_localdb();
+ db_local = alpm_option_get_localdb(config->handle);
for(i = targets; i; i = alpm_list_next(i)) {
char *pkgname = i->data;
if(alpm_db_set_pkgreason(db_local, pkgname, reason) == -1) {
diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index 19e4da4..99abd72 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -27,12 +27,13 @@
/* pacman */
#include "pacman.h"
+#include "conf.h"
int pacman_deptest(alpm_list_t *targets)
{
alpm_list_t *i;
alpm_list_t *deps = NULL;
- pmdb_t *localdb = alpm_option_get_localdb();
+ pmdb_t *localdb = alpm_option_get_localdb(config->handle);
for(i = targets; i; i = alpm_list_next(i)) {
char *target = alpm_list_getdata(i);
diff --git a/src/pacman/package.c b/src/pacman/package.c
index e256dda..9cdb487 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -33,6 +33,7 @@
/* pacman */
#include "package.h"
#include "util.h"
+#include "conf.h"
#define CLBUF_SIZE 4096
@@ -194,7 +195,7 @@ static const char *get_backup_file_status(const char *root,
void dump_pkg_backups(pmpkg_t *pkg)
{
alpm_list_t *i;
- const char *root = alpm_option_get_root();
+ const char *root = alpm_option_get_root(config->handle);
printf(_("Backup Files:\n"));
if(alpm_pkg_get_backup(pkg)) {
/* package has backup files, so print them */
@@ -227,7 +228,7 @@ void dump_pkg_files(pmpkg_t *pkg, int quiet)
pkgname = alpm_pkg_get_name(pkg);
pkgfiles = alpm_pkg_get_files(pkg);
- root = alpm_option_get_root();
+ root = alpm_option_get_root(config->handle);
for(i = pkgfiles; i; i = alpm_list_next(i)) {
filestr = alpm_list_getdata(i);
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 544a26f..9e283b5 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -875,17 +875,17 @@ int main(int argc, char *argv[])
if(config->verbose > 0) {
alpm_list_t *i;
- printf("Root : %s\n", alpm_option_get_root());
+ printf("Root : %s\n", alpm_option_get_root(config->handle));
printf("Conf File : %s\n", config->configfile);
- printf("DB Path : %s\n", alpm_option_get_dbpath());
+ printf("DB Path : %s\n", alpm_option_get_dbpath(config->handle));
printf("Cache Dirs: ");
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
+ for(i = alpm_option_get_cachedirs(config->handle); i; i = alpm_list_next(i)) {
printf("%s ", (char *)alpm_list_getdata(i));
}
printf("\n");
- printf("Lock File : %s\n", alpm_option_get_lockfile());
- printf("Log File : %s\n", alpm_option_get_logfile());
- printf("GPG Dir : %s\n", alpm_option_get_signaturedir());
+ printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle));
+ printf("Log File : %s\n", alpm_option_get_logfile(config->handle));
+ printf("GPG Dir : %s\n", alpm_option_get_signaturedir(config->handle));
list_display("Targets :", pm_targets);
}
diff --git a/src/pacman/query.c b/src/pacman/query.c
index d1105b4..d446534 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -124,12 +124,12 @@ static int query_fileowner(alpm_list_t *targets)
/* Set up our root path buffer. We only need to copy the location of root in
* once, then we can just overwrite whatever file was there on the previous
* iteration. */
- root = alpm_option_get_root();
+ root = alpm_option_get_root(config->handle);
strncpy(path, root, PATH_MAX - 1);
append = path + strlen(path);
max_length = PATH_MAX - (append - path) - 1;
- db_local = alpm_option_get_localdb();
+ db_local = alpm_option_get_localdb(config->handle);
for(t = targets; t; t = alpm_list_next(t)) {
char *filename, *dname, *rpath;
@@ -240,7 +240,7 @@ static int query_search(alpm_list_t *targets)
{
alpm_list_t *i, *searchlist;
int freelist;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
/* if we have a targets list, search for packages matching it */
if(targets) {
@@ -299,7 +299,7 @@ static int query_group(alpm_list_t *targets)
alpm_list_t *i, *j;
char *grpname = NULL;
int ret = 0;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
if(targets == NULL) {
for(j = alpm_db_get_grpcache(db_local); j; j = alpm_list_next(j)) {
@@ -342,7 +342,7 @@ static int is_foreign(pmpkg_t *pkg)
{
const char *pkgname = alpm_pkg_get_name(pkg);
alpm_list_t *j;
- alpm_list_t *sync_dbs = alpm_option_get_syncdbs();
+ alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
int match = 0;
for(j = sync_dbs; j; j = alpm_list_next(j)) {
@@ -390,7 +390,8 @@ static int filter(pmpkg_t *pkg)
return 0;
}
/* check if this pkg is outdated */
- if(config->op_q_upgrade && (alpm_sync_newversion(pkg, alpm_option_get_syncdbs()) == NULL)) {
+ if(config->op_q_upgrade && (alpm_sync_newversion(pkg,
+ alpm_option_get_syncdbs(config->handle)) == NULL)) {
return 0;
}
return 1;
@@ -406,7 +407,7 @@ static int check(pmpkg_t *pkg)
size_t rootlen;
char f[PATH_MAX];
- root = alpm_option_get_root();
+ root = alpm_option_get_root(config->handle);
rootlen = strlen(root);
if(rootlen + 1 > PATH_MAX) {
/* we are in trouble here */
@@ -503,14 +504,14 @@ int pacman_query(alpm_list_t *targets)
if(config->op_q_foreign) {
/* ensure we have at least one valid sync db set up */
- alpm_list_t *sync_dbs = alpm_option_get_syncdbs();
+ alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
return 1;
}
}
- db_local = alpm_option_get_localdb();
+ db_local = alpm_option_get_localdb(config->handle);
/* operations on all packages in the local DB
* valid: no-op (plain -Q), list, info, check
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 094a43b..46c595f 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -34,7 +34,7 @@
static int remove_target(const char *target)
{
pmpkg_t *info;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
alpm_list_t *p;
if((info = alpm_db_get_pkg(db_local, target)) != NULL) {
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index ffc30ce..3876d92 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -51,7 +51,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)
return 1;
}
- syncdbs = alpm_option_get_syncdbs();
+ syncdbs = alpm_option_get_syncdbs(config->handle);
rewinddir(dir);
/* step through the directory one file at a time */
@@ -125,7 +125,7 @@ static int sync_cleandb_all(void)
char newdbpath[PATH_MAX];
int ret = 0;
- dbpath = alpm_option_get_dbpath();
+ dbpath = alpm_option_get_dbpath(config->handle);
printf(_("Database directory: %s\n"), dbpath);
if(!yesno(_("Do you want to remove unused repositories?"))) {
return 0;
@@ -145,11 +145,12 @@ static int sync_cleandb_all(void)
static int sync_cleancache(int level)
{
alpm_list_t *i;
- alpm_list_t *sync_dbs = alpm_option_get_syncdbs();
- pmdb_t *db_local = alpm_option_get_localdb();
+ alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
+ alpm_list_t *cachedirs = alpm_option_get_cachedirs(config->handle);
int ret = 0;
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
+ for(i = cachedirs; i; i = alpm_list_next(i)) {
printf(_("Cache directory: %s\n"), (char *)alpm_list_getdata(i));
}
@@ -177,7 +178,7 @@ static int sync_cleancache(int level)
printf(_("removing all files from cache...\n"));
}
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
+ for(i = cachedirs; i; i = alpm_list_next(i)) {
const char *cachedir = alpm_list_getdata(i);
DIR *dir = opendir(cachedir);
struct dirent *ent;
@@ -335,7 +336,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
alpm_list_t *i, *j, *ret;
int freelist;
int found = 0;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
for(i = syncs; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(i);
@@ -532,7 +533,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
{
alpm_list_t *i, *j, *ls = NULL;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
if(targets) {
for(i = targets; i; i = alpm_list_next(i)) {
@@ -587,7 +588,8 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
static alpm_list_t *syncfirst(void) {
alpm_list_t *i, *res = NULL;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
+ alpm_list_t *syncdbs = alpm_option_get_syncdbs(config->handle);
for(i = config->syncfirst; i; i = alpm_list_next(i)) {
char *pkgname = alpm_list_getdata(i);
@@ -596,7 +598,7 @@ static alpm_list_t *syncfirst(void) {
continue;
}
- if(alpm_sync_newversion(pkg, alpm_option_get_syncdbs())) {
+ if(alpm_sync_newversion(pkg, syncdbs)) {
res = alpm_list_add(res, strdup(pkgname));
}
}
@@ -607,7 +609,7 @@ static alpm_list_t *syncfirst(void) {
static pmdb_t *get_db(const char *dbname)
{
alpm_list_t *i;
- for(i = alpm_option_get_syncdbs(); i; i = i->next) {
+ for(i = alpm_option_get_syncdbs(config->handle); i; i = i->next) {
pmdb_t *db = i->data;
if(strcmp(alpm_db_get_name(db), dbname) == 0) {
return db;
@@ -726,7 +728,7 @@ static int process_target(char *target)
alpm_list_free(dblist);
} else {
targname = targstring;
- dblist = alpm_option_get_syncdbs();
+ dblist = alpm_option_get_syncdbs(config->handle);
ret = process_targname(dblist, targname);
}
cleanup:
@@ -910,7 +912,7 @@ int pacman_sync(alpm_list_t *targets)
}
/* ensure we have at least one valid sync db set up */
- sync_dbs = alpm_option_get_syncdbs();
+ sync_dbs = alpm_option_get_syncdbs(config->handle);
if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
return 1;
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index 0ffc94c..21d9411 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -42,7 +42,7 @@
int pacman_upgrade(alpm_list_t *targets)
{
alpm_list_t *i, *data = NULL;
- pgp_verify_t check_sig = alpm_option_get_default_sigverify();
+ pgp_verify_t check_sig = alpm_option_get_default_sigverify(config->handle);
int retval = 0;
if(targets == NULL) {
@@ -54,7 +54,7 @@ int pacman_upgrade(alpm_list_t *targets)
*/
for(i = targets; i; i = alpm_list_next(i)) {
if(strstr(i->data, "://")) {
- char *str = alpm_fetch_pkgurl(i->data);
+ char *str = alpm_fetch_pkgurl(config->handle, i->data);
if(str == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",
(char *)i->data, alpm_strerrorlast());
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 3233f5f..8d174e9 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -64,7 +64,8 @@ int trans_init(pmtransflag_t flags)
alpm_strerrorlast());
if(pm_errno == PM_ERR_HANDLE_LOCK) {
fprintf(stderr, _(" if you're sure a package manager is not already\n"
- " running, you can remove %s\n"), alpm_option_get_lockfile());
+ " running, you can remove %s\n"),
+ alpm_option_get_lockfile(config->handle));
}
else if(pm_errno == PM_ERR_DB_VERSION) {
fprintf(stderr, _(" try running pacman-db-upgrade\n"));
@@ -654,7 +655,7 @@ static alpm_list_t *create_verbose_row(pmpkg_t *pkg, int install)
double size;
const char *label;
alpm_list_t *ret = NULL;
- pmdb_t *ldb = alpm_option_get_localdb();
+ pmdb_t *ldb = alpm_option_get_localdb(config->handle);
/* a row consists of the package name, */
pm_asprintf(&str, "%s", alpm_pkg_get_name(pkg));
@@ -688,7 +689,7 @@ void display_targets(const alpm_list_t *pkgs, int install)
const alpm_list_t *i;
off_t isize = 0, rsize = 0, dlsize = 0;
alpm_list_t *j, *lp, *header = NULL, *targets = NULL;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
if(!pkgs) {
return;
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 9247c2c..83659cd 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
}
/* let us get log messages from libalpm */
- alpm_option_set_logcb(output_cb);
+ alpm_option_set_logcb(handle, output_cb);
checkdbs(dbpath,dbnames);
alpm_list_free(dbnames);
diff --git a/src/util/pactree.c b/src/util/pactree.c
index e2210ea..6c86942 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -97,11 +97,7 @@ static int alpm_local_init(void)
return -1;
}
- db_local = alpm_option_get_localdb();
- if(!db_local) {
- return 1;
- }
-
+ db_local = alpm_option_get_localdb(handle);
return 0;
}
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 06c01f8..c7640d9 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -61,7 +61,7 @@ static int check_localdb_files(void)
int ret = 0;
DIR *dir;
- dbpath = alpm_option_get_dbpath();
+ dbpath = alpm_option_get_dbpath(handle);
snprintf(path, sizeof(path), "%slocal", dbpath);
if(!(dir = opendir(path))) {
fprintf(stderr, "error : %s : %s\n", path, strerror(errno));
@@ -138,12 +138,7 @@ static int check_localdb(void) {
return ret;
}
- db = alpm_option_get_localdb();
- if(db == NULL) {
- fprintf(stderr, "error: could not register 'local' database (%s)\n",
- alpm_strerrorlast());
- cleanup(EXIT_FAILURE);
- }
+ db = alpm_option_get_localdb(handle);
pkglist = alpm_db_get_pkgcache(db);
ret += checkdeps(pkglist);
ret += checkconflicts(pkglist);
@@ -214,7 +209,7 @@ int main(int argc, char *argv[])
}
/* let us get log messages from libalpm */
- alpm_option_set_logcb(output_cb);
+ alpm_option_set_logcb(handle, output_cb);
if(!dbnames) {
ret = check_localdb();
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 20920ff..32011d4 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
}
/* let us get log messages from libalpm */
- alpm_option_set_logcb(output_cb);
+ alpm_option_set_logcb(handle, output_cb);
if(alpm_pkg_load(argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1
|| pkg == NULL) {
--
1.7.5.2
More information about the pacman-dev
mailing list