summaryrefslogtreecommitdiff
path: root/src/pacman/sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/sync.c')
-rw-r--r--src/pacman/sync.c78
1 files changed, 42 insertions, 36 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 884504f3..37b9d6e3 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;
@@ -219,7 +220,7 @@ static int sync_cleancache(int level)
/* attempt to load the package, prompt removal on failures as we may have
* files here that aren't valid packages. we also don't need a full
* load of the package, just the metadata. */
- if(alpm_pkg_load(path, 0, PM_PGP_VERIFY_NEVER, &localpkg) != 0
+ if(alpm_pkg_load(config->handle, path, 0, PM_PGP_VERIFY_NEVER, &localpkg) != 0
|| localpkg == NULL) {
if(yesno(_("File %s does not seem to be a valid package, remove it?"),
path)) {
@@ -292,7 +293,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
ret = alpm_db_update((level < 2 ? 0 : 1), db);
if(ret < 0) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to update %s (%s)\n"),
- alpm_db_get_name(db), alpm_strerrorlast());
+ alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle)));
} else if(ret == 1) {
printf(_(" %s is up to date\n"), alpm_db_get_name(db));
success++;
@@ -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;
@@ -618,17 +620,18 @@ static pmdb_t *get_db(const char *dbname)
static int process_pkg(pmpkg_t *pkg)
{
- int ret = alpm_add_pkg(pkg);
+ int ret = alpm_add_pkg(config->handle, pkg);
if(ret == -1) {
- if(pm_errno == PM_ERR_TRANS_DUP_TARGET
- || pm_errno == PM_ERR_PKG_IGNORED) {
+ enum _pmerrno_t err = alpm_errno(config->handle);
+ if(err == PM_ERR_TRANS_DUP_TARGET
+ || err == PM_ERR_PKG_IGNORED) {
/* just skip duplicate or ignored targets */
pm_printf(PM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg));
return 0;
} else {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg),
- alpm_strerrorlast());
+ alpm_strerror(err));
return 1;
}
}
@@ -683,12 +686,13 @@ cleanup:
static int process_targname(alpm_list_t *dblist, char *targname)
{
- pmpkg_t *pkg = alpm_find_dbs_satisfier(dblist, targname);
+ pmpkg_t *pkg = alpm_find_dbs_satisfier(config->handle, dblist, targname);
- /* #FS23342 - skip ignored packages when user says no */
- if(pm_errno == PM_ERR_PKG_IGNORED) {
+ /* #FS#23342 - skip ignored packages when user says no */
+ if(alpm_errno(config->handle) == PM_ERR_PKG_IGNORED) {
pm_printf(PM_LOG_WARNING, _("skipping target: %s\n"), targname);
- pm_errno = 0;
+ /* TODO how to do this, we shouldn't be fucking with it from the frontend */
+ /* pm_errno = 0; */
return 0;
}
@@ -726,7 +730,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:
@@ -757,19 +761,20 @@ static int sync_trans(alpm_list_t *targets)
if(config->op_s_upgrade) {
printf(_(":: Starting full system upgrade...\n"));
- alpm_logaction("starting full system upgrade\n");
- if(alpm_sync_sysupgrade(config->op_s_upgrade >= 2) == -1) {
- pm_fprintf(stderr, PM_LOG_ERROR, "%s\n", alpm_strerrorlast());
+ alpm_logaction(config->handle, "starting full system upgrade\n");
+ if(alpm_sync_sysupgrade(config->handle, config->op_s_upgrade >= 2) == -1) {
+ pm_fprintf(stderr, PM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle)));
retval = 1;
goto cleanup;
}
}
/* Step 2: "compute" the transaction based on targets and flags */
- if(alpm_trans_prepare(&data) == -1) {
+ if(alpm_trans_prepare(config->handle, &data) == -1) {
+ enum _pmerrno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to prepare transaction (%s)\n"),
- alpm_strerrorlast());
- switch(pm_errno) {
+ alpm_strerror(err));
+ switch(err) {
alpm_list_t *i;
case PM_ERR_PKG_INVALID_ARCH:
for(i = data; i; i = alpm_list_next(i)) {
@@ -808,7 +813,7 @@ static int sync_trans(alpm_list_t *targets)
goto cleanup;
}
- packages = alpm_trans_get_add();
+ packages = alpm_trans_get_add(config->handle);
if(packages == NULL) {
/* nothing to do: just exit without complaining */
printf(_(" there is nothing to do\n"));
@@ -821,8 +826,8 @@ static int sync_trans(alpm_list_t *targets)
goto cleanup;
}
- display_targets(alpm_trans_get_remove(), 0);
- display_targets(alpm_trans_get_add(), 1);
+ display_targets(alpm_trans_get_remove(config->handle), 0);
+ display_targets(alpm_trans_get_add(config->handle), 1);
printf("\n");
int confirm;
@@ -835,10 +840,11 @@ static int sync_trans(alpm_list_t *targets)
goto cleanup;
}
- if(alpm_trans_commit(&data) == -1) {
+ if(alpm_trans_commit(config->handle, &data) == -1) {
+ enum _pmerrno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
- alpm_strerrorlast());
- switch(pm_errno) {
+ alpm_strerror(err));
+ switch(err) {
alpm_list_t *i;
case PM_ERR_FILE_CONFLICTS:
for(i = data; i; i = alpm_list_next(i)) {
@@ -910,7 +916,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;
@@ -919,7 +925,7 @@ int pacman_sync(alpm_list_t *targets)
if(config->op_s_sync) {
/* grab a fresh package list */
printf(_(":: Synchronizing package databases...\n"));
- alpm_logaction("synchronizing package lists\n");
+ alpm_logaction(config->handle, "synchronizing package lists\n");
if(!sync_synctree(config->op_s_sync, sync_dbs)) {
return 1;
}