summaryrefslogtreecommitdiff
path: root/Utility/Gpg.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-19 17:59:58 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-19 17:59:58 -0400
commitb1e0c707bcf4e281d0bfefa06effc9b3fcb3f92e (patch)
tree6402758cfcea96e53203cd4ef4be9a45735aad6b /Utility/Gpg.hs
parent1b028411570973f4a18ce155c080161084952e87 (diff)
Allow building with gpg2.
Diffstat (limited to 'Utility/Gpg.hs')
-rw-r--r--Utility/Gpg.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Utility/Gpg.hs b/Utility/Gpg.hs
index aa4a7af73..33a26e272 100644
--- a/Utility/Gpg.hs
+++ b/Utility/Gpg.hs
@@ -17,10 +17,16 @@ import System.Path
import Common
import Utility.Env
+import qualified Build.SysConfig as SysConfig
newtype KeyIds = KeyIds [String]
deriving (Ord, Eq)
+{- If a specific gpg command was found at configure time, use it.
+ - Otherwise, try to run gpg. -}
+gpgcmd :: FilePath
+gpgcmd = fromMaybe "gpg" SysConfig.gpg
+
stdParams :: [CommandParam] -> IO [String]
stdParams params = do
#ifndef __WINDOWS__
@@ -44,7 +50,7 @@ stdParams params = do
readStrict :: [CommandParam] -> IO String
readStrict params = do
params' <- stdParams params
- withHandle StdoutHandle createProcessSuccess (proc "gpg" params') $ \h -> do
+ withHandle StdoutHandle createProcessSuccess (proc gpgcmd params') $ \h -> do
hSetBinaryMode h True
hGetContentsStrict h
@@ -53,7 +59,7 @@ readStrict params = do
pipeStrict :: [CommandParam] -> String -> IO String
pipeStrict params input = do
params' <- stdParams params
- withBothHandles createProcessSuccess (proc "gpg" params') $ \(to, from) -> do
+ withBothHandles createProcessSuccess (proc gpgcmd params') $ \(to, from) -> do
hSetBinaryMode to True
hSetBinaryMode from True
hPutStr to input
@@ -84,7 +90,7 @@ feedRead params passphrase feeder reader = do
params' <- stdParams $ [Param "--batch"] ++ passphrasefd ++ params
closeFd frompipe `after`
- withBothHandles createProcessSuccess (proc "gpg" params') go
+ withBothHandles createProcessSuccess (proc gpgcmd params') go
where
go (to, from) = do
void $ forkIO $ do