summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-07 13:15:43 -0500
committerDan McGee <dan@archlinux.org>2011-06-09 14:24:45 -0500
commit17a6ac567502975d3a98a34ed58d79c05eb7b8d1 (patch)
treefb764ae26aac86fd43daa79cb0047cc82f8039e9 /lib/libalpm
parent7968d30510de5a6031af39da498be5c821290b82 (diff)
downloadpacman-17a6ac567502975d3a98a34ed58d79c05eb7b8d1.tar.xz
Require handle argument to all alpm_option_(get|set)_*() methods
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@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/alpm.h97
-rw-r--r--lib/libalpm/be_local.c2
-rw-r--r--lib/libalpm/be_package.c2
-rw-r--r--lib/libalpm/be_sync.c2
-rw-r--r--lib/libalpm/db.c2
-rw-r--r--lib/libalpm/delta.c11
-rw-r--r--lib/libalpm/delta.h2
-rw-r--r--lib/libalpm/diskspace.c2
-rw-r--r--lib/libalpm/dload.c6
-rw-r--r--lib/libalpm/handle.c249
-rw-r--r--lib/libalpm/log.c2
-rw-r--r--lib/libalpm/package.c4
-rw-r--r--lib/libalpm/signing.c19
-rw-r--r--lib/libalpm/signing.h3
-rw-r--r--lib/libalpm/sync.c28
-rw-r--r--lib/libalpm/trans.c6
-rw-r--r--lib/libalpm/util.c12
-rw-r--r--lib/libalpm/util.h4
18 files changed, 202 insertions, 251 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index f46c1548..26ed1e5c 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 3a0887d0..42ddaf56 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 c89365a2..0545167e 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 0c50c424..a75cbda2 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 fda8428a..61143349 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 cd234874..645c7bac 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 bd196bab..d7725f5a 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 c6c0b98f..7be54644 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 8591c9d5..0ba3bc1d 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 730372a7..209ae344 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 30d1d6f8..023bfc9e 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 d6edca1f..67d31c38 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 f6a5a1ae..6ce56e59 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 8d8c1643..fdf81fcf 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 7a33bc97..41f9f996 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 a7d762ea..59f6aeca 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 68732d13..6b11c3a9 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 86968ae5..839b802f 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);