diff options
Diffstat (limited to 'src/pacman/remove.c')
-rw-r--r-- | src/pacman/remove.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 58e6edd5..a4e18941 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -31,15 +31,16 @@ #include "util.h" #include "conf.h" -static int remove_target(char *target) +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) { - if(alpm_remove_pkg(info) == -1) { - pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", target, alpm_strerrorlast()); + if(alpm_remove_pkg(config->handle, info) == -1) { + pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", target, + alpm_strerror(alpm_errno(config->handle))); return -1; } return 0; @@ -53,8 +54,9 @@ static int remove_target(char *target) } for(p = alpm_grp_get_pkgs(grp); p; p = alpm_list_next(p)) { pmpkg_t *pkg = alpm_list_getdata(p); - if(alpm_remove_pkg(pkg) == -1) { - pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", target, alpm_strerrorlast()); + if(alpm_remove_pkg(config->handle, pkg) == -1) { + pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", target, + alpm_strerror(alpm_errno(config->handle))); return -1; } } @@ -99,10 +101,11 @@ int pacman_remove(alpm_list_t *targets) } /* Step 2: prepare the transaction based on its type, 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) { case PM_ERR_PKG_INVALID_ARCH: for(i = data; i; i = alpm_list_next(i)) { char *pkg = alpm_list_getdata(i); @@ -118,18 +121,18 @@ int pacman_remove(alpm_list_t *targets) depstring); free(depstring); } - FREELIST(data); break; default: break; } + FREELIST(data); retval = 1; goto cleanup; } /* Search for holdpkg in target list */ int holdpkg = 0; - for(i = alpm_trans_get_remove(); i; i = alpm_list_next(i)) { + for(i = alpm_trans_get_remove(config->handle); i; i = alpm_list_next(i)) { pmpkg_t *pkg = alpm_list_getdata(i); if(alpm_list_find_str(config->holdpkg, alpm_pkg_get_name(pkg))) { pm_printf(PM_LOG_WARNING, _("%s is designated as a HoldPkg.\n"), @@ -143,7 +146,7 @@ int pacman_remove(alpm_list_t *targets) } /* Step 3: actually perform the removal */ - alpm_list_t *pkglist = alpm_trans_get_remove(); + alpm_list_t *pkglist = alpm_trans_get_remove(config->handle); if(pkglist == NULL) { printf(_(" there is nothing to do\n")); goto cleanup; /* we are done */ @@ -162,12 +165,14 @@ int pacman_remove(alpm_list_t *targets) goto cleanup; } - if(alpm_trans_commit(NULL) == -1) { + if(alpm_trans_commit(config->handle, &data) == -1) { pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), - alpm_strerrorlast()); + alpm_strerror(alpm_errno(config->handle))); retval = 1; } + FREELIST(data); + /* Step 4: release transaction resources */ cleanup: if(trans_release() == -1) { |