configure: Check that checksum programs produce correct checksums. + bitter rant

So, it might be called sha1sum, or on some other OS, it might be called
sha1. It might be hidden away off of PATH on that OS. That's just expected
insanity; UNIX has been this way since 1980's. And these days, nobody even
gives the flying flip about standards that we briefly did in the 90's
after the first round of unix wars.

But it's the 2010's now, and we've certainly learned something.
So, let's make it so sometimes sha1 is a crazy program that wants to run as
root so it can lock memory while prompting for a passphrase, and outputting
binary garbage. Yes, that'd be wise. Let's package that in major Linux
distros, too, so users can stumble over it.
This commit is contained in:
Joey Hess 2012-10-25 00:05:12 -04:00
parent e36e54884e
commit 9cdbfa764e
4 changed files with 37 additions and 15 deletions

View file

@ -75,7 +75,7 @@ testCmd k cmdline = do
{- Ensures that one of a set of commands is available by running each in
- turn. The Config is set to the first one found. -}
selectCmd :: ConfigKey -> [String] -> String -> Test
selectCmd :: ConfigKey -> [(String, String)] -> Test
selectCmd k = searchCmd
(return . Config k . StringConfig)
(\cmds -> do
@ -83,17 +83,17 @@ selectCmd k = searchCmd
error $ "* need one of these commands, but none are available: " ++ show cmds
)
maybeSelectCmd :: ConfigKey -> [String] -> String -> Test
maybeSelectCmd :: ConfigKey -> [(String, String)] -> Test
maybeSelectCmd k = searchCmd
(return . Config k . MaybeStringConfig . Just)
(\_ -> return $ Config k $ MaybeStringConfig Nothing)
searchCmd :: (String -> Test) -> ([String] -> Test) -> [String] -> String -> Test
searchCmd success failure cmds param = search cmds
searchCmd :: (String -> Test) -> ([String] -> Test) -> [(String, String)] -> Test
searchCmd success failure cmdsparams = search cmdsparams
where
search [] = failure cmds
search (c:cs) = do
ret <- system $ quiet c ++ " " ++ param
search [] = failure $ fst $ unzip cmdsparams
search ((c, params):cs) = do
ret <- system $ quiet $ c ++ " " ++ params
if ret == ExitSuccess
then success c
else search cs