diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-03-30 15:18:39 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-03-30 15:20:52 -0400 |
| commit | bc607807f9aa7dffea4e6e3267b4874acd64747f (patch) | |
| tree | 661dc511b8ba2de2f89f201603b182341b682118 /src/Propellor/Bootstrap.hs | |
| parent | d051f2b366cbdfdbf879176094cb2c3c4ad67391 (diff) | |
When new dependencies are added to propellor or the propellor config, try harder to get them installed.
In particular, this makes propellor --spin work when the remote host needs
to get dependencies installed in order to build the updated config.
Fixes http://propellor.branchable.com/todo/problem_with_spin_after_new_dependencies_added/
(cherry picked from commit 0f410f8acdb9e0b84ae364e80e5ee63adcb2ee50)
Diffstat (limited to 'src/Propellor/Bootstrap.hs')
| -rw-r--r-- | src/Propellor/Bootstrap.hs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs index 69eee66c..b81a2302 100644 --- a/src/Propellor/Bootstrap.hs +++ b/src/Propellor/Bootstrap.hs @@ -6,6 +6,7 @@ module Propellor.Bootstrap ( ) where import Propellor.Base +import Propellor.Types.Info import System.Posix.Files import Data.List @@ -128,22 +129,27 @@ installGitCommand msys = case msys of , "DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends --no-upgrade -y install git" ] -buildPropellor :: IO () -buildPropellor = unlessM (actionMessage "Propellor build" build) $ +buildPropellor :: Maybe Host -> IO () +buildPropellor mh = unlessM (actionMessage "Propellor build" (build msys)) $ errorMessage "Propellor build failed!" + where + msys = case fmap (getInfo . hostInfo) mh of + Just (InfoVal sys) -> Just sys + _ -> Nothing -- Build propellor using cabal, and symlink propellor to where cabal -- leaves the built binary. -- -- For speed, only runs cabal configure when it's not been run before. -- If the build fails cabal may need to have configure re-run. -build :: IO Bool -build = catchBoolIO $ do - make "dist/setup-config" ["propellor.cabal"] $ - cabal ["configure"] - unlessM (cabal ["build", "propellor-config"]) $ do - void $ cabal ["configure"] - unlessM (cabal ["build"]) $ +-- +-- If the cabal configure fails, and a System is provided, installs +-- dependencies and retries. +build :: Maybe System -> IO Bool +build msys = catchBoolIO $ do + make "dist/setup-config" ["propellor.cabal"] cabal_configure + unlessM cabal_build $ + unlessM (cabal_configure <&&> cabal_build) $ error "cabal build failed" -- For safety against eg power loss in the middle of the build, -- make a copy of the binary, and move it into place atomically. @@ -163,6 +169,15 @@ build = catchBoolIO $ do cabalbuiltbin = "dist/build/propellor-config/propellor-config" safetycopy = cabalbuiltbin ++ ".built" tmpfor f = f ++ ".propellortmp" + cabal_configure = ifM (cabal ["configure"]) + ( return True + , case msys of + Nothing -> return False + Just sys -> + boolSystem "sh" [Param "-c", Param (depsCommand (Just sys))] + <&&> cabal ["configure"] + ) + cabal_build = cabal ["build", "propellor-config"] make :: FilePath -> [FilePath] -> IO Bool -> IO () make dest srcs builder = do |
