module Main (main) where import Control.Monad import System.Process import System.Exit import Distribution.Simple import Distribution.PackageDescription import Distribution.Package import Distribution.Simple.Configure main :: IO () main = defaultMainWithHooks defaultUserHooks { buildHook = myBuildHook, preClean = disabledCmd, preSDist = disabledCmd, preHaddock = disabledCmd, prePFE = disabledCmd } myBuildHook pd lbi verb ppshs = do let pkg = pkgName $ package pd ver = showVersion $ pkgVersion $ package pd loc = buildDir lbi mkcmd = "make build PKG=" ++ pkg ++ " VER=" ++ ver ++ " LOC=" ++ loc when (verb > 0) $ putStrLn $ "Running command:" ++ mkcmd ec <- runCommand mkcmd >>= waitForProcess when (verb > 0) $ putStrLn $ "Command exit code: " ++ (show ec) return () disabledCmd :: Args -> a -> IO HookedBuildInfo disabledCmd _ _ = do putStrLn "This command is disabled for this package" exitWith (ExitFailure 1) return emptyHookedBuildInfo