Example #1
0
static int
set_installonly_limit(_SackObject *self, PyObject *obj, void *unused)
{
    int limit = (int)PyLong_AsLong(obj);
    if (PyErr_Occurred())
        return -1;
    hif_sack_set_installonly_limit(self->sack, limit);
    return 0;
}
Example #2
0
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;
}