static int _add_mirror(alpm_db_t *db, char *value) { const char *dbname = alpm_db_get_name(db); /* let's attempt a replacement for the current repo */ char *temp = strreplace(value, "$repo", dbname); /* let's attempt a replacement for the arch */ const char *arch = config->arch; char *server; if(arch) { server = strreplace(temp, "$arch", arch); free(temp); } else { if(strstr(temp, "$arch")) { free(temp); pm_printf(ALPM_LOG_ERROR, _("mirror '%s' contains the '%s' variable, but no '%s' is defined.\n"), value, "$arch", "Architecture"); return 1; } server = temp; } if(alpm_db_add_server(db, server) != 0) { /* pm_errno is set by alpm_db_setserver */ pm_printf(ALPM_LOG_ERROR, _("could not add server URL to database '%s': %s (%s)\n"), dbname, server, alpm_strerror(alpm_errno(config->handle))); free(server); return 1; } free(server); return 0; }
/** * call-seq: * add_server( url ) * * Add a server to sync from to this database. * * === Parameters * [url] * The remote URL for this server. */ static VALUE add_server(VALUE self, VALUE url) { alpm_db_t* p_db = NULL; Data_Get_Struct(self, alpm_db_t, p_db); alpm_db_add_server(p_db, StringValuePtr(url)); return Qnil; }
/** Free the resources. * * @param ret the return value */ int ipacman_add_server(const char *name, const char *server) { alpm_db_t *db; db = alpm_register_syncdb(handle, name, ALPM_SIG_DATABASE_OPTIONAL); if(db == NULL) { printf("could not register '%s' database (%s)\n", name, alpm_strerror(alpm_errno(handle))); return 1; } if(alpm_db_add_server(db, server) != 0) { printf("could not add server URL to database '%s': %s (%s)\n", name, server, alpm_strerror(alpm_errno(handle))); return 1; } return 0; }