static HyRepo config_repo(const char *name, const char *md_repo, const char *md_primary_xml, const char *md_filelists) { HyRepo repo = hy_repo_create(name); hy_repo_set_string(repo, HY_REPO_MD_FN, md_repo); hy_repo_set_string(repo, HY_REPO_PRIMARY_FN, md_primary_xml); hy_repo_set_string(repo, HY_REPO_FILELISTS_FN, md_filelists); return repo; }
static int repo_init(_RepoObject *self, PyObject *args, PyObject *kwds) { const char *name; if (!PyArg_ParseTuple(args, "s", &name)) return -1; hy_repo_set_string(self->repo, HY_REPO_NAME, name); return 0; }
HyRepo hy_repo_create(const char *name) { assert(name); HyRepo repo = solv_calloc(1, sizeof(*repo)); repo->nrefs = 1; hy_repo_set_string(repo, HY_REPO_NAME, name); return repo; }
static int set_str(_RepoObject *self, PyObject *value, void *closure) { intptr_t str_key = (intptr_t)closure; PycompString str_value(value); if (!str_value.getCString()) return -1; hy_repo_set_string(self->repo, str_key, str_value.getCString()); return 0; }
HyRepo glob_for_repofiles(Pool *pool, const char *repo_name, const char *path) { HyRepo repo = hy_repo_create(repo_name); const char *tmpl; wordexp_t word_vector; tmpl = pool_tmpjoin(pool, path, "/repomd.xml", NULL); if (wordexp(tmpl, &word_vector, 0) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_MD_FN, word_vector.we_wordv[0]); tmpl = pool_tmpjoin(pool, path, "/*primary.xml.gz", NULL); if (wordexp(tmpl, &word_vector, WRDE_REUSE) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_PRIMARY_FN, word_vector.we_wordv[0]); tmpl = pool_tmpjoin(pool, path, "/*filelists.xml.gz", NULL); if (wordexp(tmpl, &word_vector, WRDE_REUSE) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_FILELISTS_FN, word_vector.we_wordv[0]); tmpl = pool_tmpjoin(pool, path, "/*prestodelta.xml.gz", NULL); if (wordexp(tmpl, &word_vector, WRDE_REUSE) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_PRESTO_FN, word_vector.we_wordv[0]); tmpl = pool_tmpjoin(pool, path, "/*updateinfo.xml.gz", NULL); if (wordexp(tmpl, &word_vector, WRDE_REUSE) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_UPDATEINFO_FN, word_vector.we_wordv[0]); wordfree(&word_vector); return repo; fail: wordfree(&word_vector); hy_repo_free(repo); return NULL; }
END_TEST START_TEST(test_load_repo_err) { HySack sack = hy_sack_create(test_globals.tmpdir, NULL, NULL, NULL, HY_MAKE_CACHE_DIR); HyRepo repo = hy_repo_create("crabalocker"); hy_repo_set_string(repo, HY_REPO_MD_FN, "/non/existing"); fail_unless(hy_sack_load_repo(sack, repo, 0) == HY_E_FAILED); fail_unless(hy_get_errno() == HY_E_IO); hy_repo_free(repo); hy_sack_free(sack); }
uint32_t TDNFInitRepoFromMetaData( HyRepo hRepo, LrYumRepo* pRepo ) { uint32_t dwError = 0; const char* pszValue = NULL; if(!pRepo) { dwError = ERROR_TDNF_INVALID_PARAMETER; BAIL_ON_TDNF_ERROR(dwError); } hy_repo_set_string(hRepo, HY_REPO_MD_FN, pRepo->repomd); pszValue = lr_yum_repo_path(pRepo, "primary"); if(pszValue) { hy_repo_set_string(hRepo, HY_REPO_PRIMARY_FN, pszValue); } pszValue = lr_yum_repo_path(pRepo, "filelists"); if(pszValue != NULL) { hy_repo_set_string(hRepo, HY_REPO_FILELISTS_FN, pszValue); } pszValue = lr_yum_repo_path(pRepo, "updateinfo"); if(pszValue != NULL) { hy_repo_set_string (hRepo, HY_REPO_UPDATEINFO_FN, pszValue); } cleanup: return dwError; error: goto cleanup; }
static int set_str(_RepoObject *self, PyObject *value, void *closure) { intptr_t str_key = (intptr_t)closure; PyObject *tmp_py_str = NULL; const char *str_value = pycomp_get_string(value, &tmp_py_str); if (str_value == NULL) { Py_XDECREF(tmp_py_str); return -1; } hy_repo_set_string(self->repo, str_key, str_value); Py_XDECREF(tmp_py_str); return 0; }
END_TEST START_TEST(test_load_repo_err) { g_autoptr(GError) error = NULL; HifSack *sack = hif_sack_new(); hif_sack_set_cachedir(sack, test_globals.tmpdir); fail_unless(hif_sack_setup(sack, HIF_SACK_SETUP_FLAG_MAKE_CACHE_DIR, &error)); g_assert(sack != NULL); HyRepo repo = hy_repo_create("crabalocker"); g_assert(repo != NULL); hy_repo_set_string(repo, HY_REPO_MD_FN, "/non/existing"); fail_unless(!hif_sack_load_repo(sack, repo, 0, &error)); fail_unless(g_error_matches (error, HIF_ERROR, HIF_ERROR_FILE_INVALID)); hy_repo_free(repo); g_object_unref(sack); }