mirror of
https://github.com/moparisthebest/pacman
synced 2025-02-28 17:31:52 -05:00
Patch from FW: Better control over CTRL-C interruptions -- do not leave the DB in an inconsistent state
This commit is contained in:
parent
318e233cb3
commit
54008798ef
@ -300,6 +300,10 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
||||
pmpkg_t *oldpkg = NULL;
|
||||
errors = 0;
|
||||
|
||||
if(handle->trans->state == STATE_INTERRUPTED) {
|
||||
break;
|
||||
}
|
||||
|
||||
pmo_upgrade = (trans->type == PM_TRANS_TYPE_UPGRADE) ? 1 : 0;
|
||||
|
||||
/* see if this is an upgrade. if so, remove the old package first */
|
||||
@ -689,8 +693,10 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
||||
}
|
||||
|
||||
/* run ldconfig if it exists */
|
||||
_alpm_log(PM_LOG_FLOW1, _("running \"ldconfig -r %s\""), handle->root);
|
||||
_alpm_ldconfig(handle->root);
|
||||
if(handle->trans->state != STATE_INTERRUPTED) {
|
||||
_alpm_log(PM_LOG_FLOW1, _("running \"ldconfig -r %s\""), handle->root);
|
||||
_alpm_ldconfig(handle->root);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
@ -799,6 +799,14 @@ int alpm_trans_release()
|
||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||
ASSERT(trans->state != STATE_IDLE, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||
|
||||
/* during a commit do not interrupt immediately, just after a target */
|
||||
if(trans->state == STATE_COMMITTING || trans->state == STATE_INTERRUPTED) {
|
||||
if(trans->state == STATE_COMMITTING) {
|
||||
trans->state = STATE_INTERRUPTED;
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
FREETRANS(handle->trans);
|
||||
|
||||
/* unlock db */
|
||||
|
@ -149,6 +149,10 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
|
||||
char pm_install[PATH_MAX];
|
||||
info = (pmpkg_t*)targ->data;
|
||||
|
||||
if(handle->trans->state == STATE_INTERRUPTED) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(trans->type != PM_TRANS_TYPE_UPGRADE) {
|
||||
EVENT(trans, PM_TRANS_EVT_REMOVE_START, info, NULL);
|
||||
_alpm_log(PM_LOG_FLOW1, _("removing package %s-%s"), info->name, info->version);
|
||||
@ -303,7 +307,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
|
||||
}
|
||||
|
||||
/* run ldconfig if it exists */
|
||||
if(trans->type != PM_TRANS_TYPE_UPGRADE) {
|
||||
if((trans->type != PM_TRANS_TYPE_UPGRADE) && (handle->trans->state != STATE_INTERRUPTED)) {
|
||||
_alpm_log(PM_LOG_FLOW1, _("running \"ldconfig -r %s\""), handle->root);
|
||||
_alpm_ldconfig(handle->root);
|
||||
}
|
||||
|
@ -191,6 +191,8 @@ int _alpm_trans_commit(pmtrans_t *trans, PMList **data)
|
||||
return(0);
|
||||
}
|
||||
|
||||
trans->state = STATE_COMMITTING;
|
||||
|
||||
switch(trans->type) {
|
||||
case PM_TRANS_TYPE_ADD:
|
||||
case PM_TRANS_TYPE_UPGRADE:
|
||||
|
@ -25,7 +25,9 @@ enum {
|
||||
STATE_IDLE = 0,
|
||||
STATE_INITIALIZED,
|
||||
STATE_PREPARED,
|
||||
STATE_COMMITTED
|
||||
STATE_COMMITTING,
|
||||
STATE_COMMITTED,
|
||||
STATE_INTERRUPTED
|
||||
};
|
||||
|
||||
#include "alpm.h"
|
||||
|
@ -338,6 +338,9 @@ static void cleanup(int signum)
|
||||
{
|
||||
list_t *lp;
|
||||
|
||||
if((signum == SIGINT) && (alpm_trans_release() == -1)) {
|
||||
return;
|
||||
}
|
||||
if(signum != 0 && config->op_d_vertest == 0) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user