From cb6503bfa32365b96a6b676eb4d0074df2601554 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 20:27:15 +0900 Subject: Joey's Schroot.useOverlays info property --- src/Propellor/Property/Schroot.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/Propellor/Property/Schroot.hs') diff --git a/src/Propellor/Property/Schroot.hs b/src/Propellor/Property/Schroot.hs index c53ce4f1..0e683562 100644 --- a/src/Propellor/Property/Schroot.hs +++ b/src/Propellor/Property/Schroot.hs @@ -3,11 +3,27 @@ module Propellor.Property.Schroot where import Propellor.Base +import Propellor.Types.Info import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt import Utility.FileMode +data UseOverlays = UseOverlays deriving (Eq, Show) + +-- | Indicate that a schroots on a host should use @union-type=overlay@ +-- +-- Setting this property does not actually ensure that the line +-- @union-type=overlay@ is present in any schroot config files. See +-- 'Propellor.Property.Sbuild.built' for example usage. +useOverlays :: Property (HasInfo + UnixLike) +useOverlays = pureInfoProperty "use schroot overlays" (InfoVal UseOverlays) + +-- | Gets whether a host uses overlays. +usesOverlays :: Propellor Bool +usesOverlays = isJust . fromInfoVal + <$> (askInfo :: Propellor (InfoVal UseOverlays)) + -- | Configure schroot such that all schroots with @union-type=overlay@ in their -- configuration will run their overlays in a tmpfs. -- -- cgit v1.2.3 From 1a84be997bd9bacc632b0965f965557f7c10e686 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 20:27:28 +0900 Subject: Schroot.overlaysInTmpfs sets Schroot.useOverlays --- src/Propellor/Property/Schroot.hs | 47 +++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'src/Propellor/Property/Schroot.hs') diff --git a/src/Propellor/Property/Schroot.hs b/src/Propellor/Property/Schroot.hs index 0e683562..0e52f1a4 100644 --- a/src/Propellor/Property/Schroot.hs +++ b/src/Propellor/Property/Schroot.hs @@ -27,32 +27,35 @@ usesOverlays = isJust . fromInfoVal -- | Configure schroot such that all schroots with @union-type=overlay@ in their -- configuration will run their overlays in a tmpfs. -- +-- Implicitly sets 'useOverlays' info property. +-- -- Shell script from . -overlaysInTmpfs :: Property DebianLike +overlaysInTmpfs :: Property (HasInfo + DebianLike) overlaysInTmpfs = go `requires` installed where f = "/etc/schroot/setup.d/04tmpfs" - go :: Property UnixLike - go = f `File.hasContent` - [ "#!/bin/sh" - , "" - , "set -e" - , "" - , ". \"$SETUP_DATA_DIR/common-data\"" - , ". \"$SETUP_DATA_DIR/common-functions\"" - , ". \"$SETUP_DATA_DIR/common-config\"" - , "" - , "" - , "if [ $STAGE = \"setup-start\" ]; then" - , " mount -t tmpfs overlay /var/lib/schroot/union/overlay" - , "elif [ $STAGE = \"setup-recover\" ]; then" - , " mount -t tmpfs overlay /var/lib/schroot/union/overlay" - , "elif [ $STAGE = \"setup-stop\" ]; then" - , " umount -f /var/lib/schroot/union/overlay" - , "fi" - ] - `onChange` (f `File.mode` (combineModes (readModes ++ executeModes))) - `describe` "schroot overlays in tmpfs" + go :: Property (HasInfo + UnixLike) + go = combineProperties "schroot overlays in tmpfs" $ props + & useOverlays + & f `File.hasContent` + [ "#!/bin/sh" + , "" + , "set -e" + , "" + , ". \"$SETUP_DATA_DIR/common-data\"" + , ". \"$SETUP_DATA_DIR/common-functions\"" + , ". \"$SETUP_DATA_DIR/common-config\"" + , "" + , "" + , "if [ $STAGE = \"setup-start\" ]; then" + , " mount -t tmpfs overlay /var/lib/schroot/union/overlay" + , "elif [ $STAGE = \"setup-recover\" ]; then" + , " mount -t tmpfs overlay /var/lib/schroot/union/overlay" + , "elif [ $STAGE = \"setup-stop\" ]; then" + , " umount -f /var/lib/schroot/union/overlay" + , "fi" + ] + `onChange` (f `File.mode` combineModes (readModes ++ executeModes)) installed :: Property DebianLike installed = Apt.installed ["schroot"] -- cgit v1.2.3 From d436af8f42e05272e369af3f69a65bac157db725 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 21:06:19 +0900 Subject: Typeable in Schroot.hs --- src/Propellor/Property/Schroot.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Propellor/Property/Schroot.hs') diff --git a/src/Propellor/Property/Schroot.hs b/src/Propellor/Property/Schroot.hs index 0e52f1a4..bb20f6e6 100644 --- a/src/Propellor/Property/Schroot.hs +++ b/src/Propellor/Property/Schroot.hs @@ -1,5 +1,7 @@ -- | Maintainer: Sean Whitton +{-# LANGUAGE DeriveDataTypeable #-} + module Propellor.Property.Schroot where import Propellor.Base @@ -9,7 +11,7 @@ import qualified Propellor.Property.Apt as Apt import Utility.FileMode -data UseOverlays = UseOverlays deriving (Eq, Show) +data UseOverlays = UseOverlays deriving (Eq, Show, Typeable) -- | Indicate that a schroots on a host should use @union-type=overlay@ -- -- cgit v1.2.3 From cde491e5767caca7bf10bca16d625e713ba24a9b Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 22:04:31 +0900 Subject: docs on property ordering --- src/Propellor/Property/Sbuild.hs | 2 +- src/Propellor/Property/Schroot.hs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/Propellor/Property/Schroot.hs') diff --git a/src/Propellor/Property/Sbuild.hs b/src/Propellor/Property/Sbuild.hs index 5d58a84a..bb1a2a0a 100644 --- a/src/Propellor/Property/Sbuild.hs +++ b/src/Propellor/Property/Sbuild.hs @@ -9,12 +9,12 @@ Build and maintain schroots for use with sbuild. Suggested usage in @config.hs@: > & Apt.installed ["piuparts", "autopkgtest"] +> & Schroot.overlaysInTmpfs > & Sbuild.builtFor (System (Debian Unstable) X86_32) > & Sbuild.piupartsConfFor (System (Debian Unstable) X86_32) > & Sbuild.updatedFor (System (Debian Unstable) X86_32) `period` Weekly 1 > & Sbuild.usableBy (User "spwhitton") > & Sbuild.shareAptCache -> & Schroot.overlaysInTmpfs In @~/.sbuildrc@: diff --git a/src/Propellor/Property/Schroot.hs b/src/Propellor/Property/Schroot.hs index bb20f6e6..20c98e60 100644 --- a/src/Propellor/Property/Schroot.hs +++ b/src/Propellor/Property/Schroot.hs @@ -18,6 +18,17 @@ data UseOverlays = UseOverlays deriving (Eq, Show, Typeable) -- Setting this property does not actually ensure that the line -- @union-type=overlay@ is present in any schroot config files. See -- 'Propellor.Property.Sbuild.built' for example usage. +-- +-- You should apply this property to a host before any properties that can use +-- overlays. For example, use +-- +-- > & Schroot.useOverlays +-- > & Sbuild.builtFor (System (Debian Unstable) X86_32) +-- +-- rather than +-- +-- > & Sbuild.builtFor (System (Debian Unstable) X86_32) +-- > & Schroot.useOverlays useOverlays :: Property (HasInfo + UnixLike) useOverlays = pureInfoProperty "use schroot overlays" (InfoVal UseOverlays) @@ -29,7 +40,9 @@ usesOverlays = isJust . fromInfoVal -- | Configure schroot such that all schroots with @union-type=overlay@ in their -- configuration will run their overlays in a tmpfs. -- --- Implicitly sets 'useOverlays' info property. +-- Implicitly sets 'useOverlays' info property. Like that property, you should +-- apply 'overlaysInTmpfs' to a host before applying any properties that can use +-- overlays (e.g. 'Propellor.Property.Sbuild.built'). -- -- Shell script from . overlaysInTmpfs :: Property (HasInfo + DebianLike) -- cgit v1.2.3 From 9ae2b69b2a388fdb9d18f64f4a813089768c0d69 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 21 Jun 2016 18:01:57 +0900 Subject: Revert "docs on property ordering" This reverts commit cde491e5767caca7bf10bca16d625e713ba24a9b. --- src/Propellor/Property/Sbuild.hs | 2 +- src/Propellor/Property/Schroot.hs | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) (limited to 'src/Propellor/Property/Schroot.hs') diff --git a/src/Propellor/Property/Sbuild.hs b/src/Propellor/Property/Sbuild.hs index bb1a2a0a..5d58a84a 100644 --- a/src/Propellor/Property/Sbuild.hs +++ b/src/Propellor/Property/Sbuild.hs @@ -9,12 +9,12 @@ Build and maintain schroots for use with sbuild. Suggested usage in @config.hs@: > & Apt.installed ["piuparts", "autopkgtest"] -> & Schroot.overlaysInTmpfs > & Sbuild.builtFor (System (Debian Unstable) X86_32) > & Sbuild.piupartsConfFor (System (Debian Unstable) X86_32) > & Sbuild.updatedFor (System (Debian Unstable) X86_32) `period` Weekly 1 > & Sbuild.usableBy (User "spwhitton") > & Sbuild.shareAptCache +> & Schroot.overlaysInTmpfs In @~/.sbuildrc@: diff --git a/src/Propellor/Property/Schroot.hs b/src/Propellor/Property/Schroot.hs index 20c98e60..bb20f6e6 100644 --- a/src/Propellor/Property/Schroot.hs +++ b/src/Propellor/Property/Schroot.hs @@ -18,17 +18,6 @@ data UseOverlays = UseOverlays deriving (Eq, Show, Typeable) -- Setting this property does not actually ensure that the line -- @union-type=overlay@ is present in any schroot config files. See -- 'Propellor.Property.Sbuild.built' for example usage. --- --- You should apply this property to a host before any properties that can use --- overlays. For example, use --- --- > & Schroot.useOverlays --- > & Sbuild.builtFor (System (Debian Unstable) X86_32) --- --- rather than --- --- > & Sbuild.builtFor (System (Debian Unstable) X86_32) --- > & Schroot.useOverlays useOverlays :: Property (HasInfo + UnixLike) useOverlays = pureInfoProperty "use schroot overlays" (InfoVal UseOverlays) @@ -40,9 +29,7 @@ usesOverlays = isJust . fromInfoVal -- | Configure schroot such that all schroots with @union-type=overlay@ in their -- configuration will run their overlays in a tmpfs. -- --- Implicitly sets 'useOverlays' info property. Like that property, you should --- apply 'overlaysInTmpfs' to a host before applying any properties that can use --- overlays (e.g. 'Propellor.Property.Sbuild.built'). +-- Implicitly sets 'useOverlays' info property. -- -- Shell script from . overlaysInTmpfs :: Property (HasInfo + DebianLike) -- cgit v1.2.3