static gboolean disabled_repos_configure (GHashTable *table, gboolean only_trusted, GError **error) { const alpm_list_t *i; g_return_val_if_fail (table != NULL, FALSE); g_return_val_if_fail (alpm != NULL, FALSE); if (alpm_unregister_all_syncdbs (alpm) < 0) { alpm_errno_t errno = alpm_errno (alpm); g_set_error_literal (error, ALPM_ERROR, errno, alpm_strerror (errno)); return FALSE; } for (i = configured; i != NULL; i = i->next) { PkBackendRepo *repo = (PkBackendRepo *) i->data; alpm_siglevel_t level = repo->level; alpm_db_t *db; if (g_hash_table_lookup (table, repo->name) != NULL) { /* repo is disabled */ continue; } else if (!only_trusted) { level &= ~ALPM_SIG_PACKAGE; level &= ~ALPM_SIG_DATABASE; level &= ~ALPM_SIG_USE_DEFAULT; } db = alpm_register_syncdb (alpm, repo->name, level); if (db == NULL) { alpm_errno_t errno = alpm_errno (alpm); g_set_error (error, ALPM_ERROR, errno, "[%s]: %s", repo->name, alpm_strerror (errno)); return FALSE; } alpm_db_set_servers (db, alpm_list_strdup (repo->servers)); } return TRUE; }
/** * call-seq: * servers=( ary ) * * Replace the list of servers for this database with the * given one. * * === Parameters * [servers] * An array of URLs. */ static VALUE set_servers(VALUE self, VALUE ary) { alpm_db_t* p_db = NULL; alpm_list_t* servers = NULL; int i; Data_Get_Struct(self, alpm_db_t, p_db); if (!RTEST(ary = rb_check_array_type(ary))) { /* Single = intended */ rb_raise(rb_eTypeError, "Argument is no array (#to_ary)"); return Qnil; } for(i=0; i < RARRAY_LEN(ary); i++) { VALUE url = rb_ary_entry(ary, i); servers = alpm_list_add(servers, StringValuePtr(url)); } alpm_db_set_servers(p_db, servers); alpm_list_free(servers); return ary; }
static gboolean pk_alpm_disabled_repos_configure (PkBackend *backend, gboolean only_trusted, GError **error) { PkBackendAlpmPrivate *priv = pk_backend_get_user_data (backend); const alpm_list_t *i; if (alpm_unregister_all_syncdbs (priv->alpm) < 0) { alpm_errno_t errno = alpm_errno (priv->alpm); g_set_error_literal (error, PK_ALPM_ERROR, errno, alpm_strerror (errno)); return FALSE; } for (i = priv->configured_repos; i != NULL; i = i->next) { PkBackendRepo *repo = (PkBackendRepo *) i->data; alpm_siglevel_t level = repo->level; alpm_db_t *db; if (!only_trusted) { level &= ~ALPM_SIG_PACKAGE; level &= ~ALPM_SIG_DATABASE; level &= ~ALPM_SIG_USE_DEFAULT; } db = alpm_register_syncdb (priv->alpm, repo->name, level); if (db == NULL) { alpm_errno_t errno = alpm_errno (priv->alpm); g_set_error (error, PK_ALPM_ERROR, errno, "[%s]: %s", repo->name, alpm_strerror (errno)); return FALSE; } alpm_db_set_servers (db, alpm_list_strdup (repo->servers)); } return TRUE; }