Example #1
0
static void update_local(HifSack *sack, const char *fn)
{
    HifPackage *pkg;

    pkg = hif_sack_add_cmdline_package(sack, fn);
    if (pkg) {
        update(sack, pkg);
        g_object_unref(pkg);
    }
}
Example #2
0
END_TEST

START_TEST(test_add_cmdline_package)
{
    HifSack *sack = hif_sack_new();
    hif_sack_set_cachedir(sack, test_globals.tmpdir);

    char *path_mystery = solv_dupjoin(TESTDATADIR, "/hawkey/yum/mystery-devel-19.67-1.noarch.rpm", NULL);
    HifPackage *pkg_mystery = hif_sack_add_cmdline_package(sack, path_mystery);
    char *location_mystery = hif_package_get_location(pkg_mystery);
    ck_assert_str_eq(path_mystery, location_mystery);

    char *path_tour = solv_dupjoin(TESTDATADIR, "/hawkey/yum/tour-4-6.noarch.rpm", NULL);
    HifPackage *pkg_tour = hif_sack_add_cmdline_package(sack, path_tour);
    char *location_tour = hif_package_get_location(pkg_tour);
    ck_assert_str_eq(path_tour, location_tour);

    g_free(path_mystery);
    g_free(location_mystery);
    g_free(path_tour);
    g_free(location_tour);
    g_object_unref(sack);
}
Example #3
0
static PyObject *
add_cmdline_package(_SackObject *self, PyObject *fn_obj)
{
    HifPackage *cpkg;
    PyObject *pkg;
    PyObject *tmp_py_str = NULL;
    const char *fn = pycomp_get_string(fn_obj, &tmp_py_str);

    if (fn == NULL) {
        Py_XDECREF(tmp_py_str);
        return NULL;
    }
    cpkg = hif_sack_add_cmdline_package(self->sack, fn);
    Py_XDECREF(tmp_py_str);
    if (cpkg == NULL) {
        PyErr_Format(PyExc_IOError, "Can not load RPM file: %s.", fn);
        return NULL;
    }
    pkg = new_package((PyObject*)self, hif_package_get_id(cpkg));
    g_object_unref(cpkg);
    return pkg;
}