1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 00:08:50 -05:00

Add a progressbar for package integrity checking

This can take a while too, and it is really easy to add the necessary
callback stuff for adding a progressbar.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-01-11 21:12:08 -06:00
parent 9a82cb92a4
commit fe6e90c21f
3 changed files with 18 additions and 4 deletions

View File

@ -395,6 +395,7 @@ typedef enum _pmtransprog_t {
PM_TRANS_PROGRESS_REMOVE_START, PM_TRANS_PROGRESS_REMOVE_START,
PM_TRANS_PROGRESS_CONFLICTS_START, PM_TRANS_PROGRESS_CONFLICTS_START,
PM_TRANS_PROGRESS_DISKSPACE_START, PM_TRANS_PROGRESS_DISKSPACE_START,
PM_TRANS_PROGRESS_INTEGRITY_START,
} pmtransprog_t; } pmtransprog_t;
/* Transaction Event callback */ /* Transaction Event callback */

View File

@ -822,7 +822,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
{ {
alpm_list_t *i, *j, *files = NULL; alpm_list_t *i, *j, *files = NULL;
alpm_list_t *deltas = NULL; alpm_list_t *deltas = NULL;
size_t replaces = 0; size_t numtargs, current = 0, replaces = 0;
int errors = 0; int errors = 0;
const char *cachedir = NULL; const char *cachedir = NULL;
int ret = -1; int ret = -1;
@ -949,14 +949,18 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
} }
/* Check integrity of packages */ /* Check integrity of packages */
numtargs = alpm_list_count(trans->add);
EVENT(trans, PM_TRANS_EVT_INTEGRITY_START, NULL, NULL); EVENT(trans, PM_TRANS_EVT_INTEGRITY_START, NULL, NULL);
errors = 0; errors = 0;
for(i = trans->add; i; i = i->next) { for(i = trans->add; i; i = i->next) {
pmpkg_t *spkg = i->data; pmpkg_t *spkg = i->data;
int percent = (current * 100) / numtargs;
if(spkg->origin == PKG_FROM_FILE) { if(spkg->origin == PKG_FROM_FILE) {
continue; /* pkg_load() has been already called, this package is valid */ continue; /* pkg_load() has been already called, this package is valid */
} }
PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", percent,
numtargs, current);
const char *filename = alpm_pkg_get_filename(spkg); const char *filename = alpm_pkg_get_filename(spkg);
const char *md5sum = alpm_pkg_get_md5sum(spkg); const char *md5sum = alpm_pkg_get_md5sum(spkg);
@ -982,12 +986,16 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
pkgfile->reason = spkg->reason; /* copy over install reason */ pkgfile->reason = spkg->reason; /* copy over install reason */
i->data = pkgfile; i->data = pkgfile;
_alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */ _alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */
current++;
} }
PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", 100,
numtargs, current);
EVENT(trans, PM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL);
if(errors) { if(errors) {
pm_errno = PM_ERR_PKG_INVALID; pm_errno = PM_ERR_PKG_INVALID;
goto error; goto error;
} }
EVENT(trans, PM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL);
if(trans->flags & PM_TRANS_FLAG_DOWNLOADONLY) { if(trans->flags & PM_TRANS_FLAG_DOWNLOADONLY) {
ret = 0; ret = 0;
goto error; goto error;

View File

@ -204,7 +204,9 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
display_new_optdepends(data2,data1); display_new_optdepends(data2,data1);
break; break;
case PM_TRANS_EVT_INTEGRITY_START: case PM_TRANS_EVT_INTEGRITY_START:
if(config->noprogressbar) {
printf(_("checking package integrity...\n")); printf(_("checking package integrity...\n"));
}
break; break;
case PM_TRANS_EVT_DELTA_INTEGRITY_START: case PM_TRANS_EVT_DELTA_INTEGRITY_START:
printf(_("checking delta integrity...\n")); printf(_("checking delta integrity...\n"));
@ -374,6 +376,9 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
case PM_TRANS_PROGRESS_DISKSPACE_START: case PM_TRANS_PROGRESS_DISKSPACE_START:
opr = _("checking available disk space"); opr = _("checking available disk space");
break; break;
case PM_TRANS_PROGRESS_INTEGRITY_START:
opr = _("checking package integrity");
break;
default: default:
return; return;
} }