From 57b3e462a4683b69df6fb636e0e92bfa50c62521 Mon Sep 17 00:00:00 2001 From: Tim Lauridsen Date: Mon, 14 Jun 2021 09:39:32 +0200 Subject: [PATCH 1/2] Don't return Weak dependencies in updates --- python/dnfdaemon/server/backend.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/dnfdaemon/server/backend.py b/python/dnfdaemon/server/backend.py index bf9a95a..fc6ce66 100644 --- a/python/dnfdaemon/server/backend.py +++ b/python/dnfdaemon/server/backend.py @@ -38,6 +38,7 @@ import sys import re import os +import libdnf.transaction logger = logging.getLogger('dnfdaemon.base.dnf') @@ -368,12 +369,14 @@ 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 - pkgs.append(tsi.pkg) + # skip weak dependencies + if not tsi.reason == libdnf.transaction.TransactionItemReason_WEAK_DEPENDENCY: + # action is INSTALL, then it should be a installonlypkg + pkgs.append(tsi.pkg) return pkgs @property From f6f4400b16b5cc7529bda16ecd3b402c098bab4e Mon Sep 17 00:00:00 2001 From: Tim Lauridsen Date: Wed, 16 Jun 2021 06:50:09 +0200 Subject: [PATCH 2/2] Don't return dependencies in updates --- python/dnfdaemon/server/backend.py | 72 +++++++++++++++--------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/python/dnfdaemon/server/backend.py b/python/dnfdaemon/server/backend.py index fc6ce66..6d9c8bf 100644 --- a/python/dnfdaemon/server/backend.py +++ b/python/dnfdaemon/server/backend.py @@ -72,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""" @@ -164,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. @@ -250,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 @@ -373,10 +373,12 @@ def updates(self): if tsi.action == dnf.transaction.PKG_UPGRADE: pkgs.append(tsi.pkg) elif tsi.action == dnf.transaction.PKG_INSTALL: - # skip weak dependencies - if not tsi.reason == libdnf.transaction.TransactionItemReason_WEAK_DEPENDENCY: - # action is INSTALL, then it should be a installonlypkg - pkgs.append(tsi.pkg) + # 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 @property