diff options
author | Aurelien Foret <aurelien@archlinux.org> | 2006-01-26 21:46:48 +0100 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2006-01-26 21:46:48 +0100 |
commit | fb2331ab8b62cb4737c5e31c4bee766c270b92f7 (patch) | |
tree | b7102c35bbfa9a1de195a688dd3d36de9dd878d7 /src/pacman/add.c | |
parent | 7818e6f74509fc56f75e8cdd22a4cc037668067f (diff) | |
download | pacman-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/add.c')
-rw-r--r-- | src/pacman/add.c | 23 |
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: */ |