summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoey Hess2015-04-02 10:26:51 -0400
committerJoey Hess2015-04-02 10:26:51 -0400
commit006b1c35854c134cbdf33303836c2461322ed463 (patch)
tree223b7281c3b0f5b3c86c141591accf4f610467f5 /src
parent3cbabe3f765b7e11db32992a5c9a349fc19d0858 (diff)
parent1413e9c61970532b846893ca6435f2a2785a1b02 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/Bootstrap.hs21
-rw-r--r--src/Propellor/CmdLine.hs3
-rw-r--r--src/Propellor/Property/Cron.hs4
-rw-r--r--src/Propellor/Types/CmdLine.hs1
4 files changed, 23 insertions, 6 deletions
diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs
index 214f65d5..a07347ed 100644
--- a/src/Propellor/Bootstrap.hs
+++ b/src/Propellor/Bootstrap.hs
@@ -1,5 +1,6 @@
module Propellor.Bootstrap (
bootstrapPropellorCommand,
+ checkBinaryCommand,
installGitCommand,
buildPropellor,
) where
@@ -12,17 +13,27 @@ import Data.List
type ShellCommand = String
--- Shell command line to build propellor, used when bootstrapping on a new
--- host. Should be run inside the propellor config dir, and will install
--- all necessary build dependencies.
+-- Shell command line to ensure propellor is bootstrapped and ready to run.
+-- Should be run inside the propellor config dir, and will install
+-- all necessary build dependencies and build propellor.
bootstrapPropellorCommand :: ShellCommand
-bootstrapPropellorCommand = "if ! test -x ./propellor; then " ++ go ++ "; fi"
+bootstrapPropellorCommand = "if ! test -x ./propellor; then " ++ go ++ "; fi;" ++ checkBinaryCommand
where
- go = intercalate " && "
+ go = intercalate " && "
[ depsCommand
, buildCommand
]
+-- Use propellor --check to detect if the local propellor binary has
+-- stopped working (eg due to library changes), and must be rebuilt.
+checkBinaryCommand :: ShellCommand
+checkBinaryCommand = "if test -x ./propellor && ! ./propellor --check 2>/dev/null; then " ++ go ++ "; fi"
+ where
+ go = intercalate " && "
+ [ "cabal clean"
+ , buildCommand
+ ]
+
buildCommand :: ShellCommand
buildCommand = intercalate " && "
[ "cabal configure"
diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs
index 9d7d0d95..1298daf2 100644
--- a/src/Propellor/CmdLine.hs
+++ b/src/Propellor/CmdLine.hs
@@ -33,6 +33,7 @@ usage h = hPutStrLn h $ unlines
, " propellor --list-fields"
, " propellor --merge"
, " propellor --build"
+ , " propellor --check"
]
usageError :: [String] -> IO a
@@ -43,6 +44,7 @@ usageError ps = do
processCmdLine :: IO CmdLine
processCmdLine = go =<< getArgs
where
+ go ("--check":_) = return Check
go ("--spin":ps) = case reverse ps of
(r:"--via":hs) -> Spin
<$> mapM hostname (reverse hs)
@@ -91,6 +93,7 @@ defaultMain hostlist = do
where
go _ (Serialized cmdline) = go True cmdline
go _ (Continue cmdline) = go False cmdline
+ go _ Check = return ()
go _ (Set field context) = setPrivData field context
go _ (Dump field context) = dumpPrivData field context
go _ (Edit field context) = editPrivData field context
diff --git a/src/Propellor/Property/Cron.hs b/src/Propellor/Property/Cron.hs
index 2a28a157..222f3849 100644
--- a/src/Propellor/Property/Cron.hs
+++ b/src/Propellor/Property/Cron.hs
@@ -3,6 +3,7 @@ module Propellor.Property.Cron where
import Propellor
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
+import Propellor.Bootstrap
import Utility.SafeCommand
import Utility.FileMode
@@ -81,4 +82,5 @@ niceJob desc times user cddir command = job desc times user cddir
-- | Installs a cron job to run propellor.
runPropellor :: Times -> Property NoInfo
-runPropellor times = niceJob "propellor" times "root" localdir "./propellor"
+runPropellor times = niceJob "propellor" times "root" localdir
+ (bootstrapPropellorCommand ++ "; ./propellor")
diff --git a/src/Propellor/Types/CmdLine.hs b/src/Propellor/Types/CmdLine.hs
index b8f488a4..bd0cbdfd 100644
--- a/src/Propellor/Types/CmdLine.hs
+++ b/src/Propellor/Types/CmdLine.hs
@@ -23,5 +23,6 @@ data CmdLine
| DockerChain HostName String
| ChrootChain HostName FilePath Bool Bool
| GitPush Fd Fd
+ | Check
deriving (Read, Show, Eq)