Clean up main loop
Greatly reduce duplication by moving common code into a method. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
0a44b2fd07
commit
3a6653fbc2
@ -15,6 +15,7 @@
|
|||||||
# along with this program; if not, see <https://gnu.org/licenses/>.
|
# along with this program; if not, see <https://gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from itertools import count
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import hawkey
|
import hawkey
|
||||||
@ -705,66 +706,47 @@ class Gather(GatherBase):
|
|||||||
added = self.add_initial_packages(pattern_list)
|
added = self.add_initial_packages(pattern_list)
|
||||||
self._add_packages(added)
|
self._add_packages(added)
|
||||||
|
|
||||||
self.logger.debug("PREPOPULATE")
|
added = self.log_count('PREPOPULATE', self.add_prepopulate_packages)
|
||||||
added = self.add_prepopulate_packages()
|
|
||||||
self._add_packages(added)
|
self._add_packages(added)
|
||||||
|
|
||||||
pass_num = 0
|
for pass_num in count(1):
|
||||||
added = False
|
|
||||||
while 1:
|
|
||||||
if pass_num > 0 and not added:
|
|
||||||
break
|
|
||||||
pass_num += 1
|
|
||||||
self.logger.debug("PASS %s" % pass_num)
|
self.logger.debug("PASS %s" % pass_num)
|
||||||
|
|
||||||
self.logger.debug("DEPS")
|
if self.log_count('CONDITIONAL DEPS', self.add_conditional_packages):
|
||||||
added = self.add_conditional_packages()
|
|
||||||
self.logger.debug("ADDED: %s" % bool(added))
|
|
||||||
if added:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# resolve deps
|
# resolve deps
|
||||||
self.logger.debug("DEPS")
|
if self.log_count('BINARY DEPS', self.add_binary_package_deps):
|
||||||
added = self.add_binary_package_deps()
|
|
||||||
self.logger.debug("ADDED: %s" % bool(added))
|
|
||||||
if added:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
added = self.add_source_package_deps()
|
if self.log_count('SOURCE DEPS', self.add_source_package_deps):
|
||||||
self.logger.debug("ADDED: %s" % bool(added))
|
|
||||||
if added:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.logger.debug("SOURCE PACKAGES")
|
if self.log_count('SOURCE PACKAGES', self.add_source_packages):
|
||||||
added = self.add_source_packages()
|
|
||||||
self.logger.debug("ADDED: %s" % bool(added))
|
|
||||||
if added:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.logger.debug("DEBUG PACKAGES")
|
if self.log_count('DEBUG PACKAGES', self.add_debug_packages):
|
||||||
added = self.add_debug_packages()
|
|
||||||
self.logger.debug("ADDED: %s" % bool(added))
|
|
||||||
if added:
|
|
||||||
continue
|
continue
|
||||||
# TODO: debug deps
|
# TODO: debug deps
|
||||||
|
|
||||||
self.logger.debug("FULLTREE")
|
if self.log_count('FULLTREE', self.add_fulltree_packages):
|
||||||
added = self.add_fulltree_packages()
|
|
||||||
self.logger.debug("ADDED: %s" % bool(added))
|
|
||||||
if added:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.logger.debug("LANGPACKS")
|
if self.log_count('LANGPACKS', self.add_langpack_packages, self.opts.langpacks):
|
||||||
added = self.add_langpack_packages(self.opts.langpacks)
|
|
||||||
self.logger.debug("ADDED: %s" % bool(added))
|
|
||||||
if added:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.logger.debug("MULTILIB")
|
if self.log_count('MULTILIB', self.add_multilib_packages):
|
||||||
added = self.add_multilib_packages()
|
|
||||||
self.logger.debug("ADDED: %s" % bool(added))
|
|
||||||
if added:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# nothing added -> break depsolving cycle
|
# nothing added -> break depsolving cycle
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def log_count(self, msg, method, *args):
|
||||||
|
"""
|
||||||
|
Print a message, run the function with given arguments and log length
|
||||||
|
of result.
|
||||||
|
"""
|
||||||
|
self.logger.debug('%s', msg)
|
||||||
|
added = method(*args)
|
||||||
|
self.logger.debug('ADDED: %s', len(added))
|
||||||
|
return added
|
||||||
|
Loading…
Reference in New Issue
Block a user