executable-hash 0.2.0.0 → 0.2.0.1
raw patch · 5 files changed
+22/−11 lines, 5 filessetup-changedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +5/−3
- Setup.hs +5/−3
- System/Executable/Hash.hs +5/−3
- System/Executable/Hash/Internal.hs +6/−1
- executable-hash.cabal +1/−1
README.md view
@@ -23,13 +23,15 @@ `build-type: Custom` in your `.cabal`: ```haskell-import Distribution.Simple+import Distribution.Simple (defaultMainWithHooks, simpleUserHooks, postBuild)+import Distribution.Simple.LocalBuildInfo (buildDir) import System.Executable.Hash.Internal (maybeInjectExecutableHash)+import System.FilePath ((</>)) main :: IO () main = defaultMainWithHooks $ simpleUserHooks- { postBuild = \_ _ _ _ ->- maybeInjectExecutableHash "dist/build/path-to/your-executable"+ { postBuild = \_ _ _ buildInfo ->+ maybeInjectExecutableHash (buildDir buildInfo </> "exeName/exeName") } ```
Setup.hs view
@@ -1,8 +1,10 @@-import Distribution.Simple+import Distribution.Simple (defaultMainWithHooks, simpleUserHooks, postBuild)+import Distribution.Simple.LocalBuildInfo (buildDir) import System.Executable.Hash.Internal (maybeInjectExecutableHash)+import System.FilePath ((</>)) main :: IO () main = defaultMainWithHooks $ simpleUserHooks- { postBuild = \_ _ _ _ ->- maybeInjectExecutableHash "dist/build/test-inject/test-inject"+ { postBuild = \_ _ _ buildInfo ->+ maybeInjectExecutableHash (buildDir buildInfo </> "test-inject/test-inject") }
System/Executable/Hash.hs view
@@ -10,13 +10,15 @@ -- your @Setup.hs@: -- -- @--- import Distribution.Simple+-- import Distribution.Simple (defaultMainWithHooks, simpleUserHooks, postBuild)+-- import Distribution.Simple.LocalBuildInfo (buildDir) -- import System.Executable.Hash.Internal (maybeInjectExecutableHash)+-- import System.FilePath ((</>)) -- -- main :: IO () -- main = defaultMainWithHooks $ simpleUserHooks--- { postBuild = \_ _ _ _ ->--- maybeInjectExecutableHash "dist\/build\/path-to\/your-executable"+-- { postBuild = \_ _ _ buildInfo ->+-- maybeInjectExecutableHash (buildDir buildInfo </> "exeName\/exeName") -- } -- @ --
System/Executable/Hash/Internal.hs view
@@ -5,6 +5,7 @@ -- hash. module System.Executable.Hash.Internal where +import Control.Exception (SomeException, handle) import Crypto.Hash.SHA1 (hash) import qualified Data.ByteString as BS import Data.FileEmbed (dummySpaceWith, injectWith)@@ -33,7 +34,7 @@ -- See the documentation in "System.Executable.Hash" for an example of -- how to use this with a cabal @postBuild@ hook injectExecutableHash :: FilePath -> IO ()-injectExecutableHash fp = do+injectExecutableHash fp = handle addPathToException $ do binary <- BS.readFile fp let sha1 = hash binary case injectWith "executable-hash" sha1 binary of@@ -41,6 +42,10 @@ Just binary' -> do BS.writeFile fp binary' putStrLn $ "Successfully wrote " ++ fp ++ " with injected hash."+ where+ addPathToException ex = fail $+ "While injecting hash into " ++ fp +++ ", the following exception occurred: " ++ show (ex :: SomeException) -- | Injects an executable hash into the specified binary. If it -- doesn't exist, then this prints a message to stdout indicating that
executable-hash.cabal view
@@ -1,5 +1,5 @@ name: executable-hash-version: 0.2.0.0+version: 0.2.0.1 synopsis: Provides the SHA1 hash of the program executable description: See README.md homepage: https://github.com/fpco/executable-hash