summaryrefslogtreecommitdiffstats
path: root/src/pacman/remove.c
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-01-26 21:46:48 +0100
committerAurelien Foret <aurelien@archlinux.org>2006-01-26 21:46:48 +0100
commitfb2331ab8b62cb4737c5e31c4bee766c270b92f7 (patch)
treeb7102c35bbfa9a1de195a688dd3d36de9dd878d7 /src/pacman/remove.c
parent7818e6f74509fc56f75e8cdd22a4cc037668067f (diff)
downloadpacman-fb2331ab8b62cb4737c5e31c4bee766c270b92f7.tar.gz
pacman-fb2331ab8b62cb4737c5e31c4bee766c270b92f7.tar.xz
- fixed a compilation warning
- added missing alpm_trans_release() calls upon transation completion - put back error messages from pacman 2.x in case of PM_ERR_HANDLE_LOCK error
Diffstat (limited to 'src/pacman/remove.c')
-rw-r--r--src/pacman/remove.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 495a7253..ef0810b6 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -41,6 +41,7 @@ int pacman_remove(list_t *targets)
PM_LIST *data;
list_t *i;
list_t *finaltargs = NULL;
+ int retval = 0;
if(targets == NULL) {
return(0);
@@ -77,13 +78,19 @@ int pacman_remove(list_t *targets)
*/
if(alpm_trans_init(PM_TRANS_TYPE_REMOVE, config->flags, cb_trans_evt, cb_trans_conv) == -1) {
ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
- goto error;
+ if(pm_errno == PM_ERR_HANDLE_LOCK) {
+ MSG(NL, " if you're sure a package manager is not already running,\n"
+ " you can remove %s\n", PM_LOCK);
+ }
+ FREELIST(finaltargs);
+ return(1);
}
/* and add targets to it */
for(i = finaltargs; i; i = i->next) {
if(alpm_trans_addtarget(i->data) == -1) {
ERR(NL, "failed to add target '%s' (%s)\n", (char *)i->data, alpm_strerror(pm_errno));
- goto error;
+ retval = 1;
+ goto cleanup;
}
}
@@ -104,7 +111,8 @@ int pacman_remove(list_t *targets)
default:
break;
}
- goto error;
+ retval = 1;
+ goto cleanup;
}
/* Warn user in case of dangerous operation
@@ -121,7 +129,8 @@ int pacman_remove(list_t *targets)
FREELIST(i);
/* get confirmation */
if(yesno("\nDo you want to remove these packages? [Y/n] ") == 0) {
- goto error;
+ retval = 1;
+ goto cleanup;
}
MSG(NL, "\n");
}
@@ -130,21 +139,20 @@ int pacman_remove(list_t *targets)
*/
if(alpm_trans_commit(NULL) == -1) {
ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno));
- goto error;
+ retval = 1;
+ goto cleanup;
}
- /* Step 4: cleanup */
+ /* Step 4: release transaction resources
+ */
+cleanup:
FREELIST(finaltargs);
- return(0);
-
-error:
- FREELIST(finaltargs);
if(alpm_trans_release() == -1) {
ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno));
}
- return(1);
+ return(retval);
}
/* vim: set ts=2 sw=2 noet: */