diff options
Diffstat (limited to 'src/pacman/remove.c')
-rw-r--r-- | src/pacman/remove.c | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/src/pacman/remove.c b/src/pacman/remove.c index e3750e4c..4fe9bc81 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -29,24 +29,10 @@ /* pacman */ #include "pacman.h" #include "util.h" -#include "callback.h" #include "conf.h" extern pmdb_t *db_local; -/* Free the current transaction and print an error if unsuccessful */ -static int remove_cleanup(void) -{ - int ret = alpm_trans_release(); - if(ret != 0) { - pm_printf(PM_LOG_ERROR, _("failed to release transaction (%s)\n"), - alpm_strerrorlast()); - ret = 1; - } - - return(ret); -} - /** * @brief Remove a specified list of packages. * @@ -75,11 +61,11 @@ int pacman_remove(alpm_list_t *targets) printf(_(":: group %s:\n"), alpm_grp_get_name(grp)); list_display(" ", pkgnames); - all = yesno(_(" Remove whole content? [Y/n] ")); + all = yesno(1, _(" Remove whole content?")); for(p = pkgnames; p; p = alpm_list_next(p)) { char *pkg = alpm_list_getdata(p); - if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), pkg, (char *)alpm_list_getdata(i))) { + if(all || yesno(1, _(":: Remove %s from group %s?"), pkg, (char *)alpm_list_getdata(i))) { finaltargs = alpm_list_add(finaltargs, strdup(pkg)); } } @@ -90,14 +76,7 @@ int pacman_remove(alpm_list_t *targets) } /* Step 1: create a new transaction */ - if(alpm_trans_init(PM_TRANS_TYPE_REMOVE, config->flags, - cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) { - fprintf(stderr, _("error: failed to init transaction (%s)\n"), - alpm_strerrorlast()); - if(pm_errno == PM_ERR_HANDLE_LOCK) { - printf(_(" if you're sure a package manager is not already\n" - " running, you can remove %s.\n"), alpm_option_get_lockfile()); - } + if(trans_init(PM_TRANS_TYPE_REMOVE, config->flags) == -1) { FREELIST(finaltargs); return(1); } @@ -107,9 +86,9 @@ int pacman_remove(alpm_list_t *targets) for(i = finaltargs; i; i = alpm_list_next(i)) { char *targ = alpm_list_getdata(i); if(alpm_trans_addtarget(targ) == -1) { - fprintf(stderr, _("error: '%s': %s\n"), + pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ, alpm_strerrorlast()); - remove_cleanup(); + trans_release(); FREELIST(finaltargs); return(1); } @@ -117,7 +96,7 @@ 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) { - fprintf(stderr, _("error: failed to prepare transaction (%s)\n"), + pm_fprintf(stderr, PM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), alpm_strerrorlast()); switch(pm_errno) { case PM_ERR_UNSATISFIED_DEPS: @@ -134,7 +113,7 @@ int pacman_remove(alpm_list_t *targets) default: break; } - remove_cleanup(); + trans_release(); FREELIST(finaltargs); return(1); } @@ -153,8 +132,8 @@ int pacman_remove(alpm_list_t *targets) list_display(_("Targets:"), lst); FREELIST(lst); /* get confirmation */ - if(yesno(_("\nDo you want to remove these packages? [Y/n] ")) == 0) { - remove_cleanup(); + if(yesno(1, _("\nDo you want to remove these packages?")) == 0) { + trans_release(); FREELIST(finaltargs); return(1); } @@ -163,15 +142,17 @@ int pacman_remove(alpm_list_t *targets) /* Step 3: actually perform the removal */ if(alpm_trans_commit(NULL) == -1) { - fprintf(stderr, _("error: failed to commit transaction (%s)\n"), + pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), alpm_strerrorlast()); - remove_cleanup(); + trans_release(); FREELIST(finaltargs); return(1); } /* Step 4: release transaction resources */ - retval = remove_cleanup(); + if(trans_release() == -1) { + retval = 1; + } FREELIST(finaltargs); return(retval); } |