From 681e4dbbcb880e8e2526519fc58d4f2994a41577 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Apr 2015 14:26:13 -0400 Subject: propellor spin --- src/Propellor/Engine.hs | 1 - src/Propellor/Exception.hs | 8 ++++---- src/Propellor/Property/Debootstrap.hs | 1 - src/Propellor/Spin.hs | 3 +-- src/Propellor/Types.hs | 6 ++++-- 5 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Engine.hs b/src/Propellor/Engine.hs index 99f1660d..dd3d4653 100644 --- a/src/Propellor/Engine.hs +++ b/src/Propellor/Engine.hs @@ -17,7 +17,6 @@ import Data.Monoid import Control.Applicative import System.Console.ANSI import "mtl" Control.Monad.RWS.Strict -import Control.Exception (bracket) import System.PosixCompat import System.Posix.IO import System.FilePath diff --git a/src/Propellor/Exception.hs b/src/Propellor/Exception.hs index f6fd15f1..2b38af0c 100644 --- a/src/Propellor/Exception.hs +++ b/src/Propellor/Exception.hs @@ -2,11 +2,11 @@ module Propellor.Exception where -import qualified "MonadCatchIO-transformers" Control.Monad.CatchIO as M -import Control.Exception - import Propellor.Types import Propellor.Message +import Utility.Exception + +import Control.Exception (IOException) -- | Catches IO exceptions and returns FailedChange. catchPropellor :: Propellor Result -> Propellor Result @@ -15,4 +15,4 @@ catchPropellor a = either err return =<< tryPropellor a err e = warningMessage (show e) >> return FailedChange tryPropellor :: Propellor a -> Propellor (Either IOException a) -tryPropellor = M.try +tryPropellor = try diff --git a/src/Propellor/Property/Debootstrap.hs b/src/Propellor/Property/Debootstrap.hs index d4947ab7..5d6a8bed 100644 --- a/src/Propellor/Property/Debootstrap.hs +++ b/src/Propellor/Property/Debootstrap.hs @@ -20,7 +20,6 @@ import Utility.FileMode import Data.List import Data.Char -import Control.Exception import System.Posix.Directory import System.Posix.Files diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index f55f2977..986305d7 100644 --- a/src/Propellor/Spin.hs +++ b/src/Propellor/Spin.hs @@ -12,7 +12,6 @@ import System.PosixCompat import System.Posix.IO import System.Posix.Directory import Control.Concurrent.Async -import Control.Exception (bracket) import qualified Data.ByteString as B import qualified Data.Set as S import qualified Network.BSD as BSD @@ -168,7 +167,7 @@ updateServer -> CreateProcess -> IO () updateServer target relay hst connect haveprecompiled = - withBothHandles createProcessSuccess connect go + withIOHandles createProcessSuccess connect go where hn = fromMaybe target relay relaying = relay == Just target diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs index ba63cf9d..474385b7 100644 --- a/src/Propellor/Types.hs +++ b/src/Propellor/Types.hs @@ -40,7 +40,7 @@ module Propellor.Types import Data.Monoid import Control.Applicative import "mtl" Control.Monad.RWS.Strict -import "MonadCatchIO-transformers" Control.Monad.CatchIO +import Control.Monad.Catch import qualified Data.Set as S import qualified Data.Map as M @@ -73,7 +73,9 @@ newtype Propellor p = Propellor { runWithHost :: RWST Host [EndAction] () IO p } , MonadReader Host , MonadWriter [EndAction] , MonadIO - , MonadCatchIO + , MonadCatch + , MonadThrow + , MonadMask ) instance Monoid (Propellor Result) where -- cgit v1.2.3 From 15ab46fd528b6fe697910e9ff616f5fa7f7d2c84 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Apr 2015 14:28:09 -0400 Subject: propellor spin --- src/Propellor/Bootstrap.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs index a07347ed..3c28edf0 100644 --- a/src/Propellor/Bootstrap.hs +++ b/src/Propellor/Bootstrap.hs @@ -77,7 +77,8 @@ depsCommand = "( " ++ intercalate " ; " (concat [osinstall, cabalinstall]) ++ " , "libghc-network-dev" , "libghc-quickcheck2-dev" , "libghc-mtl-dev" - , "libghc-monadcatchio-transformers-dev" + , "libghc-transformers-dev" + , "libghc-exceptions-dev" ] installGitCommand :: ShellCommand -- cgit v1.2.3 From a5842683349d6d5f41c46414e1721253f5b4779e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Apr 2015 14:31:54 -0400 Subject: Ensure build deps are installed before building propellor in --spin and cron job, even if propellor was already built before, to deal with upgrades that add new dependencies. --- debian/changelog | 3 +++ src/Propellor/Bootstrap.hs | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Propellor') diff --git a/debian/changelog b/debian/changelog index 592c75a7..5c166f0b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,9 @@ propellor (2.4.0) UNRELEASED; urgency=medium * Merged Utility changes from git-annex. * Switched from MonadCatchIO-transformers to the newer transformers and exceptions libraries. + * Ensure build deps are installed before building propellor in --spin + and cron job, even if propellor was already built before, to deal with + upgrades that add new dependencies. -- Joey Hess Wed, 22 Apr 2015 20:59:59 -0400 diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs index 3c28edf0..260d8117 100644 --- a/src/Propellor/Bootstrap.hs +++ b/src/Propellor/Bootstrap.hs @@ -17,12 +17,10 @@ type ShellCommand = String -- 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;" ++ checkBinaryCommand - where - go = intercalate " && " - [ depsCommand - , buildCommand - ] +bootstrapPropellorCommand = depsCommand ++ + "&& if ! test -x ./propellor; then " + ++ buildCommand ++ + "; fi;" ++ checkBinaryCommand -- Use propellor --check to detect if the local propellor binary has -- stopped working (eg due to library changes), and must be rebuilt. -- cgit v1.2.3 From 6288393b4b5e413b2634b0ea59cbc8713061d5cd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Apr 2015 14:41:46 -0400 Subject: avoid checking build deps if cabal configures ok --- src/Propellor/Bootstrap.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs index 260d8117..51ba69a4 100644 --- a/src/Propellor/Bootstrap.hs +++ b/src/Propellor/Bootstrap.hs @@ -17,7 +17,7 @@ type ShellCommand = String -- Should be run inside the propellor config dir, and will install -- all necessary build dependencies and build propellor. bootstrapPropellorCommand :: ShellCommand -bootstrapPropellorCommand = depsCommand ++ +bootstrapPropellorCommand = checkDepsCommand ++ "&& if ! test -x ./propellor; then " ++ buildCommand ++ "; fi;" ++ checkBinaryCommand @@ -39,6 +39,11 @@ buildCommand = intercalate " && " , "ln -sf dist/build/propellor-config/propellor-config propellor" ] +-- Run cabal configure to check if all dependencies are installed; +-- if not, run the depsCommand. +checkDepsCommand :: ShellCommand +checkDepsCommand = "if ! cabal configure >/dev/null 2>&1; then " ++ depsCommand ++ "; fi" + -- Install build dependencies of propellor. -- -- First, try to install ghc, cabal, gnupg, and all haskell libraries that -- cgit v1.2.3 From e4432caa1280a3c91f8014fe4be0d29424413948 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Apr 2015 14:44:56 -0400 Subject: remove unused import --- src/Propellor/Message.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Message.hs b/src/Propellor/Message.hs index bcd99649..f62d3cd9 100644 --- a/src/Propellor/Message.hs +++ b/src/Propellor/Message.hs @@ -6,7 +6,7 @@ import System.Console.ANSI import System.IO import System.Log.Logger import System.Log.Formatter -import System.Log.Handler (setFormatter, LogHandler) +import System.Log.Handler (setFormatter) import System.Log.Handler.Simple import "mtl" Control.Monad.Reader import Data.Maybe -- cgit v1.2.3