diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/DotDir.hs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/Propellor/DotDir.hs b/src/Propellor/DotDir.hs index 4f27788d..669ac303 100644 --- a/src/Propellor/DotDir.hs +++ b/src/Propellor/DotDir.hs @@ -1,4 +1,9 @@ -module Propellor.DotDir where +module Propellor.DotDir + ( distrepo + , dotPropellor + , interactiveInit + , checkRepoUpToDate + ) where import Propellor.Message import Propellor.Bootstrap @@ -66,6 +71,23 @@ interactiveInit = ifM (doesDirectoryExist =<< dotPropellor) setup ) +-- | Determine whether we need to create a cabal sandbox in ~/.propellor/, +-- which we do if the user has configured cabal to require a sandbox, and the +-- build system is cabal. +cabalSandboxRequired :: IO Bool +cabalSandboxRequired = ifM cabal + ( do + home <- myHomeDir + ls <- lines <$> catchDefaultIO [] + (readFile (home </> ".cabal" </> "config")) + -- For simplicity, we assume a sane ~/.cabal/config here: + return $ any ("True" `isInfixOf`) $ + filter ("require-sandbox:" `isPrefixOf`) ls + , return False + ) + where + cabal = buildSystem >>= \bSystem -> return (bSystem == "cabal") + say :: String -> IO () say = outputConcurrent @@ -115,7 +137,7 @@ setup :: IO () setup = do sayLn "Propellor's configuration file is ~/.propellor/config.hs" sayLn "" - sayLn "Lets get you started with a simple config that you can adapt" + sayLn "Let's get you started with a simple config that you can adapt" sayLn "to your needs. You can start with:" sayLn " A: A clone of propellor's git repository (most flexible)" sayLn " B: The bare minimum files to use propellor (most simple)" @@ -134,6 +156,13 @@ setup = do , Param "propellor.buildsystem" , Param b ] + ifM cabalSandboxRequired + ( void $ boolSystem "cabal" + [ Param "sandbox" + , Param "init" + ] + , return () + ) buildPropellor Nothing sayLn "" sayLn "Great! Propellor is bootstrapped." |
