Skip to content

Don't return Weak dependencies in updates #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 37 additions & 32 deletions python/dnfdaemon/server/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import sys
import re
import os
import libdnf.transaction

logger = logging.getLogger('dnfdaemon.base.dnf')

Expand Down Expand Up @@ -71,38 +72,38 @@ def __init__(self, parent):
self._packages = None

def _tree(self, dirpath):
"""Traverse dirpath recursively and yield relative filenames."""
for root, dirs, files in os.walk(dirpath):
base = os.path.relpath(root, dirpath)
for f in files:
path = os.path.join(base, f)
yield os.path.normpath(path)
"""Traverse dirpath recursively and yield relative filenames."""
for root, dirs, files in os.walk(dirpath):
base = os.path.relpath(root, dirpath)
for f in files:
path = os.path.join(base, f)
yield os.path.normpath(path)

def _filter(self, files, patterns):
"""Yield those filenames that match any of the patterns."""
return (f for f in files for p in patterns if re.match(p, f))
"""Yield those filenames that match any of the patterns."""
return (f for f in files for p in patterns if re.match(p, f))

def _clean(self, dirpath, files):
"""Remove the given filenames from dirpath."""
count = 0
for f in files:
path = os.path.join(dirpath, f)
logger.debug(_('Removing file %s'), path)
misc.unlink_f(path)
count += 1
return count
"""Remove the given filenames from dirpath."""
count = 0
for f in files:
path = os.path.join(dirpath, f)
logger.debug(_('Removing file %s'), path)
misc.unlink_f(path)
count += 1
return count

def _removeCacheFiles(self):
''' Remove solv and xml files '''
cachedir = self.conf.cachedir
''' Remove solv and xml files '''
cachedir = self.conf.cachedir

types = [ 'metadata', 'packages', 'dbcache' ]
files = list(self._tree(cachedir))
logger.debug(_('Cleaning data: ' + ' '.join(types)))
types = ['metadata', 'packages', 'dbcache']
files = list(self._tree(cachedir))
logger.debug(_('Cleaning data: ' + ' '.join(types)))

patterns = [dnf.repo.CACHE_FILES[t] for t in types]
count = self._clean(cachedir, self. _filter(files, patterns))
logger.info( '%d file removed', count)
patterns = [dnf.repo.CACHE_FILES[t] for t in types]
count = self._clean(cachedir, self._filter(files, patterns))
logger.info('%d file removed', count)

def expire_cache(self):
"""Make the current cache expire"""
Expand Down Expand Up @@ -163,12 +164,12 @@ def contains(self, attr, needle, ignore_case=True):
else:
return self.sack.query().filter(**fdict)

###############################################################################
# code copied from dnf for non public API related
#
# FIXME: this is copied from dnf/base.py, because there is no public
# API to handle gpg signatures.
###############################################################################
###############################################################################
# code copied from dnf for non public API related
#
# FIXME: this is copied from dnf/base.py, because there is no public
# API to handle gpg signatures.
###############################################################################
def _sig_check_pkg(self, po):
"""Verify the GPG signature of the given package object.

Expand Down Expand Up @@ -249,7 +250,7 @@ def _get_key_for_package(self, po, askcb=None, fullaskcb=None):
def _prov_key_data(msg):
msg += _('Failing package is: %s') % (po) + '\n '
msg += _('GPG Keys are configured as: %s') % \
(', '.join(repo.gpgkey) + '\n')
(', '.join(repo.gpgkey) + '\n')
return '\n\n\n' + msg

user_cb_fail = False
Expand Down Expand Up @@ -368,11 +369,15 @@ def updates(self):
return pkgs
# return install/upgrade type pkgs from transaction
for tsi in self._base.transaction:
#print(tsi.op_type, tsi.installed, tsi.erased, tsi.obsoleted)
logger.debug(f" --> {tsi.action_name} : {tsi} action: {tsi.action} reason: {tsi.reason}")
if tsi.action == dnf.transaction.PKG_UPGRADE:
pkgs.append(tsi.pkg)
elif tsi.action == dnf.transaction.PKG_INSTALL:
# action is INSTALL, then it should be a installonlypkg
# skip dependencies (direct & real)
if tsi.reason == libdnf.transaction.TransactionItemReason_WEAK_DEPENDENCY or \
tsi.reason == libdnf.transaction.TransactionItemReason_DEPENDENCY:
continue
pkgs.append(tsi.pkg)
return pkgs

Expand Down