dcavalca / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

Blame SOURCES/0001-Revert-selector-prefer-obsoletes-Related-RhBug-10965.patch

763049
From 13bfe81a226d0bde8d2b58d53c566e4c34069cea Mon Sep 17 00:00:00 2001
763049
From: Igor Gnatenko <ignatenko@redhat.com>
763049
Date: Thu, 5 Jan 2017 12:04:17 +0100
763049
Subject: [PATCH] Revert "selector: prefer obsoletes (Related:RhBug:1096506)"
763049
763049
This reverts commit 94ac2e5b980f9095faa372568a8e381e8a4523bc.
763049
763049
Conflicts:
763049
	libdnf/hy-goal.c
763049
	tests/hawkey/test_goal.c
763049
---
763049
 data/tests/hawkey/greedy.repo |  2 --
763049
 libdnf/hy-goal.c              | 32 ++------------------------------
763049
 tests/hawkey/test_goal.c      | 22 ----------------------
763049
 3 files changed, 2 insertions(+), 54 deletions(-)
763049
763049
diff --git a/data/tests/hawkey/greedy.repo b/data/tests/hawkey/greedy.repo
763049
index d450885..64bb85a 100644
763049
--- a/data/tests/hawkey/greedy.repo
763049
+++ b/data/tests/hawkey/greedy.repo
763049
@@ -5,7 +5,5 @@
763049
 =Pkg: B 1 0 noarch
763049
 =Rec: C
763049
 =Prv: somereq
763049
-=Obs: somereq
763049
 =Pkg: C 1 0 noarch
763049
 =Prv: somereq
763049
-=Pkg: somereq 1 0 noarch
763049
diff --git a/libdnf/hy-goal.c b/libdnf/hy-goal.c
763049
index dc05c1c..3ff1ce6 100644
763049
--- a/libdnf/hy-goal.c
763049
+++ b/libdnf/hy-goal.c
763049
@@ -550,34 +550,6 @@ filter_name2job(DnfSack *sack, const struct _Filter *f, Queue *job)
763049
     return 0;
763049
 }
763049
 
763049
-/**
763049
- * add_preferred_provide:
763049
- * when searching by provides the packages that contain the same
763049
- * name as provide or contain obsoletes with the same name as their
763049
- * provide will be picked first
763049
- */
763049
-static void
763049
-add_preferred_provide(DnfSack *sack, Queue *job, Id id)
763049
-{
763049
-    Pool *pool = dnf_sack_get_pool(sack);
763049
-    const char *name = pool_dep2str(pool, id);
763049
-    HyQuery q = hy_query_create(sack);
763049
-    hy_query_filter(q, HY_PKG_NAME, HY_NEQ, name);
763049
-    DnfPackageSet *pset = hy_query_run_set(q);
763049
-    hy_query_filter(q, HY_PKG_PROVIDES, HY_EQ, name);
763049
-    hy_query_filter_package_in(q, HY_PKG_OBSOLETES, HY_NEQ, pset);
763049
-    DnfPackage *pkg;
763049
-    g_autoptr(GPtrArray) plist = hy_query_run(q);
763049
-    for (guint i = 0; i < plist->len; i++) {
763049
-        pkg = g_ptr_array_index(plist, i);
763049
-        queue_push2(job, SOLVER_DISFAVOR|SOLVER_SOLVABLE,
763049
-                    dnf_package_get_id(pkg));
763049
-    }
763049
-    queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
763049
-    hy_query_free(q);
763049
-    g_object_unref(pset);
763049
-}
763049
-
763049
 static int
763049
 filter_provides2job(DnfSack *sack, const struct _Filter *f, Queue *job)
763049
 {
763049
@@ -593,7 +565,7 @@ filter_provides2job(DnfSack *sack, const struct _Filter *f, Queue *job)
763049
     switch (f->cmp_type) {
763049
     case HY_EQ:
763049
         id = dnf_reldep_get_id (f->matches[0].reldep);
763049
-        add_preferred_provide(sack, job, id);
763049
+        queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
763049
         break;
763049
     case HY_GLOB:
763049
         dataiterator_init(&di, pool, 0, 0, SOLVABLE_PROVIDES, name, SEARCH_GLOB);
763049
@@ -604,7 +576,7 @@ filter_provides2job(DnfSack *sack, const struct _Filter *f, Queue *job)
763049
         assert(di.idp);
763049
         id = *di.idp;
763049
         if (!job_has(job, SOLVABLE_PROVIDES, id))
763049
-            add_preferred_provide(sack, job, id);
763049
+            queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
763049
         dataiterator_free(&di);
763049
         break;
763049
     default:
763049
diff --git a/tests/hawkey/test_goal.c b/tests/hawkey/test_goal.c
763049
index 7c30097..2a98983 100644
763049
--- a/tests/hawkey/test_goal.c
763049
+++ b/tests/hawkey/test_goal.c
763049
@@ -230,27 +230,6 @@ START_TEST(test_goal_install_selector)
763049
 }
763049
 END_TEST
763049
 
763049
-START_TEST(test_goal_install_selector_obsoletes_first)
763049
-{
763049
-    HySelector sltr;
763049
-    HyGoal goal = hy_goal_create(test_globals.sack);
763049
-
763049
-    sltr = hy_selector_create(test_globals.sack);
763049
-    hy_selector_set(sltr, HY_PKG_PROVIDES, HY_EQ, "somereq");
763049
-    fail_if(!hy_goal_install_selector(goal, sltr, NULL));
763049
-    hy_selector_free(sltr);
763049
-
763049
-    fail_if(hy_goal_run(goal));
763049
-    assert_iueo(goal, 1, 0, 0, 0);
763049
-
763049
-    GPtrArray *plist = hy_goal_list_installs(goal, NULL);
763049
-    const char *nvra = dnf_package_get_nevra(g_ptr_array_index(plist, 0));
763049
-    ck_assert_str_eq(nvra, "B-1-0.noarch");
763049
-    g_ptr_array_unref(plist);
763049
-    hy_goal_free(goal);
763049
-}
763049
-END_TEST
763049
-
763049
 START_TEST(test_goal_install_selector_err)
763049
 {
763049
     int rc;
763049
@@ -1456,7 +1435,6 @@ goal_suite(void)
763049
     tc = tcase_create("Greedy");
763049
     tcase_add_unchecked_fixture(tc, fixture_greedy_only, teardown);
763049
     tcase_add_test(tc, test_goal_run_all);
763049
-    tcase_add_test(tc, test_goal_install_selector_obsoletes_first);
763049
     tcase_add_test(tc, test_goal_install_weak_deps);
763049
     suite_add_tcase(s, tc);
763049
 
763049
-- 
763049
1.8.3.1
763049