예제 #1
0
파일: test_goal.c 프로젝트: stepasm/libhif
END_TEST

START_TEST(test_goal_describe_problem_rules)
{
    g_autoptr(GError) error = NULL;
    DnfSack *sack = test_globals.sack;
    DnfPackage *pkg = get_latest_pkg(sack, "hello");
    HyGoal goal = hy_goal_create(sack);

    hy_goal_install(goal, pkg);
    fail_unless(hy_goal_run(goal));
    fail_unless(hy_goal_list_installs(goal, &error) == NULL);
    fail_unless(error->code == DNF_ERROR_NO_SOLUTION);
    fail_unless(hy_goal_count_problems(goal) > 0);

    g_auto(GStrv) problems = hy_goal_describe_problem_rules(goal, 0);
    const char *expected[] = {
                "conflicting requests",
                "nothing provides goodbye needed by hello-1-1.noarch"
                };
    for (gint p = 0; p < hy_goal_count_problems(goal); ++p) {
        fail_if(strncmp(problems[p], expected[p], strlen(expected[p])));
    }

    g_object_unref(pkg);
    hy_goal_free(goal);
}
예제 #2
0
파일: test_goal.c 프로젝트: stepasm/libhif
END_TEST

START_TEST(test_goal_verify)
{
    g_autoptr(GError) error = NULL;
    DnfSack *sack = test_globals.sack;
    HyGoal goal = hy_goal_create(sack);

    fail_unless(hy_goal_run_flags(goal, DNF_VERIFY));
    fail_unless(hy_goal_list_installs(goal, &error) == NULL);
    fail_unless(error->code == DNF_ERROR_NO_SOLUTION);
    fail_unless(hy_goal_count_problems(goal) == 2);

    const char *expected;
    char *problem;
    problem = hy_goal_describe_problem(goal, 0);
    expected = "nothing provides missing-dep needed by missing-1-0.x86_64";
    fail_if(strncmp(problem, expected, strlen(expected)));
    g_free(problem);
    problem = hy_goal_describe_problem(goal, 1);
    expected = "package conflict-1-0.x86_64 conflicts with ok provided by ok-1-0.x86_64";
    fail_if(strncmp(problem, expected, strlen(expected)));
    g_free(problem);

    hy_goal_free(goal);
}
예제 #3
0
파일: test_goal.c 프로젝트: mtoman/hawkey
END_TEST

START_TEST(test_goal_get_reason)
{
    HyPackage pkg = get_latest_pkg(test_globals.sack, "walrus");
    HyGoal goal = hy_goal_create(test_globals.sack);
    hy_goal_install(goal, pkg);
    hy_package_free(pkg);
    hy_goal_run(goal);

    HyPackageList plist = hy_goal_list_installs(goal);
    int i;
    int set = 0;
    FOR_PACKAGELIST(pkg, plist, i) {
	if (!strcmp(hy_package_get_name(pkg), "walrus")) {
	    set |= 1 << 0;
	    fail_unless(hy_goal_get_reason(goal, pkg) == HY_REASON_USER);
	}
	if (!strcmp(hy_package_get_name(pkg), "semolina")) {
	    set |= 1 << 1;
	    fail_unless(hy_goal_get_reason(goal, pkg) == HY_REASON_DEP);
	}
    }
    fail_unless(set == 3);

    hy_packagelist_free(plist);
    hy_goal_free(goal);
}
예제 #4
0
파일: test_goal.c 프로젝트: mtoman/hawkey
END_TEST

START_TEST(test_goal_verify)
{
    HySack sack = test_globals.sack;
    HyGoal goal = hy_goal_create(sack);

    fail_unless(hy_goal_run_flags(goal, HY_VERIFY));
    fail_unless(hy_goal_list_installs(goal) == NULL);
    fail_unless(hy_get_errno() == HY_E_NO_SOLUTION);
    fail_unless(hy_goal_count_problems(goal) == 2);

    char *expected;
    char *problem;
    problem = hy_goal_describe_problem(goal, 0);
    expected = "nothing provides missing-dep needed by missing-1-0.x86_64";
    fail_if(strncmp(problem, expected, strlen(expected)));
    hy_free(problem);
    problem = hy_goal_describe_problem(goal, 1);
    expected = "package conflict-1-0.x86_64 conflicts with ok provided by ok-1-0.x86_64";
    fail_if(strncmp(problem, expected, strlen(expected)));
    hy_free(problem);

    hy_goal_free(goal);
}
예제 #5
0
파일: test_goal.c 프로젝트: stepasm/libhif
END_TEST

START_TEST(test_goal_get_reason)
{
    DnfPackage *pkg = get_latest_pkg(test_globals.sack, "walrus");
    HyGoal goal = hy_goal_create(test_globals.sack);
    hy_goal_install(goal, pkg);
    g_object_unref(pkg);
    hy_goal_run(goal);

    GPtrArray *plist = hy_goal_list_installs(goal, NULL);
    guint i;
    int set = 0;
    for(i = 0; i < plist->len; i++) {
        pkg = g_ptr_array_index (plist, i);
        if (!strcmp(dnf_package_get_name(pkg), "walrus")) {
            set |= 1 << 0;
            fail_unless(hy_goal_get_reason(goal, pkg) == HY_REASON_USER);
        }
        if (!strcmp(dnf_package_get_name(pkg), "semolina")) {
            set |= 1 << 1;
            fail_unless(hy_goal_get_reason(goal, pkg) == HY_REASON_DEP);
        }
    }
    fail_unless(set == 3);

    g_ptr_array_unref(plist);
    hy_goal_free(goal);
}
예제 #6
0
파일: test_goal.c 프로젝트: stepasm/libhif
/* assert on installed-upgraded-erased-obsoleted numbers */
static void
assert_iueo(HyGoal goal, int i, int u, int e, int o)
{
    ck_assert_int_eq(size_and_free(hy_goal_list_installs(goal, NULL)), i);
    ck_assert_int_eq(size_and_free(hy_goal_list_upgrades(goal, NULL)), u);
    ck_assert_int_eq(size_and_free(hy_goal_list_erasures(goal, NULL)), e);
    ck_assert_int_eq(size_and_free(hy_goal_list_obsoleted(goal, NULL)), o);
}
예제 #7
0
파일: test_goal.c 프로젝트: mtoman/hawkey
END_TEST

START_TEST(test_goal_list_err)
{
    HyGoal goal = hy_goal_create(test_globals.sack);
    fail_unless(hy_goal_list_installs(goal) == NULL);
    fail_unless(hy_get_errno() == HY_E_OP);
    hy_goal_free(goal);
}
예제 #8
0
파일: test_goal.c 프로젝트: stepasm/libhif
END_TEST

START_TEST(test_goal_list_err)
{
    g_autoptr(GError) error = NULL;
    HyGoal goal = hy_goal_create(test_globals.sack);
    fail_unless(hy_goal_list_installs(goal, &error) == NULL);
    fail_unless(error->code == DNF_ERROR_INTERNAL_ERROR);
    hy_goal_free(goal);
}
예제 #9
0
파일: hth.c 프로젝트: Tojaj/hawkey
static void update(HySack sack, HyPackage pkg)
{
    HyGoal goal = hy_goal_create(sack);

    if (hy_goal_upgrade_to_flags(goal, pkg, HY_CHECK_INSTALLED)) {
	printf("no package of that name installed, trying install\n");
	hy_goal_install(goal, pkg);
    }
    if (hy_goal_run(goal)) {
	dump_goal_errors(goal);
	// handle errors
	goto finish;
    }
    // handle upgrades
    HyPackageList plist = hy_goal_list_upgrades(goal);
    printf("upgrade count: %d\n", hy_packagelist_count(plist));
    for (int i = 0; i < hy_packagelist_count(plist); ++i) {
	HyPackage pkg = hy_packagelist_get(plist, i);
	char *nvra = hy_package_get_nevra(pkg);
	char *location = hy_package_get_location(pkg);
	HyPackageList obsoleted = hy_goal_list_obsoleted_by_package(goal, pkg);
	HyPackage installed = hy_packagelist_get(obsoleted, 0);
	char *nvra_installed = hy_package_get_nevra(installed);

	printf("upgrading: %s using %s\n", nvra, location);
	printf("\tfrom: %s\n", nvra_installed);
	printf("\tsize: %lld kB\n", hy_package_get_size(pkg) / 1024);

	hy_free(nvra_installed);
	hy_packagelist_free(obsoleted);
	hy_free(location);
	hy_free(nvra);
    }
    hy_packagelist_free(plist);
    // handle installs
    plist = hy_goal_list_installs(goal);
    printf("install count: %d\n", hy_packagelist_count(plist));
    for (int i = 0; i < hy_packagelist_count(plist); ++i) {
	HyPackage pkg = hy_packagelist_get(plist, i);
	char *nvra = hy_package_get_nevra(pkg);
	char *location = hy_package_get_location(pkg);

	printf("installing: %s using %s\n", nvra, location);
	printf("\tsize: %lld kB\n", hy_package_get_size(pkg) / 1024);

	hy_free(location);
	hy_free(nvra);
    }
    hy_packagelist_free(plist);

 finish:
    hy_goal_free(goal);
}
예제 #10
0
static void update(HifSack *sack, HifPackage *pkg)
{
    HyGoal goal = hy_goal_create(sack);

    if (hy_goal_upgrade_to_flags(goal, pkg, HY_CHECK_INSTALLED)) {
        printf("no package of that name installed, trying install\n");
        hy_goal_install(goal, pkg);
    }
    if (hy_goal_run(goal)) {
        dump_goal_errors(goal);
        // handle errors
        goto finish;
    }
    // handle upgrades
    GPtrArray *plist = hy_goal_list_upgrades(goal, NULL);
    printf("upgrade count: %d\n", plist->len);
    for (unsigned int i = 0; i < plist->len; ++i) {
        HifPackage *upkg = g_ptr_array_index(plist, i);
        const char *nvra = hif_package_get_nevra(upkg);
        char *location = hif_package_get_location(upkg);
        GPtrArray *obsoleted = hy_goal_list_obsoleted_by_package(goal, upkg);
        HifPackage *installed = g_ptr_array_index(obsoleted, 0);
        const char *nvra_installed = hif_package_get_nevra(installed);

        printf("upgrading: %s using %s\n", nvra, location);
        printf("\tfrom: %s\n", nvra_installed);
        printf("\tsize: %lu kB\n", hif_package_get_size(upkg) / 1024);

        g_ptr_array_unref(obsoleted);
        g_free(location);
    }
    g_ptr_array_unref(plist);
    // handle installs
    plist = hy_goal_list_installs(goal, NULL);
    printf("install count: %d\n", plist->len);
    for (unsigned int i = 0; i < plist->len; ++i) {
        HifPackage *ipkg = g_ptr_array_index(plist, i);
        const char *nvra = hif_package_get_nevra(ipkg);
        char *location = hif_package_get_location(ipkg);

        printf("installing: %s using %s\n", nvra, location);
        printf("\tsize: %lu kB\n", hif_package_get_size(ipkg) / 1024);

        g_free(location);
    }
    g_ptr_array_unref(plist);

finish:
    hy_goal_free(goal);
}
예제 #11
0
파일: test_goal.c 프로젝트: mtoman/hawkey
static int
solution_cb(HyGoal goal, void *data)
{
    struct Solutions *solutions = (struct Solutions*)data;
    solutions->solutions++;

    HyPackageList new_installs = hy_goal_list_installs(goal);
    HyPackage pkg;
    int i;

    FOR_PACKAGELIST(pkg, new_installs, i)
	if (!hy_packagelist_has(solutions->installs, pkg))
	    hy_packagelist_push(solutions->installs, hy_package_link(pkg));
    hy_packagelist_free(new_installs);

    return 0;
}
예제 #12
0
파일: test_goal.c 프로젝트: stepasm/libhif
static int
solution_cb(HyGoal goal, void *data)
{
    struct Solutions *solutions = (struct Solutions*)data;
    solutions->solutions++;

    GPtrArray *new_installs = hy_goal_list_installs(goal, NULL);
    DnfPackage *pkg;
    guint i;

    for(i = 0; i < new_installs->len; i++) {
        pkg = g_ptr_array_index (new_installs, i);
        if (!hy_packagelist_has(solutions->installs, pkg))
            g_ptr_array_add(solutions->installs, g_object_ref(pkg));
    }
    g_ptr_array_unref(new_installs);

    return 0;
}
static gboolean
compute_checksum_from_treefile_and_goal (RpmOstreeTreeComposeContext   *self,
                                         HyGoal                         goal,
                                         char                        **out_checksum,
                                         GError                      **error)
{
  gboolean ret = FALSE;
  gs_free char *ret_checksum = NULL;
  GChecksum *checksum = g_checksum_new (G_CHECKSUM_SHA256);
  
  /* Hash in the raw treefile; this means reordering the input packages
   * or adding a comment will cause a recompose, but let's be conservative
   * here.
   */
  { gsize len;
    const guint8* buf = g_bytes_get_data (self->serialized_treefile, &len);

    g_checksum_update (checksum, buf, len);
  }

  /* FIXME; we should also hash the post script */

  /* Hash in each package */
  { _cleanup_hypackagelist_ HyPackageList pkglist = NULL;
    HyPackage pkg;
    guint i;
    gs_unref_ptrarray GPtrArray *nevras = g_ptr_array_new_with_free_func (g_free);

    pkglist = hy_goal_list_installs (goal);

    FOR_PACKAGELIST(pkg, pkglist, i)
      {
        g_ptr_array_add (nevras, hy_package_get_nevra (pkg));
      }

    g_ptr_array_sort (nevras, ptrarray_sort_compare_strings);
    
    for (i = 0; i < nevras->len; i++)
      {
        const char *nevra = nevras->pdata[i];
        g_checksum_update (checksum, (guint8*)nevra, strlen (nevra));
      }
  }
예제 #14
0
파일: test_goal.c 프로젝트: stepasm/libhif
END_TEST

START_TEST(test_goal_install_selector_obsoletes_first)
{
    HySelector sltr;
    HyGoal goal = hy_goal_create(test_globals.sack);

    sltr = hy_selector_create(test_globals.sack);
    hy_selector_set(sltr, HY_PKG_PROVIDES, HY_EQ, "somereq");
    fail_if(!hy_goal_install_selector(goal, sltr, NULL));
    hy_selector_free(sltr);

    fail_if(hy_goal_run(goal));
    assert_iueo(goal, 1, 0, 0, 0);

    GPtrArray *plist = hy_goal_list_installs(goal, NULL);
    const char *nvra = dnf_package_get_nevra(g_ptr_array_index(plist, 0));
    ck_assert_str_eq(nvra, "B-1-0.noarch");
    g_ptr_array_unref(plist);
    hy_goal_free(goal);
}
예제 #15
0
파일: test_goal.c 프로젝트: mtoman/hawkey
END_TEST

START_TEST(test_goal_get_reason_selector)
{

    HySelector sltr = hy_selector_create(test_globals.sack);
    HyGoal goal = hy_goal_create(test_globals.sack);

    fail_if(hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "walrus"));
    fail_if(hy_goal_install_selector(goal, sltr));
    hy_selector_free(sltr);

    fail_if(hy_goal_run(goal));

    HyPackageList plist = hy_goal_list_installs(goal);
    fail_unless(hy_packagelist_count(plist) == 2);
    HyPackage pkg = hy_packagelist_get(plist, 0);
    fail_unless(hy_goal_get_reason(goal, pkg) == HY_REASON_USER);

    hy_packagelist_free(plist);
    hy_goal_free(goal);
}
예제 #16
0
파일: hif-goal.c 프로젝트: juhp/libhif
/**
 * hif_goal_get_packages:
 */
GPtrArray *
hif_goal_get_packages (HyGoal goal, ...)
{
	GPtrArray *array;
	HyPackage pkg;
	gint info_tmp;
	guint i;
	guint j;
	va_list args;

	/* process the valist */
	va_start (args, goal);
	array = g_ptr_array_new_with_free_func ((GDestroyNotify) hy_package_free);
	for (j = 0;; j++) {
		HyPackageList pkglist = NULL;
		info_tmp = va_arg (args, gint);
		if (info_tmp == -1)
			break;
		switch (info_tmp) {
		case HIF_PACKAGE_INFO_REMOVE:
			pkglist = hy_goal_list_erasures (goal);
			FOR_PACKAGELIST(pkg, pkglist, i) {
				hif_package_set_action (pkg, HIF_STATE_ACTION_REMOVE);
				g_ptr_array_add (array, hy_package_link (pkg));
			}
			break;
		case HIF_PACKAGE_INFO_INSTALL:
			pkglist = hy_goal_list_installs (goal);
			FOR_PACKAGELIST(pkg, pkglist, i) {
				hif_package_set_action (pkg, HIF_STATE_ACTION_INSTALL);
				g_ptr_array_add (array, hy_package_link (pkg));
			}
			break;
		case HIF_PACKAGE_INFO_OBSOLETE:
			pkglist = hy_goal_list_obsoleted (goal);
			FOR_PACKAGELIST(pkg, pkglist, i) {
				hif_package_set_action (pkg, HIF_STATE_ACTION_OBSOLETE);
				g_ptr_array_add (array, hy_package_link (pkg));
			}
예제 #17
0
파일: test_goal.c 프로젝트: stepasm/libhif
END_TEST

START_TEST(test_goal_get_reason_selector)
{

    HySelector sltr = hy_selector_create(test_globals.sack);
    HyGoal goal = hy_goal_create(test_globals.sack);

    fail_if(hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "walrus"));
    fail_if(!hy_goal_install_selector(goal, sltr, NULL));
    hy_selector_free(sltr);

    fail_if(hy_goal_run(goal));

    GPtrArray *plist = hy_goal_list_installs(goal, NULL);
    fail_unless(plist->len == 2);
    DnfPackage *pkg = g_ptr_array_index(plist, 0);
    fail_unless(hy_goal_get_reason(goal, pkg) == HY_REASON_USER);

    g_ptr_array_unref(plist);
    hy_goal_free(goal);
}
예제 #18
0
파일: test_goal.c 프로젝트: mtoman/hawkey
END_TEST

START_TEST(test_goal_describe_problem)
{
    HySack sack = test_globals.sack;
    HyPackage pkg = get_latest_pkg(sack, "hello");
    HyGoal goal = hy_goal_create(sack);

    hy_goal_install(goal, pkg);
    fail_unless(hy_goal_run(goal));
    fail_unless(hy_goal_list_installs(goal) == NULL);
    fail_unless(hy_get_errno() == HY_E_NO_SOLUTION);
    fail_unless(hy_goal_count_problems(goal) > 0);

    char *problem = hy_goal_describe_problem(goal, 0);
    const char *expected = "nothing provides goodbye";
    fail_if(strncmp(problem, expected, strlen(expected)));
    hy_free(problem);

    hy_package_free(pkg);
    hy_goal_free(goal);
}
예제 #19
0
파일: test_goal.c 프로젝트: stepasm/libhif
END_TEST

START_TEST(test_goal_install_selector)
{
    HySelector sltr;
    HyGoal goal = hy_goal_create(test_globals.sack);

    // test arch forcing
    sltr = hy_selector_create(test_globals.sack);
    hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "semolina");
    hy_selector_set(sltr, HY_PKG_ARCH, HY_EQ, "i686");
    fail_if(!hy_goal_install_selector(goal, sltr, NULL));
    hy_selector_free(sltr);

    fail_if(hy_goal_run(goal));
    assert_iueo(goal, 1, 0, 0, 0);

    GPtrArray *plist = hy_goal_list_installs(goal, NULL);
    const char *nvra = dnf_package_get_nevra(g_ptr_array_index(plist, 0));
    ck_assert_str_eq(nvra, "semolina-2-0.i686");
    g_ptr_array_unref(plist);
    hy_goal_free(goal);
}
예제 #20
0
파일: test_goal.c 프로젝트: stepasm/libhif
END_TEST

START_TEST(test_goal_describe_problem)
{
    g_autoptr(GError) error = NULL;
    DnfSack *sack = test_globals.sack;
    DnfPackage *pkg = get_latest_pkg(sack, "hello");
    HyGoal goal = hy_goal_create(sack);

    hy_goal_install(goal, pkg);
    fail_unless(hy_goal_run(goal));
    fail_unless(hy_goal_list_installs(goal, &error) == NULL);
    fail_unless(error->code == DNF_ERROR_NO_SOLUTION);
    fail_unless(hy_goal_count_problems(goal) > 0);

    char *problem = hy_goal_describe_problem(goal, 0);
    const char *expected = "nothing provides goodbye";
    fail_if(strncmp(problem, expected, strlen(expected)));
    g_free(problem);

    g_object_unref(pkg);
    hy_goal_free(goal);
}
예제 #21
0
uint32_t
TDNFTransAddInstallPkgs(
    PTDNFRPMTS pTS,
    PTDNF pTdnf
    )
{
    uint32_t dwError = 0;
    int i = 0;
    HyPackage hPkg = NULL;
    HyPackageList hPkgList = NULL;

    hPkgList = hy_goal_list_installs(pTdnf->hGoal);
    if(!hPkgList)
    {
        dwError = ERROR_TDNF_NO_DATA;
        BAIL_ON_TDNF_ERROR(dwError);
    }
    for(i = 0; (hPkg = hy_packagelist_get(hPkgList, i)) != NULL; ++i)
    {
        dwError = TDNFTransAddInstallPkg(pTS, pTdnf, hPkg, 0);
        BAIL_ON_TDNF_ERROR(dwError);
    }

cleanup:
    if(hPkgList)
    {
        hy_packagelist_free(hPkgList);
    }
    return dwError;

error:
    if(dwError == ERROR_TDNF_NO_DATA)
    {
        dwError = 0;
    }
    goto cleanup;
}
예제 #22
0
파일: test_goal.c 프로젝트: mtoman/hawkey
END_TEST

START_TEST(test_goal_install_selector)
{
    HySelector sltr;
    HyGoal goal = hy_goal_create(test_globals.sack);

    // test arch forcing
    sltr = hy_selector_create(test_globals.sack);
    hy_selector_set(sltr, HY_PKG_NAME, HY_EQ, "semolina");
    hy_selector_set(sltr, HY_PKG_ARCH, HY_EQ, "i686");
    fail_if(hy_goal_install_selector(goal, sltr));
    hy_selector_free(sltr);

    fail_if(hy_goal_run(goal));
    assert_iueo(goal, 1, 0, 0, 0);

    HyPackageList plist = hy_goal_list_installs(goal);
    char *nvra = hy_package_get_nevra(hy_packagelist_get(plist, 0));
    ck_assert_str_eq(nvra, "semolina-2-0.i686");
    hy_free(nvra);
    hy_packagelist_free(plist);
    hy_goal_free(goal);
}
예제 #23
0
파일: test_goal.c 프로젝트: stepasm/libhif
END_TEST

START_TEST(test_goal_installonly_upgrade_all)
{
    const char *installonly[] = {"fool", NULL};
    DnfSack *sack = test_globals.sack;
    HyGoal goal = hy_goal_create(sack);

    dnf_sack_set_installonly(sack, installonly);
    dnf_sack_set_installonly_limit(sack, 2);

    hy_goal_upgrade_all(goal);
    fail_if(hy_goal_run(goal));

    GPtrArray *plist = hy_goal_list_erasures(goal, NULL);
    assert_list_names(plist, "penny", NULL);
    g_ptr_array_unref(plist);
    plist = hy_goal_list_installs(goal, NULL);
    assert_list_names(plist, "fool", NULL);
    g_ptr_array_unref(plist);
    assert_iueo(goal, 1, 4, 1, 0);

    hy_goal_free(goal);
}
예제 #24
0
파일: test_goal.c 프로젝트: mtoman/hawkey
END_TEST

START_TEST(test_goal_installonly_upgrade_all)
{
    const char *installonly[] = {"fool", NULL};
    HySack sack = test_globals.sack;
    HyGoal goal = hy_goal_create(sack);

    hy_sack_set_installonly(sack, installonly);
    hy_sack_set_installonly_limit(sack, 2);

    hy_goal_upgrade_all(goal);
    fail_if(hy_goal_run(goal));

    HyPackageList plist = hy_goal_list_erasures(goal);
    assert_list_names(plist, "penny", NULL);
    hy_packagelist_free(plist);
    plist = hy_goal_list_installs(goal);
    assert_list_names(plist, "fool", NULL);
    hy_packagelist_free(plist);
    assert_iueo(goal, 1, 4, 1, 0);

    hy_goal_free(goal);
}
예제 #25
0
파일: goal.c 프로젝트: xiaolin-vmware/tdnf
uint32_t
TDNFGoal(
    PTDNF pTdnf,
    HyPackageList hPkgList,
    HySelector hSelector,
    TDNF_ALTERTYPE nResolveFor,
    PTDNF_SOLVED_PKG_INFO pInfo
    )
{
    uint32_t dwError = 0;
    HyGoal hGoal = NULL;
    HyPackage hPkg = NULL;
    PTDNF_PKG_INFO pPkgsToInstall = NULL;
    PTDNF_PKG_INFO pPkgsToUpgrade = NULL;
    PTDNF_PKG_INFO pPkgsToDowngrade = NULL;
    PTDNF_PKG_INFO pPkgsToRemove = NULL;
    PTDNF_PKG_INFO pPkgsUnNeeded = NULL;
    PTDNF_PKG_INFO pPkgsToReinstall = NULL;

    int nFlags = 0;
    int nRequirePkgList =
        (nResolveFor != ALTER_UPGRADEALL &&
         nResolveFor != ALTER_DISTRO_SYNC);

    if(!pTdnf || !pInfo )
    {
        dwError = ERROR_TDNF_INVALID_PARAMETER;
        BAIL_ON_TDNF_ERROR(dwError);
    }

    if(nResolveFor == ALTER_UPGRADE && !hSelector)
    {
        dwError = ERROR_TDNF_INVALID_PARAMETER;
        BAIL_ON_TDNF_ERROR(dwError);
    }

    if(nRequirePkgList)
    {
        if(!hPkgList)
        {
            dwError = ERROR_TDNF_INVALID_PARAMETER;
            BAIL_ON_TDNF_ERROR(dwError);
        }

        hPkg = hy_packagelist_get(hPkgList, 0);
        if(!hPkg)
        {
            dwError = ERROR_TDNF_PACKAGELIST_EMPTY;
            BAIL_ON_TDNF_ERROR(dwError);
        }
    }

    hGoal = hy_goal_create(pTdnf->hSack);
    if(!hGoal)
    {
        dwError = ERROR_TDNF_GOAL_CREATE;
        BAIL_ON_TDNF_ERROR(dwError);
    }
    switch(nResolveFor)
    {
        case ALTER_DOWNGRADE:
            dwError = hy_goal_downgrade_to(hGoal, hPkg);
            BAIL_ON_TDNF_HAWKEY_ERROR(dwError);
            break;
        case ALTER_ERASE:
            dwError = hy_goal_erase(hGoal, hPkg);
            BAIL_ON_TDNF_HAWKEY_ERROR(dwError);
            break;
        case ALTER_REINSTALL:
            dwError = hy_goal_install(hGoal, hPkg);
            BAIL_ON_TDNF_HAWKEY_ERROR(dwError);
            break;
        case ALTER_INSTALL:
            dwError = TDNFPackageGetLatest(hPkgList, &hPkg);
            BAIL_ON_TDNF_ERROR(dwError);
            dwError = hy_goal_install(hGoal, hPkg);
            BAIL_ON_TDNF_HAWKEY_ERROR(dwError);
            break;
        case ALTER_UPGRADE:
            dwError = hy_goal_upgrade_to_selector(hGoal, hSelector);
            BAIL_ON_TDNF_HAWKEY_ERROR(dwError);
            break;
        case ALTER_UPGRADEALL:
            dwError = hy_goal_upgrade_all(hGoal);
            BAIL_ON_TDNF_HAWKEY_ERROR(dwError);
            break;
        case ALTER_DISTRO_SYNC:
            dwError = hy_goal_distupgrade_all(hGoal);
            BAIL_ON_TDNF_HAWKEY_ERROR(dwError);
            break;
        case ALTER_AUTOERASE:
            dwError = TDNFGoalSetUserInstalled(hGoal, hPkgList);
            BAIL_ON_TDNF_HAWKEY_ERROR(dwError);
            break;
        default:
            dwError = ERROR_TDNF_INVALID_RESOLVE_ARG;
            BAIL_ON_TDNF_ERROR(dwError);
    }

    if(pTdnf->pArgs->nBest)
    {
        nFlags = nFlags | HY_FORCE_BEST;
    }
    if(pTdnf->pArgs->nAllowErasing ||
       nResolveFor == ALTER_ERASE ||
       nResolveFor == ALTER_AUTOERASE)
    {
        nFlags = nFlags | HY_ALLOW_UNINSTALL;
    }

    dwError = hy_goal_run_flags(hGoal, nFlags);
    if(pTdnf->pArgs->nDebugSolver)
    {
        hy_goal_write_debugdata(hGoal, "debugdata");
    }
    BAIL_ON_TDNF_HAWKEY_ERROR(dwError);

    dwError = TDNFGoalGetResultsIgnoreNoData(
                  hy_goal_list_installs(hGoal),
                  &pPkgsToInstall);
    BAIL_ON_TDNF_ERROR(dwError);

    dwError = TDNFGoalGetResultsIgnoreNoData(
                  hy_goal_list_upgrades(hGoal),
                  &pPkgsToUpgrade);
    BAIL_ON_TDNF_ERROR(dwError);

    dwError = TDNFGoalGetResultsIgnoreNoData(
                  hy_goal_list_downgrades(hGoal),
                  &pPkgsToDowngrade);
    BAIL_ON_TDNF_ERROR(dwError);

    dwError = TDNFGoalGetResultsIgnoreNoData(
                  hy_goal_list_erasures(hGoal),
                  &pPkgsToRemove);
    BAIL_ON_TDNF_ERROR(dwError);

    if(nResolveFor == ALTER_AUTOERASE)
    {
        dwError = TDNFGoalGetResultsIgnoreNoData(
                      hy_goal_list_unneeded(hGoal),
                      &pPkgsUnNeeded);
        BAIL_ON_TDNF_ERROR(dwError);
    }
    dwError = TDNFGoalGetResultsIgnoreNoData(
                  hy_goal_list_reinstalls(hGoal),
                  &pPkgsToReinstall);
    BAIL_ON_TDNF_ERROR(dwError);

    pInfo->pPkgsToInstall = pPkgsToInstall;
    pInfo->pPkgsToUpgrade = pPkgsToUpgrade;
    pInfo->pPkgsToDowngrade = pPkgsToDowngrade;
    pInfo->pPkgsToRemove = pPkgsToRemove;
    pInfo->pPkgsUnNeeded = pPkgsUnNeeded;
    pInfo->pPkgsToReinstall = pPkgsToReinstall;
    pTdnf->hGoal = hGoal;

cleanup:
    return dwError;

error:
    if(hGoal)
    {
        TDNFGoalReportProblems(hGoal);
        hy_goal_free(hGoal);
    }
    if(pPkgsToInstall)
    {
        TDNFFreePackageInfo(pPkgsToInstall);
    }
    if(pPkgsToUpgrade)
    {
        TDNFFreePackageInfo(pPkgsToUpgrade);
    }
    if(pPkgsToDowngrade)
    {
        TDNFFreePackageInfo(pPkgsToDowngrade);
    }
    if(pPkgsToRemove)
    {
        TDNFFreePackageInfo(pPkgsToRemove);
    }
    if(pPkgsUnNeeded)
    {
        TDNFFreePackageInfo(pPkgsUnNeeded);
    }
    if(pPkgsToReinstall)
    {
        TDNFFreePackageInfo(pPkgsToReinstall);
    }
    goto cleanup;
}