Skip to content

Commit 65cc2ad

Browse files
m-blahaj-mracek
authored andcommitted
Move Goal class from dnf to libdnf/hawkey
1 parent ad27f5c commit 65cc2ad

File tree

2 files changed

+2
-48
lines changed

2 files changed

+2
-48
lines changed

dnf/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import dnf.rpm.miscutils
5353
import dnf.rpm.transaction
5454
import dnf.sack
55+
import dnf.selector
5556
import dnf.subject
5657
import dnf.transaction
5758
import dnf.util

dnf/goal.py

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,5 @@
2020

2121
from __future__ import absolute_import
2222
from __future__ import unicode_literals
23-
from copy import deepcopy
24-
from dnf.i18n import _
25-
import logging
26-
import hawkey
27-
from dnf.db.types import SwdbReason
2823

29-
logger = logging.getLogger('dnf')
30-
31-
class Goal(hawkey.Goal):
32-
def __init__(self, sack):
33-
super(Goal, self).__init__(sack)
34-
self.group_members = set()
35-
self._installs = []
36-
37-
def get_reason(self, pkg):
38-
code = super(Goal, self).get_reason(pkg)
39-
if code == hawkey.REASON_USER and pkg.name in self.group_members:
40-
return SwdbReason.GROUP
41-
return SwdbReason(code)
42-
43-
def group_reason(self, pkg, current_reason):
44-
if current_reason == SwdbReason.UNKNOWN and pkg.name in self.group_members:
45-
return SwdbReason.GROUP
46-
return current_reason
47-
48-
def install(self, *args, **kwargs):
49-
if args:
50-
self._installs.extend(args)
51-
if 'select' in kwargs:
52-
self._installs.extend(kwargs['select'].matches())
53-
return super(Goal, self).install(*args, **kwargs)
54-
55-
def push_userinstalled(self, query, history):
56-
msg = _('--> Finding unneeded leftover dependencies')
57-
logger.debug(msg)
58-
pkgs = query.installed()
59-
60-
# get only user installed packages
61-
user_installed = history.select_user_installed(pkgs)
62-
63-
for pkg in user_installed:
64-
self.userinstalled(pkg)
65-
66-
def available_updates_diff(self, query):
67-
available_updates = set(query.upgrades().filter(arch__neq="src")
68-
.latest().run())
69-
installable_updates = set(self.list_upgrades())
70-
installs = set(self.list_installs())
71-
return (available_updates - installable_updates) - installs
24+
from hawkey import Goal

0 commit comments

Comments
 (0)