summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/add.c23
-rw-r--r--src/pacman/remove.c30
-rw-r--r--src/pacman/sync.c23
3 files changed, 52 insertions, 24 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: */
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: */
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 88b7ed71..28c916ed 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -414,8 +414,11 @@ int pacman_sync(list_t *targets)
*/
if(alpm_trans_init(PM_TRANS_TYPE_SYNC, config->flags, cb_trans_evt, cb_trans_conv) == -1) {
ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
- retval = 1;
- goto cleanup;
+ 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);
}
if(config->op_s_upgrade) {
@@ -450,8 +453,11 @@ int pacman_sync(list_t *targets)
}
if(alpm_trans_init(PM_TRANS_TYPE_SYNC, config->flags, cb_trans_evt, cb_trans_conv) == -1) {
ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
- retval = 1;
- goto cleanup;
+ 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);
}
if(alpm_trans_addtarget("pacman") == -1) {
ERR(NL, "could not add target '%s': %s\n", (char *)i->data, alpm_strerror(pm_errno));
@@ -524,7 +530,7 @@ int pacman_sync(list_t *targets)
for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
PM_DEPMISS *miss = alpm_list_getdata(lp);
MSG(NL, ":: %s: %s %s", alpm_dep_getinfo(miss, PM_DEP_TARGET),
- alpm_dep_getinfo(miss, PM_DEP_TYPE) == PM_DEP_TYPE_DEPEND ? "requires" : "is required by",
+ (int)alpm_dep_getinfo(miss, PM_DEP_TYPE) == PM_DEP_TYPE_DEPEND ? "requires" : "is required by",
alpm_dep_getinfo(miss, PM_DEP_NAME));
switch((int)alpm_dep_getinfo(miss, PM_DEP_MOD)) {
case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_getinfo(miss, PM_DEP_VERSION)); break;
@@ -779,8 +785,13 @@ int pacman_sync(list_t *targets)
}
}
+ /* Step 4: release transaction resources
+ */
cleanup:
- alpm_trans_release();
+ if(alpm_trans_release() == -1) {
+ ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno));
+ }
+
return(retval);
}