1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-08 12:28:00 -05:00

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>
This commit is contained in:
Dan McGee 2011-06-07 13:15:43 -05:00
parent 7968d30510
commit 17a6ac5675
32 changed files with 275 additions and 325 deletions

View File

@ -127,10 +127,11 @@ typedef int (*alpm_cb_fetch)(const char *url, const char *localpath,
int force); int force);
/** Fetch a remote pkg. /** Fetch a remote pkg.
* @param handle the context handle
* @param url URL of the package to download * @param url URL of the package to download
* @return the downloaded filepath on success, NULL on error * @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 /** @addtogroup alpm_api_options Options
* Libalpm option getters and setters * Libalpm option getters and setters
@ -138,67 +139,67 @@ char *alpm_fetch_pkgurl(const char *url);
*/ */
/** Returns the callback used for logging. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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. /** @name Accessors to the list of package cache directories.
* @{ * @{
*/ */
alpm_list_t *alpm_option_get_cachedirs(void); alpm_list_t *alpm_option_get_cachedirs(pmhandle_t *handle);
int alpm_option_set_cachedirs(alpm_list_t *cachedirs); int alpm_option_set_cachedirs(pmhandle_t *handle, alpm_list_t *cachedirs);
int alpm_option_add_cachedir(const char *cachedir); int alpm_option_add_cachedir(pmhandle_t *handle, const char *cachedir);
int alpm_option_remove_cachedir(const char *cachedir); int alpm_option_remove_cachedir(pmhandle_t *handle, const char *cachedir);
/** @} */ /** @} */
/** Returns the logfile name. */ /** Returns the logfile name. */
const char *alpm_option_get_logfile(void); const char *alpm_option_get_logfile(pmhandle_t *handle);
/** Sets the logfile name. */ /** 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. */ /** 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. */ /** 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). */ /** 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). */ /** 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. /** @name Accessors to the list of no-upgrade files.
* These functions modify the list of files which should * These functions modify the list of files which should
* not be updated by package installation. * not be updated by package installation.
* @{ * @{
*/ */
alpm_list_t *alpm_option_get_noupgrades(void); alpm_list_t *alpm_option_get_noupgrades(pmhandle_t *handle);
int alpm_option_add_noupgrade(const char *pkg); int alpm_option_add_noupgrade(pmhandle_t *handle, const char *pkg);
int alpm_option_set_noupgrades(alpm_list_t *noupgrade); int alpm_option_set_noupgrades(pmhandle_t *handle, alpm_list_t *noupgrade);
int alpm_option_remove_noupgrade(const char *pkg); int alpm_option_remove_noupgrade(pmhandle_t *handle, const char *pkg);
/** @} */ /** @} */
/** @name Accessors to the list of no-extract files. /** @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. * not be upgraded by a sysupgrade operation.
* @{ * @{
*/ */
alpm_list_t *alpm_option_get_noextracts(void); alpm_list_t *alpm_option_get_noextracts(pmhandle_t *handle);
int alpm_option_add_noextract(const char *pkg); int alpm_option_add_noextract(pmhandle_t *handle, const char *pkg);
int alpm_option_set_noextracts(alpm_list_t *noextract); int alpm_option_set_noextracts(pmhandle_t *handle, alpm_list_t *noextract);
int alpm_option_remove_noextract(const char *pkg); int alpm_option_remove_noextract(pmhandle_t *handle, const char *pkg);
/** @} */ /** @} */
/** @name Accessors to the list of ignored packages. /** @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. * should be ignored by a sysupgrade.
* @{ * @{
*/ */
alpm_list_t *alpm_option_get_ignorepkgs(void); alpm_list_t *alpm_option_get_ignorepkgs(pmhandle_t *handle);
int alpm_option_add_ignorepkg(const char *pkg); int alpm_option_add_ignorepkg(pmhandle_t *handle, const char *pkg);
int alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs); int alpm_option_set_ignorepkgs(pmhandle_t *handle, alpm_list_t *ignorepkgs);
int alpm_option_remove_ignorepkg(const char *pkg); int alpm_option_remove_ignorepkg(pmhandle_t *handle, const char *pkg);
/** @} */ /** @} */
/** @name Accessors to the list of ignored groups. /** @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. * should be ignored by a sysupgrade.
* @{ * @{
*/ */
alpm_list_t *alpm_option_get_ignoregrps(void); alpm_list_t *alpm_option_get_ignoregrps(pmhandle_t *handle);
int alpm_option_add_ignoregrp(const char *grp); int alpm_option_add_ignoregrp(pmhandle_t *handle, const char *grp);
int alpm_option_set_ignoregrps(alpm_list_t *ignoregrps); int alpm_option_set_ignoregrps(pmhandle_t *handle, alpm_list_t *ignoregrps);
int alpm_option_remove_ignoregrp(const char *grp); int alpm_option_remove_ignoregrp(pmhandle_t *handle, const char *grp);
/** @} */ /** @} */
/** Returns the targeted architecture. */ /** Returns the targeted architecture. */
const char *alpm_option_get_arch(void); const char *alpm_option_get_arch(pmhandle_t *handle);
/** Sets the targeted architecture. */ /** 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_get_usedelta(pmhandle_t *handle);
int alpm_option_set_usedelta(int usedelta); int alpm_option_set_usedelta(pmhandle_t *handle, int usedelta);
int alpm_option_get_checkspace(void); int alpm_option_get_checkspace(pmhandle_t *handle);
int alpm_option_set_checkspace(int checkspace); int alpm_option_set_checkspace(pmhandle_t *handle, int checkspace);
pgp_verify_t alpm_option_get_default_sigverify(void); pgp_verify_t alpm_option_get_default_sigverify(pmhandle_t *handle);
int alpm_option_set_default_sigverify(pgp_verify_t level); 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. * libalpm functions.
* @return a reference to the local database * @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. /** Get the list of sync databases.
* Returns a list of pmdb_t structures, one for each registered * Returns a list of pmdb_t structures, one for each registered
* sync database. * sync database.
* @return a reference to an internal list of pmdb_t structures * @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. /** Register a sync database of packages.
* @param treename the name of the sync repository * @param treename the name of the sync repository

View File

@ -205,7 +205,7 @@ static void *_cache_changelog_open(pmpkg_t *pkg)
{ {
char clfile[PATH_MAX]; char clfile[PATH_MAX];
snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog", snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog",
alpm_option_get_dbpath(), alpm_option_get_dbpath(pkg->handle),
alpm_db_get_name(alpm_pkg_get_db(pkg)), alpm_db_get_name(alpm_pkg_get_db(pkg)),
alpm_pkg_get_name(pkg), alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg)); alpm_pkg_get_version(pkg));

View File

@ -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); _alpm_log(PM_LOG_DEBUG, "base64_sig: %s\n", base64_sig);
if(check_sig != PM_PGP_VERIFY_NEVER) { if(check_sig != PM_PGP_VERIFY_NEVER) {
_alpm_log(PM_LOG_DEBUG, "checking signature for %s\n", pkgfile); _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) || if((check_sig == PM_PGP_VERIFY_ALWAYS && ret != 0) ||
(check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) { (check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) {
RET_ERR(PM_ERR_SIG_INVALID, NULL); RET_ERR(PM_ERR_SIG_INVALID, NULL);

View File

@ -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 != NULL && db != db->handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1));
ASSERT(db->servers != NULL, RET_ERR(PM_ERR_SERVER_NONE, -1)); ASSERT(db->servers != NULL, RET_ERR(PM_ERR_SERVER_NONE, -1));
dbpath = alpm_option_get_dbpath(); dbpath = alpm_option_get_dbpath(db->handle);
len = strlen(dbpath) + 6; len = strlen(dbpath) + 6;
MALLOC(syncpath, len, RET_ERR(PM_ERR_MEMORY, -1)); MALLOC(syncpath, len, RET_ERR(PM_ERR_MEMORY, -1));
sprintf(syncpath, "%s%s", dbpath, "sync/"); sprintf(syncpath, "%s%s", dbpath, "sync/");

View File

@ -360,7 +360,7 @@ const char *_alpm_db_path(pmdb_t *db)
const char *dbpath; const char *dbpath;
size_t pathsize; size_t pathsize;
dbpath = alpm_option_get_dbpath(); dbpath = alpm_option_get_dbpath(db->handle);
if(!dbpath) { if(!dbpath) {
_alpm_log(PM_LOG_ERROR, _("database path is undefined\n")); _alpm_log(PM_LOG_ERROR, _("database path is undefined\n"));
RET_ERR(PM_ERR_DB_OPEN, NULL); RET_ERR(PM_ERR_DB_OPEN, NULL);

View File

@ -111,7 +111,7 @@ static alpm_list_t *graph_init(alpm_list_t *deltas, int reverse)
return vertices; 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; alpm_list_t *i;
@ -121,7 +121,7 @@ static void graph_init_size(alpm_list_t *vertices)
pmdelta_t *vdelta = v->data; pmdelta_t *vdelta = v->data;
/* determine whether the delta file already exists */ /* 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); md5sum = alpm_compute_md5sum(fpath);
if(fpath && md5sum && strcmp(md5sum, vdelta->delta_md5) == 0) { if(fpath && md5sum && strcmp(md5sum, vdelta->delta_md5) == 0) {
vdelta->download_size = 0; vdelta->download_size = 0;
@ -130,7 +130,7 @@ static void graph_init_size(alpm_list_t *vertices)
FREE(md5sum); FREE(md5sum);
/* determine whether a base 'from' file exists */ /* determine whether a base 'from' file exists */
fpath = _alpm_filecache_find(vdelta->from); fpath = _alpm_filecache_find(handle, vdelta->from);
if(fpath) { if(fpath) {
v->weight = vdelta->download_size; 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. /** Calculates the shortest path from one version to another.
* The shortest path is defined as the path with the smallest combined * The shortest path is defined as the path with the smallest combined
* size, not the length of the path. * 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 deltas the list of pmdelta_t * objects that a file has
* @param to the file to start the search at * @param to the file to start the search at
* @param path the pointer to a list location where pmdelta_t * objects that * @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. * possible with the files available.
* @return the size of the path stored, or LONG_MAX if path is unfindable * @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) const char *to, alpm_list_t **path)
{ {
alpm_list_t *bestpath = NULL; 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); _alpm_log(PM_LOG_DEBUG, "started delta shortest-path search for '%s'\n", to);
vertices = graph_init(deltas, 0); vertices = graph_init(deltas, 0);
graph_init_size(vertices); graph_init_size(handle, vertices);
dijkstra(vertices); dijkstra(vertices);
bestsize = shortest_path(vertices, to, &bestpath); bestsize = shortest_path(vertices, to, &bestpath);

View File

@ -43,7 +43,7 @@ struct __pmdelta_t {
pmdelta_t *_alpm_delta_parse(char *line); pmdelta_t *_alpm_delta_parse(char *line);
void _alpm_delta_free(pmdelta_t *delta); 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); const char *to, alpm_list_t **path);
/* max percent of package size to download deltas */ /* max percent of package size to download deltas */

View File

@ -226,7 +226,7 @@ static int calculate_installed_size(pmhandle_t *handle,
/* approximate space requirements for db entries */ /* approximate space requirements for db entries */
if(filename[0] == '.') { if(filename[0] == '.') {
filename = alpm_option_get_dbpath(); filename = alpm_option_get_dbpath(handle);
} }
snprintf(path, PATH_MAX, "%s%s", handle->root, filename); snprintf(path, PATH_MAX, "%s%s", handle->root, filename);

View File

@ -332,7 +332,7 @@ int _alpm_download(const char *url, const char *localpath,
} }
/** Fetch a remote pkg. */ /** 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; char *filepath;
const char *filename, *cachedir; const char *filename, *cachedir;
@ -341,7 +341,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(const char *url)
filename = get_filename(url); filename = get_filename(url);
/* find a valid cache dir to download to */ /* find a valid cache dir to download to */
cachedir = _alpm_filecache_setup(); cachedir = _alpm_filecache_setup(handle);
/* download the file */ /* download the file */
ret = _alpm_download(url, cachedir, 0, 1, 0); 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 */ /* 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; return filepath;
} }

View File

@ -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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->logcb; 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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->dlcb; 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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->fetchcb; 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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->totaldlcb; return handle->totaldlcb;
} }
const char SYMEXPORT *alpm_option_get_root() const char SYMEXPORT *alpm_option_get_root(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->root; return handle->root;
} }
const char SYMEXPORT *alpm_option_get_dbpath() const char SYMEXPORT *alpm_option_get_dbpath(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->dbpath; 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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->cachedirs; return handle->cachedirs;
} }
const char SYMEXPORT *alpm_option_get_logfile() const char SYMEXPORT *alpm_option_get_logfile(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->logfile; return handle->logfile;
} }
const char SYMEXPORT *alpm_option_get_lockfile() const char SYMEXPORT *alpm_option_get_lockfile(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->lockfile; return handle->lockfile;
} }
const char SYMEXPORT *alpm_option_get_signaturedir() const char SYMEXPORT *alpm_option_get_signaturedir(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->signaturedir; return handle->signaturedir;
} }
int SYMEXPORT alpm_option_get_usesyslog() int SYMEXPORT alpm_option_get_usesyslog(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return -1);
pm_errno = PM_ERR_HANDLE_NULL;
return -1;
}
return handle->usesyslog; 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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->noupgrade; 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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->noextract; 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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->ignorepkg; 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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->ignoregrp; return handle->ignoregrp;
} }
const char SYMEXPORT *alpm_option_get_arch() const char SYMEXPORT *alpm_option_get_arch(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->arch; return handle->arch;
} }
int SYMEXPORT alpm_option_get_usedelta() int SYMEXPORT alpm_option_get_usedelta(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return -1);
pm_errno = PM_ERR_HANDLE_NULL;
return -1;
}
return handle->usedelta; return handle->usedelta;
} }
int SYMEXPORT alpm_option_get_checkspace() int SYMEXPORT alpm_option_get_checkspace(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return -1);
pm_errno = PM_ERR_HANDLE_NULL;
return -1;
}
return handle->checkspace; return handle->checkspace;
} }
pmdb_t SYMEXPORT *alpm_option_get_localdb() pmdb_t SYMEXPORT *alpm_option_get_localdb(pmhandle_t *handle)
{ {
if(handle == NULL) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->db_local; 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) { ASSERT(handle != NULL, return NULL);
pm_errno = PM_ERR_HANDLE_NULL;
return NULL;
}
return handle->dbs_sync; 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; handle->logcb = cb;
return 0; 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; handle->dlcb = cb;
return 0; 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; handle->fetchcb = cb;
return 0; 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; handle->totaldlcb = cb;
return 0; return 0;
} }
@ -344,11 +284,11 @@ enum _pmerrno_t _alpm_set_directory_option(const char *value,
return 0; 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; char *newcachedir;
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(handle != NULL, return -1);
if(!cachedir) { if(!cachedir) {
pm_errno = PM_ERR_WRONG_ARGS; pm_errno = PM_ERR_WRONG_ARGS;
return -1; return -1;
@ -362,15 +302,15 @@ int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
return 0; 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; alpm_list_t *i;
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(handle != NULL, return -1);
if(handle->cachedirs) { if(handle->cachedirs) {
FREELIST(handle->cachedirs); FREELIST(handle->cachedirs);
} }
for(i = cachedirs; i; i = i->next) { 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) { if(ret) {
return ret; return ret;
} }
@ -378,12 +318,12 @@ int SYMEXPORT alpm_option_set_cachedirs(alpm_list_t *cachedirs)
return 0; 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 *vdata = NULL;
char *newcachedir; char *newcachedir;
size_t cachedirlen; size_t cachedirlen;
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(handle != NULL, return -1);
/* verify cachedir ends in a '/' */ /* verify cachedir ends in a '/' */
cachedirlen = strlen(cachedir); cachedirlen = strlen(cachedir);
if(cachedir[cachedirlen-1] != '/') { if(cachedir[cachedirlen-1] != '/') {
@ -401,11 +341,11 @@ int SYMEXPORT alpm_option_remove_cachedir(const char *cachedir)
return 0; 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; char *oldlogfile = handle->logfile;
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(handle != NULL, return -1);
if(!logfile) { if(!logfile) {
pm_errno = PM_ERR_WRONG_ARGS; pm_errno = PM_ERR_WRONG_ARGS;
return -1; return -1;
@ -426,8 +366,9 @@ int SYMEXPORT alpm_option_set_logfile(const char *logfile)
return 0; 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) { if(!signaturedir) {
pm_errno = PM_ERR_WRONG_ARGS; pm_errno = PM_ERR_WRONG_ARGS;
return -1; return -1;
@ -442,32 +383,32 @@ int SYMEXPORT alpm_option_set_signaturedir(const char *signaturedir)
return 0; 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; handle->usesyslog = usesyslog;
return 0; 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)); handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
return 0; 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); if(handle->noupgrade) FREELIST(handle->noupgrade);
handle->noupgrade = alpm_list_strdup(noupgrade); handle->noupgrade = alpm_list_strdup(noupgrade);
return 0; 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; 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); handle->noupgrade = alpm_list_remove_str(handle->noupgrade, pkg, &vdata);
if(vdata != NULL) { if(vdata != NULL) {
FREE(vdata); FREE(vdata);
@ -476,25 +417,25 @@ int SYMEXPORT alpm_option_remove_noupgrade(const char *pkg)
return 0; 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)); handle->noextract = alpm_list_add(handle->noextract, strdup(pkg));
return 0; 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); if(handle->noextract) FREELIST(handle->noextract);
handle->noextract = alpm_list_strdup(noextract); handle->noextract = alpm_list_strdup(noextract);
return 0; 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; 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); handle->noextract = alpm_list_remove_str(handle->noextract, pkg, &vdata);
if(vdata != NULL) { if(vdata != NULL) {
FREE(vdata); FREE(vdata);
@ -503,25 +444,25 @@ int SYMEXPORT alpm_option_remove_noextract(const char *pkg)
return 0; 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)); handle->ignorepkg = alpm_list_add(handle->ignorepkg, strdup(pkg));
return 0; 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); if(handle->ignorepkg) FREELIST(handle->ignorepkg);
handle->ignorepkg = alpm_list_strdup(ignorepkgs); handle->ignorepkg = alpm_list_strdup(ignorepkgs);
return 0; 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; 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); handle->ignorepkg = alpm_list_remove_str(handle->ignorepkg, pkg, &vdata);
if(vdata != NULL) { if(vdata != NULL) {
FREE(vdata); FREE(vdata);
@ -530,25 +471,25 @@ int SYMEXPORT alpm_option_remove_ignorepkg(const char *pkg)
return 0; 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)); handle->ignoregrp = alpm_list_add(handle->ignoregrp, strdup(grp));
return 0; 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); if(handle->ignoregrp) FREELIST(handle->ignoregrp);
handle->ignoregrp = alpm_list_strdup(ignoregrps); handle->ignoregrp = alpm_list_strdup(ignoregrps);
return 0; 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; 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); handle->ignoregrp = alpm_list_remove_str(handle->ignoregrp, grp, &vdata);
if(vdata != NULL) { if(vdata != NULL) {
FREE(vdata); FREE(vdata);
@ -557,9 +498,9 @@ int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp)
return 0; 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(handle->arch) FREE(handle->arch);
if(arch) { if(arch) {
handle->arch = strdup(arch); handle->arch = strdup(arch);
@ -569,31 +510,31 @@ int SYMEXPORT alpm_option_set_arch(const char *arch)
return 0; 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; handle->usedelta = usedelta;
return 0; 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; handle->checkspace = checkspace;
return 0; 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)); ASSERT(level != PM_PGP_VERIFY_UNKNOWN, RET_ERR(PM_ERR_WRONG_ARGS, -1));
handle->sigverify = level; handle->sigverify = level;
return 0; 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; return handle->sigverify;
} }

View File

@ -89,7 +89,7 @@ int SYMEXPORT alpm_logaction(pmhandle_t *handle, const char *fmt, ...)
void _alpm_log(pmloglevel_t flag, const char *fmt, ...) void _alpm_log(pmloglevel_t flag, const char *fmt, ...)
{ {
va_list args; va_list args;
alpm_cb_log logcb = alpm_option_get_logcb(); alpm_cb_log logcb = alpm_option_get_logcb(handle);
if(logcb == NULL) { if(logcb == NULL) {
return; return;

View File

@ -65,7 +65,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg)
/* We only inspect packages from sync repositories */ /* We only inspect packages from sync repositories */
ASSERT(pkg->origin == PKG_FROM_SYNCDB, RET_ERR(PM_ERR_PKG_INVALID, -1)); 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)); 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) { if(pkg->origin == PKG_FROM_FILE) {
/* The sane option; search locally for things that require this. */ /* 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); find_requiredby(pkg, db, &reqs);
} else { } else {
/* We have a DB package. if it is a local package, then we should /* We have a DB package. if it is a local package, then we should

View File

@ -104,7 +104,7 @@ static alpm_list_t *gpgme_list_sigsum(gpgme_sigsum_t sigsum)
return summary; return summary;
} }
static int gpgme_init(void) static int gpgme_init(pmhandle_t *handle)
{ {
static int init = 0; static int init = 0;
const char *version; const char *version;
@ -116,7 +116,7 @@ static int gpgme_init(void)
return 0; return 0;
} }
if(!alpm_option_get_signaturedir()) { if(!alpm_option_get_signaturedir(handle)) {
RET_ERR(PM_ERR_SIG_MISSINGDIR, 1); RET_ERR(PM_ERR_SIG_MISSINGDIR, 1);
} }
@ -142,7 +142,7 @@ static int gpgme_init(void)
/* set and check engine information */ /* set and check engine information */
err = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, NULL, err = gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, NULL,
alpm_option_get_signaturedir()); alpm_option_get_signaturedir(handle));
CHECK_ERR(); CHECK_ERR();
err = gpgme_get_engine_info(&enginfo); err = gpgme_get_engine_info(&enginfo);
CHECK_ERR(); CHECK_ERR();
@ -194,12 +194,14 @@ error:
/** /**
* Check the PGP signature for the given file. * Check the PGP signature for the given file.
* @param handle the context handle
* @param path the full path to a file * @param path the full path to a file
* @param base64_sig PGP signature data in base64 encoding; if NULL, expect a * @param base64_sig PGP signature data in base64 encoding; if NULL, expect a
* signature file next to 'path' * signature file next to 'path'
* @return a int value : 0 (valid), 1 (invalid), -1 (an error occured) * @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; int ret = 0;
gpgme_error_t err; 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() */ /* pm_errno was set in gpgme_init() */
return -1; 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) { if(db->pgp_verify != PM_PGP_VERIFY_UNKNOWN) {
return db->pgp_verify; return db->pgp_verify;
} else { } 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); 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); 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: */ /* vim: set ts=2 sw=2 noet: */

View File

@ -21,7 +21,8 @@
#include "alpm.h" #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); pgp_verify_t _alpm_db_get_sigverify_level(pmdb_t *db);
#endif /* _ALPM_SIGNING_H */ #endif /* _ALPM_SIGNING_H */

View File

@ -265,7 +265,7 @@ static int compute_download_size(pmpkg_t *newpkg)
fname = alpm_pkg_get_filename(newpkg); fname = alpm_pkg_get_filename(newpkg);
ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1)); 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) { if(fpath) {
FREE(fpath); FREE(fpath);
@ -274,7 +274,7 @@ static int compute_download_size(pmpkg_t *newpkg)
off_t dltsize; off_t dltsize;
off_t pkgsize = alpm_pkg_get_size(newpkg); 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_deltas(newpkg),
alpm_pkg_get_filename(newpkg), alpm_pkg_get_filename(newpkg),
&newpkg->delta_path); &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 * All intermediate files are deleted, leaving only the starting and
* ending package files. * 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. * @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; alpm_list_t *i;
int ret = 0; 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) { for(i = trans->add; i; i = i->next) {
pmpkg_t *spkg = i->data; pmpkg_t *spkg = i->data;
@ -602,10 +603,10 @@ static int apply_deltas(pmtrans_t *trans)
char command[PATH_MAX]; char command[PATH_MAX];
size_t len = 0; 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 */ /* the initial package might be in a different cachedir */
if(dlts == delta_path) { if(dlts == delta_path) {
from = _alpm_filecache_find(d->from); from = _alpm_filecache_find(handle, d->from);
} else { } else {
/* len = cachedir len + from len + '/' + null */ /* len = cachedir len + from len + '/' + null */
len = strlen(cachedir) + strlen(d->from) + 2; len = strlen(cachedir) + strlen(d->from) + 2;
@ -686,11 +687,12 @@ static int test_md5sum(pmtrans_t *trans, const char *filepath,
return ret; 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) alpm_list_t **data)
{ {
int errors = 0, ret = 0; int errors = 0, ret = 0;
alpm_list_t *i; alpm_list_t *i;
pmtrans_t *trans = handle->trans;
if(!deltas) { if(!deltas) {
return 0; return 0;
@ -702,7 +704,7 @@ static int validate_deltas(pmtrans_t *trans, alpm_list_t *deltas,
for(i = deltas; i; i = i->next) { for(i = deltas; i; i = i->next) {
pmdelta_t *d = alpm_list_getdata(i); pmdelta_t *d = alpm_list_getdata(i);
const char *filename = alpm_delta_get_filename(d); 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); const char *md5sum = alpm_delta_get_md5sum(d);
if(test_md5sum(trans, filepath, md5sum) != 0) { 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 */ /* Use the deltas to generate the packages */
EVENT(trans, PM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL); 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); EVENT(trans, PM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL);
return ret; return ret;
} }
@ -731,7 +733,7 @@ static int download_files(pmhandle_t *handle, alpm_list_t **deltas)
alpm_list_t *files = NULL; alpm_list_t *files = NULL;
int errors = 0; int errors = 0;
cachedir = _alpm_filecache_setup(); cachedir = _alpm_filecache_setup(handle);
handle->trans->state = STATE_DOWNLOADING; handle->trans->state = STATE_DOWNLOADING;
/* Total progress - figure out the total download size if required to /* 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; return -1;
} }
if(validate_deltas(trans, deltas, data)) { if(validate_deltas(handle, deltas, data)) {
alpm_list_free(deltas); alpm_list_free(deltas);
return -1; return -1;
} }
@ -870,7 +872,7 @@ int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
} }
filename = alpm_pkg_get_filename(spkg); 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); pmdb_t *sdb = alpm_pkg_get_db(spkg);
check_sig = _alpm_db_get_sigverify_level(sdb); check_sig = _alpm_db_get_sigverify_level(sdb);

View File

@ -149,7 +149,7 @@ static alpm_list_t *check_arch(alpm_list_t *pkgs)
alpm_list_t *i; alpm_list_t *i;
alpm_list_t *invalid = NULL; alpm_list_t *invalid = NULL;
const char *arch = alpm_option_get_arch(); const char *arch = alpm_option_get_arch(handle);
if(!arch) { if(!arch) {
return NULL; return NULL;
} }
@ -291,9 +291,9 @@ int SYMEXPORT alpm_trans_release(void)
if(!nolock_flag) { if(!nolock_flag) {
if(remove_lock(handle)) { if(remove_lock(handle)) {
_alpm_log(PM_LOG_WARNING, _("could not remove lock file %s\n"), _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_logaction(handle, "warning: could not remove lock file %s\n",
alpm_option_get_lockfile()); alpm_option_get_lockfile(handle));
} }
} }

View File

@ -559,10 +559,11 @@ int _alpm_str_cmp(const void *s1, const void *s2)
} }
/** Find a filename in a registered alpm cachedir. /** Find a filename in a registered alpm cachedir.
* @param handle the context handle
* @param filename name of file to find * @param filename name of file to find
* @return malloced path of file, NULL if not found * @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 path[PATH_MAX];
char *retpath; char *retpath;
@ -570,7 +571,7 @@ char *_alpm_filecache_find(const char* filename)
struct stat buf; struct stat buf;
/* Loop through the cache dirs until we find a matching file */ /* 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), snprintf(path, PATH_MAX, "%s%s", (char *)alpm_list_getdata(i),
filename); filename);
if(stat(path, &buf) == 0 && S_ISREG(buf.st_mode)) { 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. /** Check the alpm cachedirs for existance and find a writable one.
* If no valid cache directory can be found, use /tmp. * If no valid cache directory can be found, use /tmp.
* @param handle the context handle
* @return pointer to a writable cache directory. * @return pointer to a writable cache directory.
*/ */
const char *_alpm_filecache_setup(void) const char *_alpm_filecache_setup(pmhandle_t *handle)
{ {
struct stat buf; struct stat buf;
alpm_list_t *i, *tmp; alpm_list_t *i, *tmp;
char *cachedir; char *cachedir;
/* Loop through the cache dirs until we find a writeable dir */ /* 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); cachedir = alpm_list_getdata(i);
if(stat(cachedir, &buf) != 0) { if(stat(cachedir, &buf) != 0) {
/* cache directory does not exist.... try creating it */ /* 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. */ /* we didn't find a valid cache directory. use /tmp. */
tmp = alpm_list_add(NULL, "/tmp/"); tmp = alpm_list_add(NULL, "/tmp/");
alpm_option_set_cachedirs(tmp); alpm_option_set_cachedirs(handle, tmp);
alpm_list_free(tmp); alpm_list_free(tmp);
_alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", "/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")); _alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));

View File

@ -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_run_chroot(pmhandle_t *handle, const char *path, char *const argv[]);
int _alpm_ldconfig(pmhandle_t *handle); int _alpm_ldconfig(pmhandle_t *handle);
int _alpm_str_cmp(const void *s1, const void *s2); int _alpm_str_cmp(const void *s1, const void *s2);
char *_alpm_filecache_find(const char *filename); char *_alpm_filecache_find(pmhandle_t *handle, const char *filename);
const char *_alpm_filecache_setup(void); const char *_alpm_filecache_setup(pmhandle_t *handle);
int _alpm_lstat(const char *path, struct stat *buf); int _alpm_lstat(const char *path, struct stat *buf);
int _alpm_test_md5sum(const char *filepath, const char *md5sum); int _alpm_test_md5sum(const char *filepath, const char *md5sum);
int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b); int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b);

View File

@ -421,6 +421,7 @@ static int setup_libalpm(void)
{ {
int ret = 0; int ret = 0;
enum _pmerrno_t err; enum _pmerrno_t err;
pmhandle_t *handle;
pm_printf(PM_LOG_DEBUG, "setup_libalpm called\n"); pm_printf(PM_LOG_DEBUG, "setup_libalpm called\n");
@ -444,18 +445,19 @@ static int setup_libalpm(void)
} }
/* initialize library */ /* initialize library */
config->handle = alpm_initialize(config->rootdir, config->dbpath, &err); handle = alpm_initialize(config->rootdir, config->dbpath, &err);
if(!config->handle) { if(!handle) {
pm_printf(PM_LOG_ERROR, _("failed to initialize alpm library (%s)\n"), pm_printf(PM_LOG_ERROR, _("failed to initialize alpm library (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
return -1; return -1;
} }
config->handle = handle;
alpm_option_set_logcb(cb_log); alpm_option_set_logcb(handle, cb_log);
alpm_option_set_dlcb(cb_dl_progress); alpm_option_set_dlcb(handle, cb_dl_progress);
config->logfile = config->logfile ? config->logfile : strdup(LOGFILE); 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) { if(ret != 0) {
pm_printf(PM_LOG_ERROR, _("problem setting logfile '%s' (%s)\n"), pm_printf(PM_LOG_ERROR, _("problem setting logfile '%s' (%s)\n"),
config->logfile, alpm_strerrorlast()); 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 /* Set GnuPG's home directory. This is not relative to rootdir, even if
* rootdir is defined. Reasoning: gpgdir contains configuration data. */ * rootdir is defined. Reasoning: gpgdir contains configuration data. */
config->gpgdir = config->gpgdir ? config->gpgdir : strdup(GPGDIR); 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) { if(ret != 0) {
pm_printf(PM_LOG_ERROR, _("problem setting gpgdir '%s' (%s)\n"), pm_printf(PM_LOG_ERROR, _("problem setting gpgdir '%s' (%s)\n"),
config->gpgdir, alpm_strerrorlast()); config->gpgdir, alpm_strerrorlast());
@ -474,33 +476,33 @@ static int setup_libalpm(void)
/* add a default cachedir if one wasn't specified */ /* add a default cachedir if one wasn't specified */
if(config->cachedirs == NULL) { if(config->cachedirs == NULL) {
alpm_option_add_cachedir(CACHEDIR); alpm_option_add_cachedir(handle, CACHEDIR);
} else { } else {
alpm_option_set_cachedirs(config->cachedirs); alpm_option_set_cachedirs(handle, config->cachedirs);
} }
if(config->sigverify != PM_PGP_VERIFY_UNKNOWN) { 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) { if(config->xfercommand) {
alpm_option_set_fetchcb(download_with_xfercommand); alpm_option_set_fetchcb(handle, download_with_xfercommand);
} }
if(config->totaldownload) { 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_arch(handle, config->arch);
alpm_option_set_checkspace(config->checkspace); alpm_option_set_checkspace(handle, config->checkspace);
alpm_option_set_usesyslog(config->usesyslog); alpm_option_set_usesyslog(handle, config->usesyslog);
alpm_option_set_usedelta(config->usedelta); alpm_option_set_usedelta(handle, config->usedelta);
alpm_option_set_default_sigverify(config->sigverify); alpm_option_set_default_sigverify(handle, config->sigverify);
alpm_option_set_ignorepkgs(config->ignorepkg); alpm_option_set_ignorepkgs(handle, config->ignorepkg);
alpm_option_set_ignoregrps(config->ignoregrp); alpm_option_set_ignoregrps(handle, config->ignoregrp);
alpm_option_set_noupgrades(config->noupgrade); alpm_option_set_noupgrades(handle, config->noupgrade);
alpm_option_set_noextracts(config->noextract); alpm_option_set_noextracts(handle, config->noextract);
return 0; return 0;
} }

View File

@ -63,7 +63,7 @@ int pacman_database(alpm_list_t *targets)
return 1; 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)) { for(i = targets; i; i = alpm_list_next(i)) {
char *pkgname = i->data; char *pkgname = i->data;
if(alpm_db_set_pkgreason(db_local, pkgname, reason) == -1) { if(alpm_db_set_pkgreason(db_local, pkgname, reason) == -1) {

View File

@ -27,12 +27,13 @@
/* pacman */ /* pacman */
#include "pacman.h" #include "pacman.h"
#include "conf.h"
int pacman_deptest(alpm_list_t *targets) int pacman_deptest(alpm_list_t *targets)
{ {
alpm_list_t *i; alpm_list_t *i;
alpm_list_t *deps = NULL; 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)) { for(i = targets; i; i = alpm_list_next(i)) {
char *target = alpm_list_getdata(i); char *target = alpm_list_getdata(i);

View File

@ -33,6 +33,7 @@
/* pacman */ /* pacman */
#include "package.h" #include "package.h"
#include "util.h" #include "util.h"
#include "conf.h"
#define CLBUF_SIZE 4096 #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) void dump_pkg_backups(pmpkg_t *pkg)
{ {
alpm_list_t *i; alpm_list_t *i;
const char *root = alpm_option_get_root(); const char *root = alpm_option_get_root(config->handle);
printf(_("Backup Files:\n")); printf(_("Backup Files:\n"));
if(alpm_pkg_get_backup(pkg)) { if(alpm_pkg_get_backup(pkg)) {
/* package has backup files, so print them */ /* 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); pkgname = alpm_pkg_get_name(pkg);
pkgfiles = alpm_pkg_get_files(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)) { for(i = pkgfiles; i; i = alpm_list_next(i)) {
filestr = alpm_list_getdata(i); filestr = alpm_list_getdata(i);

View File

@ -263,7 +263,7 @@ static void setuseragent(void)
*/ */
static void cleanup(int ret) { static void cleanup(int ret) {
/* free alpm library resources */ /* free alpm library resources */
if(alpm_release(config->handle) == -1) { if(config->handle && alpm_release(config->handle) == -1) {
pm_printf(PM_LOG_ERROR, "error releasing alpm library\n"); pm_printf(PM_LOG_ERROR, "error releasing alpm library\n");
} }
@ -875,17 +875,17 @@ int main(int argc, char *argv[])
if(config->verbose > 0) { if(config->verbose > 0) {
alpm_list_t *i; 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("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: "); 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("%s ", (char *)alpm_list_getdata(i));
} }
printf("\n"); printf("\n");
printf("Lock File : %s\n", alpm_option_get_lockfile()); printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle));
printf("Log File : %s\n", alpm_option_get_logfile()); printf("Log File : %s\n", alpm_option_get_logfile(config->handle));
printf("GPG Dir : %s\n", alpm_option_get_signaturedir()); printf("GPG Dir : %s\n", alpm_option_get_signaturedir(config->handle));
list_display("Targets :", pm_targets); list_display("Targets :", pm_targets);
} }

View File

@ -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 /* 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 * once, then we can just overwrite whatever file was there on the previous
* iteration. */ * iteration. */
root = alpm_option_get_root(); root = alpm_option_get_root(config->handle);
strncpy(path, root, PATH_MAX - 1); strncpy(path, root, PATH_MAX - 1);
append = path + strlen(path); append = path + strlen(path);
max_length = PATH_MAX - (append - path) - 1; 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)) { for(t = targets; t; t = alpm_list_next(t)) {
char *filename, *dname, *rpath; char *filename, *dname, *rpath;
@ -240,7 +240,7 @@ static int query_search(alpm_list_t *targets)
{ {
alpm_list_t *i, *searchlist; alpm_list_t *i, *searchlist;
int freelist; 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 we have a targets list, search for packages matching it */
if(targets) { if(targets) {
@ -299,7 +299,7 @@ static int query_group(alpm_list_t *targets)
alpm_list_t *i, *j; alpm_list_t *i, *j;
char *grpname = NULL; char *grpname = NULL;
int ret = 0; int ret = 0;
pmdb_t *db_local = alpm_option_get_localdb(); pmdb_t *db_local = alpm_option_get_localdb(config->handle);
if(targets == NULL) { if(targets == NULL) {
for(j = alpm_db_get_grpcache(db_local); j; j = alpm_list_next(j)) { 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); const char *pkgname = alpm_pkg_get_name(pkg);
alpm_list_t *j; 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; int match = 0;
for(j = sync_dbs; j; j = alpm_list_next(j)) { for(j = sync_dbs; j; j = alpm_list_next(j)) {
@ -390,7 +390,8 @@ static int filter(pmpkg_t *pkg)
return 0; return 0;
} }
/* check if this pkg is outdated */ /* 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 0;
} }
return 1; return 1;
@ -406,7 +407,7 @@ static int check(pmpkg_t *pkg)
size_t rootlen; size_t rootlen;
char f[PATH_MAX]; char f[PATH_MAX];
root = alpm_option_get_root(); root = alpm_option_get_root(config->handle);
rootlen = strlen(root); rootlen = strlen(root);
if(rootlen + 1 > PATH_MAX) { if(rootlen + 1 > PATH_MAX) {
/* we are in trouble here */ /* we are in trouble here */
@ -503,14 +504,14 @@ int pacman_query(alpm_list_t *targets)
if(config->op_q_foreign) { if(config->op_q_foreign) {
/* ensure we have at least one valid sync db set up */ /* 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) { if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n")); pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
return 1; return 1;
} }
} }
db_local = alpm_option_get_localdb(); db_local = alpm_option_get_localdb(config->handle);
/* operations on all packages in the local DB /* operations on all packages in the local DB
* valid: no-op (plain -Q), list, info, check * valid: no-op (plain -Q), list, info, check

View File

@ -34,7 +34,7 @@
static int remove_target(const char *target) static int remove_target(const char *target)
{ {
pmpkg_t *info; 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; alpm_list_t *p;
if((info = alpm_db_get_pkg(db_local, target)) != NULL) { if((info = alpm_db_get_pkg(db_local, target)) != NULL) {

View File

@ -51,7 +51,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)
return 1; return 1;
} }
syncdbs = alpm_option_get_syncdbs(); syncdbs = alpm_option_get_syncdbs(config->handle);
rewinddir(dir); rewinddir(dir);
/* step through the directory one file at a time */ /* step through the directory one file at a time */
@ -125,7 +125,7 @@ static int sync_cleandb_all(void)
char newdbpath[PATH_MAX]; char newdbpath[PATH_MAX];
int ret = 0; int ret = 0;
dbpath = alpm_option_get_dbpath(); dbpath = alpm_option_get_dbpath(config->handle);
printf(_("Database directory: %s\n"), dbpath); printf(_("Database directory: %s\n"), dbpath);
if(!yesno(_("Do you want to remove unused repositories?"))) { if(!yesno(_("Do you want to remove unused repositories?"))) {
return 0; return 0;
@ -145,11 +145,12 @@ static int sync_cleandb_all(void)
static int sync_cleancache(int level) static int sync_cleancache(int level)
{ {
alpm_list_t *i; alpm_list_t *i;
alpm_list_t *sync_dbs = alpm_option_get_syncdbs(); alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
pmdb_t *db_local = alpm_option_get_localdb(); pmdb_t *db_local = alpm_option_get_localdb(config->handle);
alpm_list_t *cachedirs = alpm_option_get_cachedirs(config->handle);
int ret = 0; 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)); 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")); 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); const char *cachedir = alpm_list_getdata(i);
DIR *dir = opendir(cachedir); DIR *dir = opendir(cachedir);
struct dirent *ent; 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; alpm_list_t *i, *j, *ret;
int freelist; int freelist;
int found = 0; 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)) { for(i = syncs; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(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) static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
{ {
alpm_list_t *i, *j, *ls = NULL; 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) { if(targets) {
for(i = targets; i; i = alpm_list_next(i)) { 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) { static alpm_list_t *syncfirst(void) {
alpm_list_t *i, *res = NULL; 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)) { for(i = config->syncfirst; i; i = alpm_list_next(i)) {
char *pkgname = alpm_list_getdata(i); char *pkgname = alpm_list_getdata(i);
@ -596,7 +598,7 @@ static alpm_list_t *syncfirst(void) {
continue; continue;
} }
if(alpm_sync_newversion(pkg, alpm_option_get_syncdbs())) { if(alpm_sync_newversion(pkg, syncdbs)) {
res = alpm_list_add(res, strdup(pkgname)); 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) static pmdb_t *get_db(const char *dbname)
{ {
alpm_list_t *i; 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; pmdb_t *db = i->data;
if(strcmp(alpm_db_get_name(db), dbname) == 0) { if(strcmp(alpm_db_get_name(db), dbname) == 0) {
return db; return db;
@ -726,7 +728,7 @@ static int process_target(char *target)
alpm_list_free(dblist); alpm_list_free(dblist);
} else { } else {
targname = targstring; targname = targstring;
dblist = alpm_option_get_syncdbs(); dblist = alpm_option_get_syncdbs(config->handle);
ret = process_targname(dblist, targname); ret = process_targname(dblist, targname);
} }
cleanup: cleanup:
@ -910,7 +912,7 @@ int pacman_sync(alpm_list_t *targets)
} }
/* ensure we have at least one valid sync db set up */ /* 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) { if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n")); pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
return 1; return 1;

View File

@ -42,7 +42,7 @@
int pacman_upgrade(alpm_list_t *targets) int pacman_upgrade(alpm_list_t *targets)
{ {
alpm_list_t *i, *data = NULL; 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; int retval = 0;
if(targets == NULL) { if(targets == NULL) {
@ -54,7 +54,7 @@ int pacman_upgrade(alpm_list_t *targets)
*/ */
for(i = targets; i; i = alpm_list_next(i)) { for(i = targets; i; i = alpm_list_next(i)) {
if(strstr(i->data, "://")) { if(strstr(i->data, "://")) {
char *str = alpm_fetch_pkgurl(i->data); char *str = alpm_fetch_pkgurl(config->handle, i->data);
if(str == NULL) { if(str == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",
(char *)i->data, alpm_strerrorlast()); (char *)i->data, alpm_strerrorlast());

View File

@ -64,7 +64,8 @@ int trans_init(pmtransflag_t flags)
alpm_strerrorlast()); alpm_strerrorlast());
if(pm_errno == PM_ERR_HANDLE_LOCK) { if(pm_errno == PM_ERR_HANDLE_LOCK) {
fprintf(stderr, _(" if you're sure a package manager is not already\n" 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) { else if(pm_errno == PM_ERR_DB_VERSION) {
fprintf(stderr, _(" try running pacman-db-upgrade\n")); 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; double size;
const char *label; const char *label;
alpm_list_t *ret = NULL; 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, */ /* a row consists of the package name, */
pm_asprintf(&str, "%s", alpm_pkg_get_name(pkg)); 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; const alpm_list_t *i;
off_t isize = 0, rsize = 0, dlsize = 0; off_t isize = 0, rsize = 0, dlsize = 0;
alpm_list_t *j, *lp, *header = NULL, *targets = NULL; 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) { if(!pkgs) {
return; return;

View File

@ -127,7 +127,7 @@ int main(int argc, char *argv[])
} }
/* let us get log messages from libalpm */ /* let us get log messages from libalpm */
alpm_option_set_logcb(output_cb); alpm_option_set_logcb(handle, output_cb);
checkdbs(dbpath,dbnames); checkdbs(dbpath,dbnames);
alpm_list_free(dbnames); alpm_list_free(dbnames);

View File

@ -97,11 +97,7 @@ static int alpm_local_init(void)
return -1; return -1;
} }
db_local = alpm_option_get_localdb(); db_local = alpm_option_get_localdb(handle);
if(!db_local) {
return 1;
}
return 0; return 0;
} }

View File

@ -61,7 +61,7 @@ static int check_localdb_files(void)
int ret = 0; int ret = 0;
DIR *dir; DIR *dir;
dbpath = alpm_option_get_dbpath(); dbpath = alpm_option_get_dbpath(handle);
snprintf(path, sizeof(path), "%slocal", dbpath); snprintf(path, sizeof(path), "%slocal", dbpath);
if(!(dir = opendir(path))) { if(!(dir = opendir(path))) {
fprintf(stderr, "error : %s : %s\n", path, strerror(errno)); fprintf(stderr, "error : %s : %s\n", path, strerror(errno));
@ -138,12 +138,7 @@ static int check_localdb(void) {
return ret; return ret;
} }
db = alpm_option_get_localdb(); db = alpm_option_get_localdb(handle);
if(db == NULL) {
fprintf(stderr, "error: could not register 'local' database (%s)\n",
alpm_strerrorlast());
cleanup(EXIT_FAILURE);
}
pkglist = alpm_db_get_pkgcache(db); pkglist = alpm_db_get_pkgcache(db);
ret += checkdeps(pkglist); ret += checkdeps(pkglist);
ret += checkconflicts(pkglist); ret += checkconflicts(pkglist);
@ -214,7 +209,7 @@ int main(int argc, char *argv[])
} }
/* let us get log messages from libalpm */ /* let us get log messages from libalpm */
alpm_option_set_logcb(output_cb); alpm_option_set_logcb(handle, output_cb);
if(!dbnames) { if(!dbnames) {
ret = check_localdb(); ret = check_localdb();

View File

@ -56,7 +56,7 @@ int main(int argc, char *argv[])
} }
/* let us get log messages from libalpm */ /* 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 if(alpm_pkg_load(argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1
|| pkg == NULL) { || pkg == NULL) {