|author||Joey Hess||2017-07-12 19:12:36 -0400|
|committer||Joey Hess||2017-07-12 19:12:36 -0400|
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
@@ -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 (
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
+-- > host "example.com" $ 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)
+ desc = "bootstrapped with " ++ case b of
+ Robustly Stack -> "stack"
+ Robustly Cabal -> "cabal"
+ OSOnly -> "OS packages only"
-- | Where a propellor repository should be bootstrapped from.
= GitRepoUrl String
@@ -17,14 +44,17 @@ data RepoSource
-- | Bootstraps a propellor installation into
--- 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