mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 20:05:07 -05:00
- 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
This commit is contained in:
parent
7818e6f745
commit
fb2331ab8b
@ -38,6 +38,7 @@ int pacman_add(list_t *targets)
|
|||||||
{
|
{
|
||||||
PM_LIST *data;
|
PM_LIST *data;
|
||||||
list_t *i;
|
list_t *i;
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
if(targets == NULL) {
|
if(targets == NULL) {
|
||||||
return(0);
|
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,
|
if(alpm_trans_init((config->upgrade == 0) ? PM_TRANS_TYPE_ADD : PM_TRANS_TYPE_UPGRADE,
|
||||||
config->flags, cb_trans_evt, cb_trans_conv) == -1) {
|
config->flags, cb_trans_evt, cb_trans_conv) == -1) {
|
||||||
ERR(NL, "%s\n", alpm_strerror(pm_errno));
|
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);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +75,8 @@ int pacman_add(list_t *targets)
|
|||||||
for(i = targets; i; i = i->next) {
|
for(i = targets; i; i = i->next) {
|
||||||
if(alpm_trans_addtarget(i->data) == -1) {
|
if(alpm_trans_addtarget(i->data) == -1) {
|
||||||
ERR(NL, "failed to add target '%s' (%s)\n", (char *)i->data, alpm_strerror(pm_errno));
|
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.");
|
MSG(CL, "done.");
|
||||||
@ -116,23 +122,26 @@ int pacman_add(list_t *targets)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
goto error;
|
retval = 1;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Step 3: actually perform the installation
|
/* Step 3: actually perform the installation
|
||||||
*/
|
*/
|
||||||
if(alpm_trans_commit(NULL) == -1) {
|
if(alpm_trans_commit(NULL) == -1) {
|
||||||
ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno));
|
ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno));
|
||||||
goto error;
|
retval = 1;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
/* Step 4: release transaction resources
|
||||||
|
*/
|
||||||
error:
|
cleanup:
|
||||||
if(alpm_trans_release() == -1) {
|
if(alpm_trans_release() == -1) {
|
||||||
ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno));
|
ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno));
|
||||||
}
|
}
|
||||||
return(1);
|
|
||||||
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
@ -41,6 +41,7 @@ int pacman_remove(list_t *targets)
|
|||||||
PM_LIST *data;
|
PM_LIST *data;
|
||||||
list_t *i;
|
list_t *i;
|
||||||
list_t *finaltargs = NULL;
|
list_t *finaltargs = NULL;
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
if(targets == NULL) {
|
if(targets == NULL) {
|
||||||
return(0);
|
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) {
|
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));
|
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 */
|
/* and add targets to it */
|
||||||
for(i = finaltargs; i; i = i->next) {
|
for(i = finaltargs; i; i = i->next) {
|
||||||
if(alpm_trans_addtarget(i->data) == -1) {
|
if(alpm_trans_addtarget(i->data) == -1) {
|
||||||
ERR(NL, "failed to add target '%s' (%s)\n", (char *)i->data, alpm_strerror(pm_errno));
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
goto error;
|
retval = 1;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Warn user in case of dangerous operation
|
/* Warn user in case of dangerous operation
|
||||||
@ -121,7 +129,8 @@ int pacman_remove(list_t *targets)
|
|||||||
FREELIST(i);
|
FREELIST(i);
|
||||||
/* get confirmation */
|
/* get confirmation */
|
||||||
if(yesno("\nDo you want to remove these packages? [Y/n] ") == 0) {
|
if(yesno("\nDo you want to remove these packages? [Y/n] ") == 0) {
|
||||||
goto error;
|
retval = 1;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
MSG(NL, "\n");
|
MSG(NL, "\n");
|
||||||
}
|
}
|
||||||
@ -130,21 +139,20 @@ int pacman_remove(list_t *targets)
|
|||||||
*/
|
*/
|
||||||
if(alpm_trans_commit(NULL) == -1) {
|
if(alpm_trans_commit(NULL) == -1) {
|
||||||
ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno));
|
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);
|
FREELIST(finaltargs);
|
||||||
|
|
||||||
return(0);
|
|
||||||
|
|
||||||
error:
|
|
||||||
FREELIST(finaltargs);
|
|
||||||
if(alpm_trans_release() == -1) {
|
if(alpm_trans_release() == -1) {
|
||||||
ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno));
|
ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return(1);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
@ -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) {
|
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));
|
ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
|
||||||
retval = 1;
|
if(pm_errno == PM_ERR_HANDLE_LOCK) {
|
||||||
goto cleanup;
|
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) {
|
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) {
|
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));
|
ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
|
||||||
retval = 1;
|
if(pm_errno == PM_ERR_HANDLE_LOCK) {
|
||||||
goto cleanup;
|
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) {
|
if(alpm_trans_addtarget("pacman") == -1) {
|
||||||
ERR(NL, "could not add target '%s': %s\n", (char *)i->data, alpm_strerror(pm_errno));
|
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)) {
|
for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
|
||||||
PM_DEPMISS *miss = alpm_list_getdata(lp);
|
PM_DEPMISS *miss = alpm_list_getdata(lp);
|
||||||
MSG(NL, ":: %s: %s %s", alpm_dep_getinfo(miss, PM_DEP_TARGET),
|
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));
|
alpm_dep_getinfo(miss, PM_DEP_NAME));
|
||||||
switch((int)alpm_dep_getinfo(miss, PM_DEP_MOD)) {
|
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;
|
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:
|
cleanup:
|
||||||
alpm_trans_release();
|
if(alpm_trans_release() == -1) {
|
||||||
|
ERR(NL, "failed to release transaction (%s)\n", alpm_strerror(pm_errno));
|
||||||
|
}
|
||||||
|
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user