static PyObject * load_repo(_SackObject *self, PyObject *args, PyObject *kwds) { const char *kwlist[] = {"repo", "build_cache", "load_filelists", "load_presto", "load_updateinfo", NULL}; HyRepo crepo = NULL; int build_cache = 0, load_filelists = 0, load_presto = 0, load_updateinfo = 0; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|iiii", (char**) kwlist, repo_converter, &crepo, &build_cache, &load_filelists, &load_presto, &load_updateinfo)) return 0; int flags = 0; gboolean ret = 0; g_autoptr(GError) error = NULL; if (build_cache) flags |= HIF_SACK_LOAD_FLAG_BUILD_CACHE; if (load_filelists) flags |= HIF_SACK_LOAD_FLAG_USE_FILELISTS; if (load_presto) flags |= HIF_SACK_LOAD_FLAG_USE_PRESTO; if (load_updateinfo) flags |= HIF_SACK_LOAD_FLAG_USE_UPDATEINFO; Py_BEGIN_ALLOW_THREADS; ret = hif_sack_load_repo(self->sack, crepo, flags, &error); Py_END_ALLOW_THREADS; if (!ret) return op_error2exc(error); Py_RETURN_NONE; }
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); }
int main(int argc, const char **argv) { HifSack *sack = hif_sack_new (); HyRepo repo; char *md_repo; char *md_primary_xml; char *md_filelists; char *md_repo_updates; char *md_primary_updates_xml; char *md_filelists_updates; int ret; g_autoptr(GError) error = NULL; if (!hif_sack_setup(sack, HIF_SACK_SETUP_FLAG_MAKE_CACHE_DIR, NULL)) return 1; if (read_repopaths(&md_repo, &md_primary_xml, &md_filelists, &md_repo_updates, &md_primary_updates_xml, &md_filelists_updates)) { fprintf(stderr, "This is hawkey testing hack, it needs a readable %s file " "containing the following paths on separate lines:\n" "<main repomd.xml path>\n" "<main primary.xml.gz path>\n" "<main filelist.xml.gz path>\n" "<updates repomd.xml path>\n" "<updates primary.xml.gz path>\n" "<updates filelists.xml.gz path>\n", CFG_FILE); return 1; } int load_flags = HIF_SACK_LOAD_FLAG_BUILD_CACHE; /* rpmdb */ repo = hy_repo_create(HY_SYSTEM_REPO_NAME); hif_sack_load_system_repo(sack, NULL, load_flags, &error); hy_repo_free(repo); if (need_filelists(argc, argv)) load_flags |= HIF_SACK_LOAD_FLAG_USE_FILELISTS; /* Fedora repo */ repo = config_repo("Fedora", md_repo, md_primary_xml, md_filelists); ret = hif_sack_load_repo(sack, repo, load_flags, &error); assert(ret == 0); (void)ret; hy_repo_free(repo); /* Fedora updates repo */ repo = config_repo("updates", md_repo_updates, md_primary_updates_xml, md_filelists_updates); ret = hif_sack_load_repo(sack, repo, load_flags, &error); assert(ret == 0); (void)ret; hy_repo_free(repo); free(md_repo); free(md_primary_xml); free(md_filelists); free(md_repo_updates); free(md_primary_updates_xml); free(md_filelists_updates); hif_sack_set_installonly(sack, installonly); hif_sack_set_installonly_limit(sack, 3); if (argc == 2 && !strcmp(argv[1], "-o")) { obsoletes(sack); } else if (argc == 2) { search_and_print(sack, argv[1]); } else if (argc == 3 && !strcmp(argv[1], "-f")) { search_filter_files(sack, argv[2]); } else if (argc == 3 && !strcmp(argv[1], "-r")) { search_filter_repos(sack, argv[2]); } else if (argc == 3 && !strcmp(argv[1], "-u")) { updatables_query_name(sack, argv[2]); } else if (argc == 3 && !strcmp(argv[1], "-ul")) { update_local(sack, argv[2]); } else if (argc == 3 && !strcmp(argv[1], "-ur")) { update_remote(sack, argv[2]); } else if (argc == 3 && !strcmp(argv[1], "-e")) { erase(sack, argv[2]); } else if (argc == 3) { search_anded(sack, argv[1], argv[2]); } else if (argc == 4 && !strcmp(argv[1], "-p")) { search_provides(sack, argv[2], argv[3]); } g_object_unref(sack); return 0; }