FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-08-2011, 12:18 PM
Dan McGee
 
Default Allow invalid sync DBs to be returned by the library

On Wed, Jun 8, 2011 at 6:38 AM, Allan McRae <allan@archlinux.org> 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.
"));
>> + * * * * * * * 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)
"),
>> + * * * * * * * * * * * * * * * * * * * * * * * 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...

-Dan
 
Old 06-09-2011, 07:07 PM
Dan McGee
 
Default Allow invalid sync DBs to be returned by the library

On Wed, Jun 8, 2011 at 7:18 AM, Dan McGee <dpmcgee@gmail.com> wrote:
> On Wed, Jun 8, 2011 at 6:38 AM, Allan McRae <allan@archlinux.org> 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.
"));
>>> + * * * * * * * 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)
"),
>>> + * * * * * * * * * * * * * * * * * * * * * * * 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)
 

Thread Tools




All times are GMT. The time now is 08:18 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org