summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-07 20:15:43 +0200
committerDan McGee <dan@archlinux.org>2011-06-09 21:24:45 +0200
commit17a6ac567502975d3a98a34ed58d79c05eb7b8d1 (patch)
treefb764ae26aac86fd43daa79cb0047cc82f8039e9 /src
parent7968d30510de5a6031af39da498be5c821290b82 (diff)
downloadpacman-17a6ac567502975d3a98a34ed58d79c05eb7b8d1.tar.gz
pacman-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 'src')
-rw-r--r--src/pacman/conf.c42
-rw-r--r--src/pacman/database.c2
-rw-r--r--src/pacman/deptest.c3
-rw-r--r--src/pacman/package.c5
-rw-r--r--src/pacman/pacman.c14
-rw-r--r--src/pacman/query.c19
-rw-r--r--src/pacman/remove.c2
-rw-r--r--src/pacman/sync.c28
-rw-r--r--src/pacman/upgrade.c4
-rw-r--r--src/pacman/util.c7
-rw-r--r--src/util/cleanupdelta.c2
-rw-r--r--src/util/pactree.c6
-rw-r--r--src/util/testdb.c11
-rw-r--r--src/util/testpkg.c2
14 files changed, 73 insertions, 74 deletions
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 512eade0..c52c6044 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -421,6 +421,7 @@ static int setup_libalpm(void)
{
int ret = 0;
enum _pmerrno_t err;
+ pmhandle_t *handle;
pm_printf(PM_LOG_DEBUG, "setup_libalpm called\n");
@@ -444,18 +445,19 @@ static int setup_libalpm(void)
}
/* initialize library */
- config->handle = alpm_initialize(config->rootdir, config->dbpath, &err);
- if(!config->handle) {
+ handle = alpm_initialize(config->rootdir, config->dbpath, &err);
+ if(!handle) {
pm_printf(PM_LOG_ERROR, _("failed to initialize alpm library (%s)\n"),
alpm_strerror(err));
return -1;
}
+ config->handle = handle;
- alpm_option_set_logcb(cb_log);
- alpm_option_set_dlcb(cb_dl_progress);
+ alpm_option_set_logcb(handle, cb_log);
+ alpm_option_set_dlcb(handle, cb_dl_progress);
config->logfile = config->logfile ? config->logfile : strdup(LOGFILE);
- ret = alpm_option_set_logfile(config->logfile);
+ ret = alpm_option_set_logfile(handle, config->logfile);
if(ret != 0) {
pm_printf(PM_LOG_ERROR, _("problem setting logfile '%s' (%s)\n"),
config->logfile, alpm_strerrorlast());
@@ -465,7 +467,7 @@ static int setup_libalpm(void)
/* Set GnuPG's home directory. This is not relative to rootdir, even if
* rootdir is defined. Reasoning: gpgdir contains configuration data. */
config->gpgdir = config->gpgdir ? config->gpgdir : strdup(GPGDIR);
- ret = alpm_option_set_signaturedir(config->gpgdir);
+ ret = alpm_option_set_signaturedir(handle, config->gpgdir);
if(ret != 0) {
pm_printf(PM_LOG_ERROR, _("problem setting gpgdir '%s' (%s)\n"),
config->gpgdir, alpm_strerrorlast());
@@ -474,33 +476,33 @@ static int setup_libalpm(void)
/* add a default cachedir if one wasn't specified */
if(config->cachedirs == NULL) {
- alpm_option_add_cachedir(CACHEDIR);
+ alpm_option_add_cachedir(handle, CACHEDIR);
} else {
- alpm_option_set_cachedirs(config->cachedirs);
+ alpm_option_set_cachedirs(handle, config->cachedirs);
}
if(config->sigverify != PM_PGP_VERIFY_UNKNOWN) {
- alpm_option_set_default_sigverify(config->sigverify);
+ alpm_option_set_default_sigverify(handle, config->sigverify);
}
if(config->xfercommand) {
- alpm_option_set_fetchcb(download_with_xfercommand);
+ alpm_option_set_fetchcb(handle, download_with_xfercommand);
}
if(config->totaldownload) {
- alpm_option_set_totaldlcb(cb_dl_total);
+ alpm_option_set_totaldlcb(handle, cb_dl_total);
}
- alpm_option_set_arch(config->arch);
- alpm_option_set_checkspace(config->checkspace);
- alpm_option_set_usesyslog(config->usesyslog);
- alpm_option_set_usedelta(config->usedelta);
- alpm_option_set_default_sigverify(config->sigverify);
+ alpm_option_set_arch(handle, config->arch);
+ alpm_option_set_checkspace(handle, config->checkspace);
+ alpm_option_set_usesyslog(handle, config->usesyslog);
+ alpm_option_set_usedelta(handle, config->usedelta);
+ alpm_option_set_default_sigverify(handle, config->sigverify);
- alpm_option_set_ignorepkgs(config->ignorepkg);
- alpm_option_set_ignoregrps(config->ignoregrp);
- alpm_option_set_noupgrades(config->noupgrade);
- alpm_option_set_noextracts(config->noextract);
+ alpm_option_set_ignorepkgs(handle, config->ignorepkg);
+ alpm_option_set_ignoregrps(handle, config->ignoregrp);
+ alpm_option_set_noupgrades(handle, config->noupgrade);
+ alpm_option_set_noextracts(handle, config->noextract);
return 0;
}
diff --git a/src/pacman/database.c b/src/pacman/database.c
index 123f72d2..33cd49e3 100644
--- a/src/pacman/database.c
+++ b/src/pacman/database.c
@@ -63,7 +63,7 @@ int pacman_database(alpm_list_t *targets)
return 1;
}
- db_local = alpm_option_get_localdb();
+ db_local = alpm_option_get_localdb(config->handle);
for(i = targets; i; i = alpm_list_next(i)) {
char *pkgname = i->data;
if(alpm_db_set_pkgreason(db_local, pkgname, reason) == -1) {
diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index 19e4da4a..99abd72d 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -27,12 +27,13 @@
/* pacman */
#include "pacman.h"
+#include "conf.h"
int pacman_deptest(alpm_list_t *targets)
{
alpm_list_t *i;
alpm_list_t *deps = NULL;
- pmdb_t *localdb = alpm_option_get_localdb();
+ pmdb_t *localdb = alpm_option_get_localdb(config->handle);
for(i = targets; i; i = alpm_list_next(i)) {
char *target = alpm_list_getdata(i);
diff --git a/src/pacman/package.c b/src/pacman/package.c
index e256dda5..9cdb4877 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -33,6 +33,7 @@
/* pacman */
#include "package.h"
#include "util.h"
+#include "conf.h"
#define CLBUF_SIZE 4096
@@ -194,7 +195,7 @@ static const char *get_backup_file_status(const char *root,
void dump_pkg_backups(pmpkg_t *pkg)
{
alpm_list_t *i;
- const char *root = alpm_option_get_root();
+ const char *root = alpm_option_get_root(config->handle);
printf(_("Backup Files:\n"));
if(alpm_pkg_get_backup(pkg)) {
/* package has backup files, so print them */
@@ -227,7 +228,7 @@ void dump_pkg_files(pmpkg_t *pkg, int quiet)
pkgname = alpm_pkg_get_name(pkg);
pkgfiles = alpm_pkg_get_files(pkg);
- root = alpm_option_get_root();
+ root = alpm_option_get_root(config->handle);
for(i = pkgfiles; i; i = alpm_list_next(i)) {
filestr = alpm_list_getdata(i);
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 544a26fe..c186ebed 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -263,7 +263,7 @@ static void setuseragent(void)
*/
static void cleanup(int ret) {
/* 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");
}
@@ -875,17 +875,17 @@ int main(int argc, char *argv[])
if(config->verbose > 0) {
alpm_list_t *i;
- printf("Root : %s\n", alpm_option_get_root());
+ printf("Root : %s\n", alpm_option_get_root(config->handle));
printf("Conf File : %s\n", config->configfile);
- printf("DB Path : %s\n", alpm_option_get_dbpath());
+ printf("DB Path : %s\n", alpm_option_get_dbpath(config->handle));
printf("Cache Dirs: ");
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
+ for(i = alpm_option_get_cachedirs(config->handle); i; i = alpm_list_next(i)) {
printf("%s ", (char *)alpm_list_getdata(i));
}
printf("\n");
- printf("Lock File : %s\n", alpm_option_get_lockfile());
- printf("Log File : %s\n", alpm_option_get_logfile());
- printf("GPG Dir : %s\n", alpm_option_get_signaturedir());
+ printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle));
+ printf("Log File : %s\n", alpm_option_get_logfile(config->handle));
+ printf("GPG Dir : %s\n", alpm_option_get_signaturedir(config->handle));
list_display("Targets :", pm_targets);
}
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 9e81e26d..cf24306c 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -124,12 +124,12 @@ static int query_fileowner(alpm_list_t *targets)
/* Set up our root path buffer. We only need to copy the location of root in
* once, then we can just overwrite whatever file was there on the previous
* iteration. */
- root = alpm_option_get_root();
+ root = alpm_option_get_root(config->handle);
strncpy(path, root, PATH_MAX - 1);
append = path + strlen(path);
max_length = PATH_MAX - (append - path) - 1;
- db_local = alpm_option_get_localdb();
+ db_local = alpm_option_get_localdb(config->handle);
for(t = targets; t; t = alpm_list_next(t)) {
char *filename, *dname, *rpath;
@@ -240,7 +240,7 @@ static int query_search(alpm_list_t *targets)
{
alpm_list_t *i, *searchlist;
int freelist;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
/* if we have a targets list, search for packages matching it */
if(targets) {
@@ -299,7 +299,7 @@ static int query_group(alpm_list_t *targets)
alpm_list_t *i, *j;
char *grpname = NULL;
int ret = 0;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
if(targets == NULL) {
for(j = alpm_db_get_grpcache(db_local); j; j = alpm_list_next(j)) {
@@ -342,7 +342,7 @@ static int is_foreign(pmpkg_t *pkg)
{
const char *pkgname = alpm_pkg_get_name(pkg);
alpm_list_t *j;
- alpm_list_t *sync_dbs = alpm_option_get_syncdbs();
+ alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
int match = 0;
for(j = sync_dbs; j; j = alpm_list_next(j)) {
@@ -390,7 +390,8 @@ static int filter(pmpkg_t *pkg)
return 0;
}
/* check if this pkg is outdated */
- if(config->op_q_upgrade && (alpm_sync_newversion(pkg, alpm_option_get_syncdbs()) == NULL)) {
+ if(config->op_q_upgrade && (alpm_sync_newversion(pkg,
+ alpm_option_get_syncdbs(config->handle)) == NULL)) {
return 0;
}
return 1;
@@ -406,7 +407,7 @@ static int check(pmpkg_t *pkg)
size_t rootlen;
char f[PATH_MAX];
- root = alpm_option_get_root();
+ root = alpm_option_get_root(config->handle);
rootlen = strlen(root);
if(rootlen + 1 > PATH_MAX) {
/* we are in trouble here */
@@ -503,14 +504,14 @@ int pacman_query(alpm_list_t *targets)
if(config->op_q_foreign) {
/* ensure we have at least one valid sync db set up */
- alpm_list_t *sync_dbs = alpm_option_get_syncdbs();
+ alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
return 1;
}
}
- db_local = alpm_option_get_localdb();
+ db_local = alpm_option_get_localdb(config->handle);
/* operations on all packages in the local DB
* valid: no-op (plain -Q), list, info, check
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 094a43bf..46c595f9 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -34,7 +34,7 @@
static int remove_target(const char *target)
{
pmpkg_t *info;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
alpm_list_t *p;
if((info = alpm_db_get_pkg(db_local, target)) != NULL) {
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index ffc30ce5..3876d92c 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -51,7 +51,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)
return 1;
}
- syncdbs = alpm_option_get_syncdbs();
+ syncdbs = alpm_option_get_syncdbs(config->handle);
rewinddir(dir);
/* step through the directory one file at a time */
@@ -125,7 +125,7 @@ static int sync_cleandb_all(void)
char newdbpath[PATH_MAX];
int ret = 0;
- dbpath = alpm_option_get_dbpath();
+ dbpath = alpm_option_get_dbpath(config->handle);
printf(_("Database directory: %s\n"), dbpath);
if(!yesno(_("Do you want to remove unused repositories?"))) {
return 0;
@@ -145,11 +145,12 @@ static int sync_cleandb_all(void)
static int sync_cleancache(int level)
{
alpm_list_t *i;
- alpm_list_t *sync_dbs = alpm_option_get_syncdbs();
- pmdb_t *db_local = alpm_option_get_localdb();
+ alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
+ alpm_list_t *cachedirs = alpm_option_get_cachedirs(config->handle);
int ret = 0;
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
+ for(i = cachedirs; i; i = alpm_list_next(i)) {
printf(_("Cache directory: %s\n"), (char *)alpm_list_getdata(i));
}
@@ -177,7 +178,7 @@ static int sync_cleancache(int level)
printf(_("removing all files from cache...\n"));
}
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
+ for(i = cachedirs; i; i = alpm_list_next(i)) {
const char *cachedir = alpm_list_getdata(i);
DIR *dir = opendir(cachedir);
struct dirent *ent;
@@ -335,7 +336,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
alpm_list_t *i, *j, *ret;
int freelist;
int found = 0;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
for(i = syncs; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(i);
@@ -532,7 +533,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
{
alpm_list_t *i, *j, *ls = NULL;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
if(targets) {
for(i = targets; i; i = alpm_list_next(i)) {
@@ -587,7 +588,8 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
static alpm_list_t *syncfirst(void) {
alpm_list_t *i, *res = NULL;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
+ alpm_list_t *syncdbs = alpm_option_get_syncdbs(config->handle);
for(i = config->syncfirst; i; i = alpm_list_next(i)) {
char *pkgname = alpm_list_getdata(i);
@@ -596,7 +598,7 @@ static alpm_list_t *syncfirst(void) {
continue;
}
- if(alpm_sync_newversion(pkg, alpm_option_get_syncdbs())) {
+ if(alpm_sync_newversion(pkg, syncdbs)) {
res = alpm_list_add(res, strdup(pkgname));
}
}
@@ -607,7 +609,7 @@ static alpm_list_t *syncfirst(void) {
static pmdb_t *get_db(const char *dbname)
{
alpm_list_t *i;
- for(i = alpm_option_get_syncdbs(); i; i = i->next) {
+ for(i = alpm_option_get_syncdbs(config->handle); i; i = i->next) {
pmdb_t *db = i->data;
if(strcmp(alpm_db_get_name(db), dbname) == 0) {
return db;
@@ -726,7 +728,7 @@ static int process_target(char *target)
alpm_list_free(dblist);
} else {
targname = targstring;
- dblist = alpm_option_get_syncdbs();
+ dblist = alpm_option_get_syncdbs(config->handle);
ret = process_targname(dblist, targname);
}
cleanup:
@@ -910,7 +912,7 @@ int pacman_sync(alpm_list_t *targets)
}
/* ensure we have at least one valid sync db set up */
- sync_dbs = alpm_option_get_syncdbs();
+ sync_dbs = alpm_option_get_syncdbs(config->handle);
if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
return 1;
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index 0ffc94c4..21d9411e 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -42,7 +42,7 @@
int pacman_upgrade(alpm_list_t *targets)
{
alpm_list_t *i, *data = NULL;
- pgp_verify_t check_sig = alpm_option_get_default_sigverify();
+ pgp_verify_t check_sig = alpm_option_get_default_sigverify(config->handle);
int retval = 0;
if(targets == NULL) {
@@ -54,7 +54,7 @@ int pacman_upgrade(alpm_list_t *targets)
*/
for(i = targets; i; i = alpm_list_next(i)) {
if(strstr(i->data, "://")) {
- char *str = alpm_fetch_pkgurl(i->data);
+ char *str = alpm_fetch_pkgurl(config->handle, i->data);
if(str == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n",
(char *)i->data, alpm_strerrorlast());
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 3233f5f7..8d174e94 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -64,7 +64,8 @@ int trans_init(pmtransflag_t flags)
alpm_strerrorlast());
if(pm_errno == PM_ERR_HANDLE_LOCK) {
fprintf(stderr, _(" if you're sure a package manager is not already\n"
- " running, you can remove %s\n"), alpm_option_get_lockfile());
+ " running, you can remove %s\n"),
+ alpm_option_get_lockfile(config->handle));
}
else if(pm_errno == PM_ERR_DB_VERSION) {
fprintf(stderr, _(" try running pacman-db-upgrade\n"));
@@ -654,7 +655,7 @@ static alpm_list_t *create_verbose_row(pmpkg_t *pkg, int install)
double size;
const char *label;
alpm_list_t *ret = NULL;
- pmdb_t *ldb = alpm_option_get_localdb();
+ pmdb_t *ldb = alpm_option_get_localdb(config->handle);
/* a row consists of the package name, */
pm_asprintf(&str, "%s", alpm_pkg_get_name(pkg));
@@ -688,7 +689,7 @@ void display_targets(const alpm_list_t *pkgs, int install)
const alpm_list_t *i;
off_t isize = 0, rsize = 0, dlsize = 0;
alpm_list_t *j, *lp, *header = NULL, *targets = NULL;
- pmdb_t *db_local = alpm_option_get_localdb();
+ pmdb_t *db_local = alpm_option_get_localdb(config->handle);
if(!pkgs) {
return;
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 9247c2c2..83659cd5 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
}
/* let us get log messages from libalpm */
- alpm_option_set_logcb(output_cb);
+ alpm_option_set_logcb(handle, output_cb);
checkdbs(dbpath,dbnames);
alpm_list_free(dbnames);
diff --git a/src/util/pactree.c b/src/util/pactree.c
index e2210ea4..6c869426 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -97,11 +97,7 @@ static int alpm_local_init(void)
return -1;
}
- db_local = alpm_option_get_localdb();
- if(!db_local) {
- return 1;
- }
-
+ db_local = alpm_option_get_localdb(handle);
return 0;
}
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 06c01f8d..c7640d91 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -61,7 +61,7 @@ static int check_localdb_files(void)
int ret = 0;
DIR *dir;
- dbpath = alpm_option_get_dbpath();
+ dbpath = alpm_option_get_dbpath(handle);
snprintf(path, sizeof(path), "%slocal", dbpath);
if(!(dir = opendir(path))) {
fprintf(stderr, "error : %s : %s\n", path, strerror(errno));
@@ -138,12 +138,7 @@ static int check_localdb(void) {
return ret;
}
- db = alpm_option_get_localdb();
- if(db == NULL) {
- fprintf(stderr, "error: could not register 'local' database (%s)\n",
- alpm_strerrorlast());
- cleanup(EXIT_FAILURE);
- }
+ db = alpm_option_get_localdb(handle);
pkglist = alpm_db_get_pkgcache(db);
ret += checkdeps(pkglist);
ret += checkconflicts(pkglist);
@@ -214,7 +209,7 @@ int main(int argc, char *argv[])
}
/* let us get log messages from libalpm */
- alpm_option_set_logcb(output_cb);
+ alpm_option_set_logcb(handle, output_cb);
if(!dbnames) {
ret = check_localdb();
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 20920ff0..32011d46 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
}
/* let us get log messages from libalpm */
- alpm_option_set_logcb(output_cb);
+ alpm_option_set_logcb(handle, output_cb);
if(alpm_pkg_load(argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1
|| pkg == NULL) {