summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/FreeBSD/Poudriere.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Property/FreeBSD/Poudriere.hs')
-rw-r--r--src/Propellor/Property/FreeBSD/Poudriere.hs30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/Propellor/Property/FreeBSD/Poudriere.hs b/src/Propellor/Property/FreeBSD/Poudriere.hs
index 3ebb4633..32234b27 100644
--- a/src/Propellor/Property/FreeBSD/Poudriere.hs
+++ b/src/Propellor/Property/FreeBSD/Poudriere.hs
@@ -1,5 +1,5 @@
-- | Maintainer: 2016 Evan Cofsky <evan@theunixman.com>
---
+--
-- FreeBSD Poudriere properties
{-# Language GeneralizedNewtypeDeriving #-}
@@ -10,6 +10,7 @@ import Propellor.Base
import Propellor.Types.Info
import Data.List
import Data.String (IsString(..))
+import Data.String.Utils (splitWs)
import qualified Propellor.Property.FreeBSD.Pkg as Pkg
import qualified Propellor.Property.ZFS as ZFS
@@ -52,26 +53,27 @@ runPoudriere cmd args =
lines <$> readProcess p a
listJails :: IO [String]
-listJails = runPoudriere "jail" ["-l", "-q"]
+listJails =
+ map ((\(n:_) -> n ) . take 1 . splitWs) <$> runPoudriere "jail" ["-l", "-q"]
jailExists :: Jail -> IO Bool
jailExists (Jail name _ _) = isInfixOf [name] <$> listJails
jail :: Jail -> Property NoInfo
jail j@(Jail name version arch) =
- checkResult chk (\_ -> return MadeChange) createJail
+ let
+ chk = do
+ c <- poudriereConfigured <$> askInfo
+ nx <- liftIO $ not <$> jailExists j
+ return $ c && nx
+
+ (cmd, args) = poudriereCommand "jail" ["-c", "-j", name, "-a", show arch, "-v", show version]
+ createJail = cmdProperty cmd args
+ in
+ check chk createJail
`describe` unwords ["Create poudriere jail", name]
- where
- cfgd = poudriereConfigured <$> askInfo
-
- notExists :: IO Bool
- notExists = not <$> jailExists j
- chk = do
- c <- cfgd
- x <- liftIO notExists
- return $ c && x
- (cmd, args) = poudriereCommand "jail" ["-c", "-j", name, "-a", show arch, "-v", show version]
- createJail = cmdProperty cmd args
+
+data JailInfo = JailInfo String
data Poudriere = Poudriere
{ _resolvConf :: String