chantra / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone
Blob Blame History Raw
From 13bfe81a226d0bde8d2b58d53c566e4c34069cea Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenko@redhat.com>
Date: Thu, 5 Jan 2017 12:04:17 +0100
Subject: [PATCH] Revert "selector: prefer obsoletes (Related:RhBug:1096506)"

This reverts commit 94ac2e5b980f9095faa372568a8e381e8a4523bc.

Conflicts:
	libdnf/hy-goal.c
	tests/hawkey/test_goal.c
---
 data/tests/hawkey/greedy.repo |  2 --
 libdnf/hy-goal.c              | 32 ++------------------------------
 tests/hawkey/test_goal.c      | 22 ----------------------
 3 files changed, 2 insertions(+), 54 deletions(-)

diff --git a/data/tests/hawkey/greedy.repo b/data/tests/hawkey/greedy.repo
index d450885..64bb85a 100644
--- a/data/tests/hawkey/greedy.repo
+++ b/data/tests/hawkey/greedy.repo
@@ -5,7 +5,5 @@
 =Pkg: B 1 0 noarch
 =Rec: C
 =Prv: somereq
-=Obs: somereq
 =Pkg: C 1 0 noarch
 =Prv: somereq
-=Pkg: somereq 1 0 noarch
diff --git a/libdnf/hy-goal.c b/libdnf/hy-goal.c
index dc05c1c..3ff1ce6 100644
--- a/libdnf/hy-goal.c
+++ b/libdnf/hy-goal.c
@@ -550,34 +550,6 @@ filter_name2job(DnfSack *sack, const struct _Filter *f, Queue *job)
     return 0;
 }
 
-/**
- * add_preferred_provide:
- * when searching by provides the packages that contain the same
- * name as provide or contain obsoletes with the same name as their
- * provide will be picked first
- */
-static void
-add_preferred_provide(DnfSack *sack, Queue *job, Id id)
-{
-    Pool *pool = dnf_sack_get_pool(sack);
-    const char *name = pool_dep2str(pool, id);
-    HyQuery q = hy_query_create(sack);
-    hy_query_filter(q, HY_PKG_NAME, HY_NEQ, name);
-    DnfPackageSet *pset = hy_query_run_set(q);
-    hy_query_filter(q, HY_PKG_PROVIDES, HY_EQ, name);
-    hy_query_filter_package_in(q, HY_PKG_OBSOLETES, HY_NEQ, pset);
-    DnfPackage *pkg;
-    g_autoptr(GPtrArray) plist = hy_query_run(q);
-    for (guint i = 0; i < plist->len; i++) {
-        pkg = g_ptr_array_index(plist, i);
-        queue_push2(job, SOLVER_DISFAVOR|SOLVER_SOLVABLE,
-                    dnf_package_get_id(pkg));
-    }
-    queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
-    hy_query_free(q);
-    g_object_unref(pset);
-}
-
 static int
 filter_provides2job(DnfSack *sack, const struct _Filter *f, Queue *job)
 {
@@ -593,7 +565,7 @@ filter_provides2job(DnfSack *sack, const struct _Filter *f, Queue *job)
     switch (f->cmp_type) {
     case HY_EQ:
         id = dnf_reldep_get_id (f->matches[0].reldep);
-        add_preferred_provide(sack, job, id);
+        queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
         break;
     case HY_GLOB:
         dataiterator_init(&di, pool, 0, 0, SOLVABLE_PROVIDES, name, SEARCH_GLOB);
@@ -604,7 +576,7 @@ filter_provides2job(DnfSack *sack, const struct _Filter *f, Queue *job)
         assert(di.idp);
         id = *di.idp;
         if (!job_has(job, SOLVABLE_PROVIDES, id))
-            add_preferred_provide(sack, job, id);
+            queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
         dataiterator_free(&di);
         break;
     default:
diff --git a/tests/hawkey/test_goal.c b/tests/hawkey/test_goal.c
index 7c30097..2a98983 100644
--- a/tests/hawkey/test_goal.c
+++ b/tests/hawkey/test_goal.c
@@ -230,27 +230,6 @@ START_TEST(test_goal_install_selector)
 }
 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);
-}
-END_TEST
-
 START_TEST(test_goal_install_selector_err)
 {
     int rc;
@@ -1456,7 +1435,6 @@ goal_suite(void)
     tc = tcase_create("Greedy");
     tcase_add_unchecked_fixture(tc, fixture_greedy_only, teardown);
     tcase_add_test(tc, test_goal_run_all);
-    tcase_add_test(tc, test_goal_install_selector_obsoletes_first);
     tcase_add_test(tc, test_goal_install_weak_deps);
     suite_add_tcase(s, tc);
 
-- 
1.8.3.1