From 82065c5e149e9f7e3b59ca3425142efdbc2800c7 Mon Sep 17 00:00:00 2001 From: Nagy Gabor Date: Fri, 22 May 2009 15:30:38 +0200 Subject: [PATCH] Ldconfig rework It was hard to follow when we run ldconfig. Sometimes it was run twice (-S conflict resolving), sometimes it was not run at all (if the end of _alpm_*_commit() was not reached). I moved _alpm_ldconfig() call to alpm_trans_commit(), so now it is run exactly once per transaction (commit). This means that ldconfig is run even if the user press ctrl-c or an error occurs. We have one stupid exception, the only "fake" transaction, -Sw, which is handled in a different way (then ldconfig is not run). I added PM_TRANS_EVT_LDCONFIG_{START,DONE} events to indicate this important process and the front-end now prints "running ldconfig...". Signed-off-by: Nagy Gabor --- lib/libalpm/add.c | 4 ---- lib/libalpm/alpm.h | 4 ++++ lib/libalpm/remove.c | 6 ------ lib/libalpm/trans.c | 22 ++++++++++++++++------ lib/libalpm/util.c | 1 + src/pacman/callback.c | 4 ++++ 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 3c0074f..8388c0e 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -886,10 +886,6 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) pkg_current++; } - /* run ldconfig if it exists */ - _alpm_log(PM_LOG_DEBUG, "running \"ldconfig -r %s\"\n", handle->root); - _alpm_ldconfig(handle->root); - return(0); } diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 94c3b67..fd67783 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -363,6 +363,10 @@ typedef enum _pmtransevt_t { * The repository's tree name is passed to the callback. */ PM_TRANS_EVT_RETRIEVE_START, + /** Ldconfig will be run. */ + PM_TRANS_EVT_LDCONFIG_START, + /** Ldconfig was run. */ + PM_TRANS_EVT_LDCONFIG_DONE } pmtransevt_t; /*@}*/ diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 9dfff9c..0b5bd31 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -393,12 +393,6 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) } } - /* run ldconfig if it exists */ - if(trans->type != PM_TRANS_TYPE_REMOVEUPGRADE) { - _alpm_log(PM_LOG_DEBUG, "running \"ldconfig -r %s\"\n", handle->root); - _alpm_ldconfig(handle->root); - } - return(0); } diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 6317b69..a3e2500 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -152,17 +152,27 @@ int SYMEXPORT alpm_trans_prepare(alpm_list_t **data) */ int SYMEXPORT alpm_trans_commit(alpm_list_t **data) { + int retval; + pmtrans_t *trans; + ALPM_LOG_FUNC; /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - ASSERT(handle->trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); - ASSERT(handle->trans->state == STATE_PREPARED, RET_ERR(PM_ERR_TRANS_NOT_PREPARED, -1)); - - ASSERT(!(handle->trans->flags & PM_TRANS_FLAG_NOLOCK), RET_ERR(PM_ERR_TRANS_NOT_LOCKED, -1)); - - return(_alpm_trans_commit(handle->trans, data)); + trans = handle->trans; + ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); + ASSERT(trans->state == STATE_PREPARED, RET_ERR(PM_ERR_TRANS_NOT_PREPARED, -1)); + ASSERT(!(trans->flags & PM_TRANS_FLAG_NOLOCK), RET_ERR(PM_ERR_TRANS_NOT_LOCKED, -1)); + + retval = _alpm_trans_commit(trans, data); + /* run ldconfig, exception: -Sw */ + if(!(trans->type == PM_TRANS_TYPE_SYNC && trans->flags & PM_TRANS_FLAG_DOWNLOADONLY)) { + EVENT(trans, PM_TRANS_EVT_LDCONFIG_START, NULL, NULL); + _alpm_ldconfig(handle->root); + EVENT(trans, PM_TRANS_EVT_LDCONFIG_DONE, NULL, NULL); + } + return(retval); } /** Interrupt a transaction. diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 75f6042..88229fb 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -458,6 +458,7 @@ int _alpm_ldconfig(const char *root) { char line[PATH_MAX]; + _alpm_log(PM_LOG_DEBUG, "running \"ldconfig -r %s\"\n", root); snprintf(line, PATH_MAX, "%setc/ld.so.conf", root); if(access(line, F_OK) == 0) { snprintf(line, PATH_MAX, "%ssbin/ldconfig", root); diff --git a/src/pacman/callback.c b/src/pacman/callback.c index e1cad20..a675487 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -227,6 +227,9 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) case PM_TRANS_EVT_RETRIEVE_START: printf(_(":: Retrieving packages from %s...\n"), (char*)data1); break; + case PM_TRANS_EVT_LDCONFIG_START: + printf(_("running ldconfig...\n")); + break; /* all the simple done events, with fallthrough for each */ case PM_TRANS_EVT_FILECONFLICTS_DONE: case PM_TRANS_EVT_CHECKDEPS_DONE: @@ -235,6 +238,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2) case PM_TRANS_EVT_INTEGRITY_DONE: case PM_TRANS_EVT_DELTA_INTEGRITY_DONE: case PM_TRANS_EVT_DELTA_PATCHES_DONE: + case PM_TRANS_EVT_LDCONFIG_DONE: /* nothing */ break; } -- 1.6.3.1