diff options
-rw-r--r-- | lib/libalpm/alpm.h | 5 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 58 | ||||
-rw-r--r-- | src/pacman/callback.c | 9 |
3 files changed, 60 insertions, 12 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 202c3cd3..9fe80341 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -305,6 +305,10 @@ typedef enum _alpm_event_t { ALPM_EVENT_INTEGRITY_START, /** Target package's integrity was checked. */ ALPM_EVENT_INTEGRITY_DONE, + /** Target package will be loaded. */ + ALPM_EVENT_LOAD_START, + /** Target package is finished loading. */ + ALPM_EVENT_LOAD_DONE, /** Target deltas's integrity will be checked. */ ALPM_EVENT_DELTA_INTEGRITY_START, /** Target delta's integrity was checked. */ @@ -361,6 +365,7 @@ typedef enum _alpm_progress_t { ALPM_PROGRESS_CONFLICTS_START, ALPM_PROGRESS_DISKSPACE_START, ALPM_PROGRESS_INTEGRITY_START, + ALPM_PROGRESS_LOAD_START, } alpm_progress_t; /** Progress callback */ diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index a5281078..e1eff032 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -966,11 +966,6 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) alpm_db_t *sdb = alpm_pkg_get_db(spkg); level = alpm_db_get_siglevel(sdb); - /* load the package file and replace pkgcache entry with it in the target list */ - /* TODO: alpm_pkg_get_db() will not work on this target anymore */ - _alpm_log(handle, ALPM_LOG_DEBUG, - "replacing pkgcache entry with package file for target %s\n", - spkg->name); if(_alpm_pkg_validate_internal(handle, filepath, spkg, level) == -1) { prompt_to_delete(handle, filepath, handle->pm_errno); errors++; @@ -978,6 +973,50 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) FREE(filepath); continue; } + FREE(filepath); + } + + PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", 100, + numtargs, current); + EVENT(handle, ALPM_EVENT_INTEGRITY_DONE, NULL, NULL); + + if(errors) { + if(!handle->pm_errno) { + RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1); + } + return -1; + } + + if(trans->flags & ALPM_TRANS_FLAG_DOWNLOADONLY) { + return 0; + } + + /* load packages from disk now that they are known-valid */ + numtargs = alpm_list_count(trans->add); + EVENT(handle, ALPM_EVENT_LOAD_START, NULL, NULL); + + current = current_bytes = 0; + errors = 0; + + for(i = trans->add; i; i = i->next, current++) { + alpm_pkg_t *spkg = i->data; + char *filepath; + int percent = (int)(((double)current_bytes / total_bytes) * 100); + + PROGRESS(handle, ALPM_PROGRESS_LOAD_START, "", percent, + numtargs, current); + if(spkg->origin == PKG_FROM_FILE) { + continue; /* pkg_load() has been already called, this package is valid */ + } + + current_bytes += spkg->size; + filepath = _alpm_filecache_find(handle, spkg->filename); + + /* load the package file and replace pkgcache entry with it in the target list */ + /* TODO: alpm_pkg_get_db() will not work on this target anymore */ + _alpm_log(handle, ALPM_LOG_DEBUG, + "replacing pkgcache entry with package file for target %s\n", + spkg->name); alpm_pkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1); if(!pkgfile) { errors++; @@ -991,10 +1030,9 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) _alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */ } - PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", 100, + PROGRESS(handle, ALPM_PROGRESS_LOAD_START, "", 100, numtargs, current); - EVENT(handle, ALPM_EVENT_INTEGRITY_DONE, NULL, NULL); - + EVENT(handle, ALPM_EVENT_LOAD_DONE, NULL, NULL); if(errors) { if(!handle->pm_errno) { @@ -1003,10 +1041,6 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) return -1; } - if(trans->flags & ALPM_TRANS_FLAG_DOWNLOADONLY) { - return 0; - } - trans->state = STATE_COMMITING; replaces = alpm_list_count(trans->remove); diff --git a/src/pacman/callback.c b/src/pacman/callback.c index fffaf2ed..4fdd8f37 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -206,6 +206,11 @@ void cb_event(alpm_event_t event, void *data1, void *data2) printf(_("checking package integrity...\n")); } break; + case ALPM_EVENT_LOAD_START: + if(config->noprogressbar) { + printf(_("loading package files...\n")); + } + break; case ALPM_EVENT_DELTA_INTEGRITY_START: printf(_("checking delta integrity...\n")); break; @@ -238,6 +243,7 @@ void cb_event(alpm_event_t event, void *data1, void *data2) case ALPM_EVENT_RESOLVEDEPS_DONE: case ALPM_EVENT_INTERCONFLICTS_DONE: case ALPM_EVENT_INTEGRITY_DONE: + case ALPM_EVENT_LOAD_DONE: case ALPM_EVENT_DELTA_INTEGRITY_DONE: case ALPM_EVENT_DELTA_PATCHES_DONE: case ALPM_EVENT_DISKSPACE_DONE: @@ -408,6 +414,9 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent, case ALPM_PROGRESS_INTEGRITY_START: opr = _("checking package integrity"); break; + case ALPM_PROGRESS_LOAD_START: + opr = _("loading package files"); + break; default: return; } |