On Wed, Jun 8, 2011 at 7:18 AM, Dan McGee <[email protected]> wrote: > On Wed, Jun 8, 2011 at 6:38 AM, Allan McRae <[email protected]> wrote: >> On 08/06/11 17:51, Dan McGee wrote: >>> @@ -100,6 +103,28 @@ int needs_root(void) >>> } >>> } >>> >>> +int check_syncdbs(int min_count, int check_valid) >>> +{ >>> + alpm_list_t *i, *sync_dbs; >>> + sync_dbs = alpm_option_get_syncdbs(config->handle); >>> + if(sync_dbs == NULL || alpm_list_count(sync_dbs)< min_count) { >>> + pm_printf(PM_LOG_ERROR, _("no usable package repositories >>> configured.\n")); >>> + return 1; >>> + } >>> + if(check_valid) { >>> + /* ensure all known dbs are valid */ >>> + for(i = sync_dbs; i; i = alpm_list_next(i)) { >>> + pmdb_t *db = i->data; >>> + if(alpm_db_valid(db)) { >>> + pm_printf(PM_LOG_ERROR, _("database '%s' >>> is not valid (%s)\n"), >>> + alpm_db_get_name(db), >>> alpm_strerror(alpm_errno(config->handle))); >>> + return 1; >> >> Instead of returning immediately here, would it be good to finish checking >> all databases for validity? > > I thought about that too when doing it and I was on the fence- I think > that is a good idea, as then you would know in one shot what all is > wrong. Just set error = 1 if we ever are invalid in the loop and then > return that value...
Updated to fix this; example output: dmcgee@galway ~/projects/pacman (working) $ ./src/pacman/pacman -Ss masdfasd error: database 'core' is not valid (invalid PGP signature) error: database 'extra' is not valid (invalid PGP signature) error: database 'community-testing' is not valid (invalid PGP signature) error: database 'multilib' is not valid (invalid PGP signature) error: database 'community' is not valid (invalid PGP signature)
