From a66a129b29d59a6563afeeb3776b6beca87bf533 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Thu, 2 Apr 2020 15:34:27 -0700 Subject: [PATCH] Make sure all DNF errors are printed In addition to printing a summary of unresolvable package names whenever DNF fails, also print error messages for any "unknown" DNF error, and finally print the full stdout/stderr from failed DNF commands for later inspection. Signed-off-by: Patrick McCarty --- builder/bundles.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/builder/bundles.go b/builder/bundles.go index 09c1aaf..9f5642b 100644 --- a/builder/bundles.go +++ b/builder/bundles.go @@ -243,7 +243,11 @@ func parseNoopInstall(installOut string) ([]packageMetadata, error) { } } } - return nil, fmt.Errorf("unable to resolve package(s): %s", pkgs) + if len(pkgs) > 0 { + return nil, fmt.Errorf("unable to resolve package(s): %s", pkgs) + } else { + return nil, fmt.Errorf("dnf error occurred") + } } pkgList := strings.Split(parts[1], "\nTransaction Summary")[0] @@ -367,16 +371,19 @@ func resolvePackagesWithOptions(numWorkers int, set bundleSet, packagerCmd []str queryString = append(queryString, p) } bundle.AllRpms = make(map[string]packageMetadata) - // ignore error from the --assumeno install. It is an error every time because - // --assumeno forces the install command to "abort" and return a non-zero exit - // status. This exit status is 1, which is the same as any other dnf install - // error. Fortunately if this is a different error than we expect, it should - // fail in the actual install to the full chroot. - outBuf, _ := helpers.RunCommandOutputEnv(queryString[0], queryString[1:], []string{"LC_ALL=en_US.UTF-8"}) + // Ignore error from the --assumeno install, but save the output for later + // printing, in case the output indicates an error. An error is returned every + // time because --assumeno forces the command to "abort" and return a non-zero + // exit status. This exit status is 1, which is the same as any other dnf install + // error. Fortunately if this is a different error than we expect, it should fail + // in the actual install to the full chroot. + outBuf, errStr := helpers.RunCommandOutputEnv(queryString[0], queryString[1:], []string{"LC_ALL=en_US.UTF-8"}) rpm, e := repoPkgFromNoopInstall(outBuf.String()) if len(bundle.AllPackages) != 0 && e != nil { e = errors.Wrapf(e, bundle.Name) fmt.Println(e) + fmt.Println("error details:") + fmt.Println(errStr) errorCh <- e return }