{-# LANGUAGE CPP #-} -- | -- Module : Seqaid.Demo -- Copyright : (c) 2014, Andrew G. Seniuk -- License : BSD-style (see the file LICENSE) -- -- Maintainer : Andrew Seniuk -- Stability : provisional -- Portability : POSIX, Cabal -- -- Instrument a sample program (package -- ) -- with dynamic forcing functions. Refer to -- -- for more information about this methodology. module Main ( main ) where --module Seqaid.Demo ( main ) where import System.Environment ( getArgs ) import System.IO.Temp import System.Directory import System.Process import System.Exit import Paths_seqaid import Data.Version import Data.List ( intercalate ) leaky_version = (intercalate "." $ map show $ take 3 $ versionBranch version) ++ ".0" --leaky_version = "0.1.6.0" -- XXX need a better way!!.... main :: IO ExitCode main = do -- putStrLn $ leaky_version -- error "DEVEXIT" args <- getArgs if args /= ["demo"] then do putStrLn "seqaid: \"seqaid demo\" is the only supported invocation at this time." return $ ExitFailure 1 else do tdir <- createTempDirectory "." "leaky_" -- XXX Note that "cabal get" already extracts the tarball for you. #if IS_WINDOWS let shebang_line = "@echo off\n" #else let shebang_line = "#!/bin/bash\nset -e\n" #endif let seqaid_init_bash = shebang_line ++ "\ \cabal get leaky-" ++ leaky_version ++ "\n\ \cd leaky-" ++ leaky_version ++ "\n\ \cabal configure\n\ \cabal build\n\ \cabal run 123\n\ #if IS_WINDOWS \echo.\n\ #else \echo\n\ #endif \echo \"(Please see " ++ tdir ++ "/leaky-" ++ leaky_version ++ "/README for the interpretation.)\"\n\ #if IS_WINDOWS \echo.\n" #else \echo\n" #endif setCurrentDirectory tdir writeFile "seqaidinit.sh" seqaid_init_bash p <- getPermissions "seqaidinit.sh" setPermissions "seqaidinit.sh" (p { executable = True }) st <- system "./seqaidinit.sh" case st of ExitSuccess -> return ExitSuccess ExitFailure n -> do putStrLn $ "Sorry, seqaid demo had a problem (status=" ++ show st ++ ").\nPlease report this bug to rasfar@gmail.com" return $ ExitFailure 2 _ -> error $ "unexpected ExitCode = " ++ show st ++ "\nPlease report this bug to rasfar@gmail.com"