path: root/src/Propellor/Property/Bootstrap.hs
diff options
authorJoey Hess2017-07-12 19:12:36 -0400
committerJoey Hess2017-07-12 19:12:36 -0400
commit08010583fa42af1b2b5ab070e4742263d43b26cf (patch)
tree6a65363f435863139950616cc12ca7ef74042fdf /src/Propellor/Property/Bootstrap.hs
parent8e172612f5675a9dab4c302e9353af7e77773d45 (diff)
add bootstrapWith property to support stack and more
* Hosts can be configured to build propellor using stack, by adding a property: & bootstrapWith (Robustly Stack) * Hosts can be configured to build propellor using cabal, but using only packages installed from the operating system. This will work on eg Debian: & bootstrapWith OSOnly propellor build its config using stack. (This does not affect how propellor is bootstrapped on a host by "propellor --spin host".) This has not yet been tested at all! But should probably work fine. This is based on earlier work by Arnaud Bailly, who made Propellor.Bootstrap use stack without parameterization. In Arnaud's patch, stack was installed using wget, but that only worked on linux-x86_64 and was insecure. I instead chose to use the distribution packages of stack, like is done for cabal. Debian stack has haskell-stack now, and it's getting into many distributions. This commit was sponsored by Francois Marier on Patreon.
Diffstat (limited to 'src/Propellor/Property/Bootstrap.hs')
1 files changed, 38 insertions, 7 deletions
diff --git a/src/Propellor/Property/Bootstrap.hs b/src/Propellor/Property/Bootstrap.hs
index 767d6ef7..93529c14 100644
--- a/src/Propellor/Property/Bootstrap.hs
+++ b/src/Propellor/Property/Bootstrap.hs
@@ -1,12 +1,39 @@
-module Propellor.Property.Bootstrap (RepoSource(..), bootstrappedFrom, clonedFrom) where
+-- | This module contains properties that configure how Propellor
+-- bootstraps to run itself on a Host.
+module Propellor.Property.Bootstrap (
+ Bootstrapper(..),
+ bootstrapWith,
+ RepoSource(..),
+ bootstrappedFrom,
+ clonedFrom
+) where
import Propellor.Base
import Propellor.Bootstrap
+import Propellor.Types.Info
import Propellor.Property.Chroot
import Data.List
import qualified Data.ByteString as B
+-- | This property can be used to configure the `Bootstrapper` that is used
+-- to bootstrap propellor on a Host. For example, if you want to use
+-- stack:
+-- > host "" $ props
+-- > & bootstrapWith (Robustly Stack)
+-- When `bootstrappedFrom` is used in a `Chroot` or other `Container`,
+-- this property can also be added to the chroot to configure it.
+bootstrapWith :: Bootstrapper -> Property (HasInfo + UnixLike)
+bootstrapWith b = pureInfoProperty desc (InfoVal b)
+ where
+ desc = "bootstrapped with " ++ case b of
+ Robustly Stack -> "stack"
+ Robustly Cabal -> "cabal"
+ OSOnly -> "OS packages only"
-- | Where a propellor repository should be bootstrapped from.
data RepoSource
= GitRepoUrl String
@@ -17,14 +44,17 @@ data RepoSource
-- | Bootstraps a propellor installation into
-- /usr/local/propellor/
--- This property only does anything when used inside a chroot.
--- This is particularly useful inside a chroot used to build a
+-- Normally, propellor is bootstrapped by eg, using propellor --spin,
+-- and so this property is not generally needed.
+-- This property only does anything when used inside a Chroot or other
+-- Container. This is particularly useful inside a chroot used to build a
-- disk image, to make the disk image have propellor installed.
-- The git repository is cloned (or pulled to update if it already exists).
-- All build dependencies are installed, using distribution packages
--- or falling back to using cabal.
+-- or falling back to using cabal or stack.
bootstrappedFrom :: RepoSource -> Property Linux
bootstrappedFrom reposource = check inChroot $
go `requires` clonedFrom reposource
@@ -32,14 +62,15 @@ bootstrappedFrom reposource = check inChroot $
go :: Property Linux
go = property "Propellor bootstrapped" $ do
system <- getOS
+ bootstrapper <- getBootstrapper
assumeChange $ exposeTrueLocaldir $ const $
runShellCommand $ buildShellCommand
[ "cd " ++ localdir
- , checkDepsCommand system
- , buildCommand
+ , checkDepsCommand bootstrapper system
+ , buildCommand bootstrapper
--- | Clones the propellor repeository into /usr/local/propellor/
+-- | Clones the propellor repository into /usr/local/propellor/
-- If the propellor repo has already been cloned, pulls to get it
-- up-to-date.