Try all packages when installpkg --optional is used.

Also sort the expanded list of packages so that any failures will
be consistent instead of depending on the randomness of a set().
And add better logging when things fail.

The core issue is that repodata may have packages that match globs, but
they cannot actually be installed (eg. sigrok-firmware). This can cause
*some* of the globbed packages to be installed before hitting the
failure package.

With this change it will log the expanded list of packages if a glob is
used. It will skip any packages that fail to install when using
--optional with the glob, and continue to install the rest.

Related: rhbz#1440417
This commit is contained in:
Brian C. Lane 2017-05-26 16:38:26 -07:00
parent 33308c227c
commit 1c6b083260

View File

@ -570,8 +570,21 @@ class LoraxTemplateRunner(object):
for exclude in excludes:
pkgnames = {pkgname for pkgname in pkgnames if not fnmatch.fnmatch(pkgname, exclude)}
# Sort the results so that we have consistent results
pkgnames = sorted(pkgnames)
# If the request is a glob, expand it in the log
if any(g for g in ['*','?','.'] if g in p):
logger.info("installpkg: %s expands to %s", p, ",".join(pkgnames))
for pkgname in pkgnames:
self.dbo.install(pkgname)
try:
self.dbo.install(pkgname)
except Exception as e: # pylint: disable=broad-except
if required:
raise
# Not required, log it and continue processing pkgs
logger.error("installpkg %s failed: %s", pkgname, str(e))
except Exception as e: # pylint: disable=broad-except
logger.error("installpkg %s failed: %s", p, str(e))
errors = True