From 1c6b08326000359ee57fba3962a063b8744a0c9a Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 26 May 2017 16:38:26 -0700 Subject: [PATCH] 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 --- src/pylorax/ltmpl.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py index 128fb7c4..37877e61 100644 --- a/src/pylorax/ltmpl.py +++ b/src/pylorax/ltmpl.py @@ -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