summaryrefslogtreecommitdiff
path: root/src/pacman/add.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/add.c')
-rw-r--r--src/pacman/add.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/pacman/add.c b/src/pacman/add.c
index 70ff1abd..2400b5d0 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -38,6 +38,7 @@ int pacman_add(list_t *targets)
{
PM_LIST *data;
list_t *i;
+ int retval = 0;
if(targets == NULL) {
return(0);
@@ -62,6 +63,10 @@ int pacman_add(list_t *targets)
if(alpm_trans_init((config->upgrade == 0) ? PM_TRANS_TYPE_ADD : PM_TRANS_TYPE_UPGRADE,
config->flags, cb_trans_evt, cb_trans_conv) == -1) {
ERR(NL, "%s\n", alpm_strerror(pm_errno));
+ 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);
+ }
return(1);
}
@@ -70,7 +75,8 @@ int pacman_add(list_t *targets)
for(i = targets; 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;
}
}
MSG(CL, "done.");
@@ -116,23 +122,26 @@ int pacman_add(list_t *targets)
default:
break;
}
- goto error;
+ retval = 1;
+ goto cleanup;
}
/* Step 3: actually perform the installation
*/
if(alpm_trans_commit(NULL) == -1) {
ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno));
- goto error;
+ retval = 1;
+ goto cleanup;
}
- return(0);
-
-error:
+ /* Step 4: release transaction resources
+ */
+cleanup:
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: */