Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c10
-rw-r--r--lib/libalpm/alpm.c8
-rw-r--r--lib/libalpm/remove.c6
-rw-r--r--lib/libalpm/trans.c2
-rw-r--r--lib/libalpm/trans.h4
5 files changed, 26 insertions, 4 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 7b96cf08..62ea3e00 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -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);
}
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index cffbfc46..96d8536e 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -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 */
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index f675eda1..4df9c7ba 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -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);
}
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 449d3355..ee546480 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -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:
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index 56b2e625..b60301c5 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -25,7 +25,9 @@ enum {
STATE_IDLE = 0,
STATE_INITIALIZED,
STATE_PREPARED,
- STATE_COMMITTED
+ STATE_COMMITTING,
+ STATE_COMMITTED,
+ STATE_INTERRUPTED
};
#include "alpm.h"