ghc-package.eclass: Handle missing ghc in lookups
authorBenjamin Gordon <bmgordon@chromium.org>
Wed, 29 Jan 2020 19:38:13 +0000 (12:38 -0700)
committerSergei Trofimovich <slyfox@gentoo.org>
Wed, 29 Jan 2020 22:04:46 +0000 (22:04 +0000)
ghc-getghc() and ghc-getghcpkg() both assume that they can find an
installed binary.  If ghc isn't installed (e.g., because it's being
being rebuilt or has been unmerged), there is no such binary. This
causes the intended arguments to be run as a command, which produces
"command not found" QA Notices.

If ghc can't be found, return "false" instead.  The false command will
harmlessly absorb the other command-line arguments.  This doesn't
produce any difference in the final result because the invalid commands
were failing anyway.

Closes: https://bugs.gentoo.org/683144
Signed-off-by: Benjamin Gordon <bmgordon@chromium.org>
Closes: https://github.com/gentoo/gentoo/pull/14499
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
eclass/ghc-package.eclass

index 27fafff5a21b2f27875dec073803d054f3df180c..dbe7dc2a5acdb29948121ca28848c07f908392ab 100644 (file)
@@ -22,14 +22,20 @@ esac
 # @DESCRIPTION:
 # returns the name of the ghc executable
 ghc-getghc() {
-       type -P ${HC:-ghc}
+       if ! type -P ${HC:-ghc}; then
+               ewarn "ghc not found"
+               type -P false
+       fi
 }
 
 # @FUNCTION: ghc-getghcpkg
 # @DESCRIPTION:
 # Internal function determines returns the name of the ghc-pkg executable
 ghc-getghcpkg() {
-       type -P ${HC_PKG:-ghc-pkg}
+       if ! type -P ${HC_PKG:-ghc-pkg}; then
+               ewarn "ghc-pkg not found"
+               type -P false
+       fi
 }
 
 # @FUNCTION: ghc-getghcpkgbin