/** * call-seq: * valid?() → true or false * * Checks if the database is in a valid state (mostly useful * for verifying signature status). If this returns false, * check out Alpm::errno for the reason. */ static VALUE valid(VALUE self) { alpm_db_t* p_db = NULL; Data_Get_Struct(self, alpm_db_t, p_db); return alpm_db_get_valid(p_db) == 0 ? Qtrue : Qfalse; }
/* * Return: 0 for success. */ int ipacman_sync_packages(alpm_list_t *targets) { int ret = 0; alpm_list_t *i; alpm_list_t *sync_dbs = alpm_get_syncdbs(handle); if(sync_dbs == NULL) { printf("no usable package repositories configured.\n"); return 1; } /* ensure all known dbs are valid */ for(i = sync_dbs; i; i = alpm_list_next(i)) { alpm_db_t *db = i->data; if(alpm_db_get_valid(db)) { printf("database '%s' is not valid (%s)\n", alpm_db_get_name(db), alpm_strerror(alpm_errno(handle))); ret = 1; } } if (ret) return ret; /* Step 1: create a new transaction... */ ret = alpm_trans_init(handle, ALPM_TRANS_FLAG_FORCE); if(ret == -1) { trans_init_error(handle); return 1; } /* process targets */ for(i = targets; i; i = alpm_list_next(i)) { const char *targ = i->data; if(process_target(targ, ret) == 1) { ret = 1; } } if(ret) { if(alpm_trans_release(handle) == -1) { printf("failed to release transaction (%s)\n", alpm_strerror(alpm_errno(handle))); } return ret; } return sync_prepare_execute(); }
int check_syncdbs(size_t need_repos, int check_valid) { int ret = 0; alpm_list_t *i; alpm_list_t *sync_dbs = alpm_get_syncdbs(config->handle); if(need_repos && sync_dbs == NULL) { pm_printf(ALPM_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)) { alpm_db_t *db = i->data; if(alpm_db_get_valid(db)) { pm_printf(ALPM_LOG_ERROR, _("database '%s' is not valid (%s)\n"), alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle))); ret = 1; } } } return ret; }