summaryrefslogtreecommitdiff
path: root/Build/Configure.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-08 11:17:09 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-08 11:17:09 -0400
commitff6b397dab5cac810061c386c28fa87e7b2b420b (patch)
treec7ac7985c9a505995a799620fd757c4b32942c24 /Build/Configure.hs
parent2578c950fc47d3edfd30375d91e0d415c4f32be0 (diff)
configure: Better checking that sha commands output in the desired format.
Run the same code git-annex used to get the sha, including its sanity checking. Much better than old grep. Should detect FreeBSD systems with sha commands that output in stange format.
Diffstat (limited to 'Build/Configure.hs')
-rw-r--r--Build/Configure.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/Build/Configure.hs b/Build/Configure.hs
index d89c206d5..46a3a2452 100644
--- a/Build/Configure.hs
+++ b/Build/Configure.hs
@@ -14,6 +14,7 @@ import Build.TestConfig
import Utility.SafeCommand
import Utility.Monad
import Utility.Exception
+import Utility.ExternalSHA
tests :: [TestCase]
tests =
@@ -45,17 +46,24 @@ tests =
- On some systems, shaN is used instead, but on other
- systems, it might be "hashalot", which does not produce
- usable checksums. Only accept programs that produce
- - known-good hashes. -}
+ - known-good hashes when run on files. -}
shaTestCases :: [(Int, String)] -> [TestCase]
shaTestCases l = map make l
where
- make (n, knowngood) = TestCase key $ maybeSelectCmd key $
- zip (shacmds n) (repeat check)
+ make (n, knowngood) = TestCase key $
+ Config key . MaybeStringConfig <$> search (shacmds n)
where
key = "sha" ++ show n
- check = "</dev/null 2>/dev/null | grep -q '" ++ knowngood ++ "'"
+ search [] = return Nothing
+ search (c:cmds) = do
+ sha <- externalSHA c n "/dev/null"
+ if sha == Right knowngood
+ then return $ Just c
+ else search cmds
+
shacmds n = concatMap (\x -> [x, 'g':x, osxpath </> x]) $
map (\x -> "sha" ++ show n ++ x) ["sum", ""]
+
{- Max OSX sometimes puts GNU tools outside PATH, so look in
- the location it uses, and remember where to run them
- from. -}